Skip to content

Online DataKit List



GET /api/v1/datakit/list

Overview

Lists the DataKit reporting records visible on the current site, filterable by workspace, version, and activity status.

Prerequisites and Usage Steps

If you need to verify the DataKit instances in a workspace, first obtain the workspaceUUID, then query page by page. Online filtering is based on whether data was reported on the current day and on the site activity duration threshold. To filter instances that have sent a heartbeat within a recent period, use lastHeartbeatTime. When you go beyond the last page, data is empty and totalCount may return 0; the client can stop at the empty page.

The example uses External API signature version v20240417. Set the target site's External API URL, Access Key, and Secret Key to DF_EXTERNAL_API_URL, DF_EXTERNAL_ACCESS_KEY, and DF_EXTERNAL_SECRET_KEY, respectively. Replace the example IDs with actual values.

Request Headers

Parameter Name Type Required Description
X-Df-SVersion string Signature version; the following example uses v20240417.
Example: v20240417
How to obtain or fill in: Enter it exactly as shown in the example, corresponding to the signature algorithm.
X-Df-Access-Key string Y Request AK information
Example: <access-key>
How to obtain or fill in: Assigned by the External API administrator.
X-Df-Signature string Y Signature information
Example: <hex-signature>
How to obtain or fill in: Use the Secret Key to compute HMAC-SHA256 over the text consisting of GET, the nonce, the request path and raw query string, the timestamp, and an empty string, then take the hexadecimal result.
X-Df-Timestamp string Y Timestamp at request time
Example: 1785456000
How to obtain or fill in: Enter the current Unix second at call time, for example by running date +%s.
X-Df-Nonce string Y Temporary code generated for the request
Example: b53b47e12e514616ad8cb1f17cb66dce
How to obtain or fill in: Generate a new random value for each request, for example uuid.uuid4().hex.

Query Request Parameters

Parameter Name Type Required Description
workspaceUUID string UUID of the target workspace.
Null allowed: False
Example: wksp_example
How to obtain or fill in: Obtain it from content.data[].uuid in the response of Workspace List and use the original value.
version string Exact match against the original version string.
Null allowed: False
Example: 1.70.0
How to obtain or fill in: Obtain the full version number from the DataKit installation information or content.data[].version in the historical list.
search string Uses case-insensitive fuzzy matching.
Null allowed: False
Example: web-01
How to obtain or fill in: Enter part of an existing host name, runtime ID, IP, or selected field in the DataKit report.
searchKeys string Matching fields used when search takes effect. Defaults to hostName, extend.ip, extend.runtime_id.
Null allowed: False
Example: hostName,extend.ip,extend.runtime_id
How to obtain or fill in: Separate with commas, and select as needed from hostName, os, arch, version, or fields under extend.
isOnline boolean When omitted, records are not filtered by the current-day active condition.
Null allowed: False
Example: true
How to obtain or fill in: Pass true to query active records for the current day; pass false to query records that do not meet the threshold or did not report on the current day.
lastHeartbeatTime integer Reporting occurred within the last N seconds; minimum 1. Counted backward from the server's current time.
Null allowed: False
$minValue: 1
Example: 600
How to obtain or fill in: Convert the heartbeat observation window to seconds; for example, pass 600 to query the last 10 minutes.
pageIndex integer Page number, default 1.
Null allowed: False
$minValue: 1
Example: 1
How to obtain or fill in: Increment page by page starting from 1, and verify against the response page number.
pageSize integer Number of records per page, default 50. Enter a positive integer.
Null allowed: False
$minValue: 1
Example: 50
How to obtain or fill in: Enter an integer based on the page capacity required by the client.

Additional Parameter Notes

Use the External API signing credentials assigned to the current target site.

Request Example

import hmac
import os
import time
import uuid
from urllib.parse import urlencode
import requests

server = os.environ["DF_EXTERNAL_API_URL"].rstrip("/")
path = "/api/v1/datakit/list"
query = {'workspaceUUID': 'wksp_example', 'search': 'web-01', 'lastHeartbeatTime': 600}
if query:
    path += "?" + urlencode(query)
timestamp = str(int(time.time()))
nonce = uuid.uuid4().hex
payload = " ".join(("GET", nonce, path, timestamp, ""))
signature = hmac.digest(os.environ["DF_EXTERNAL_SECRET_KEY"].encode(), payload.encode(), "sha256").hex()
headers = {
    "X-Df-Access-Key": os.environ["DF_EXTERNAL_ACCESS_KEY"],
    "X-Df-Timestamp": timestamp,
    "X-Df-Nonce": nonce,
    "X-Df-SVersion": "v20240417",
    "X-Df-Signature": signature,
}
try:
    result = requests.get(server + path, headers=headers, timeout=15)
except requests.RequestException:
    print('读取失败,可退避后重新签名重试,保留traceId及查询条件。')
    raise SystemExit(1)
if not 200 <= result.status_code < 300:
    print("HTTP", result.status_code, result.text)  # Preserve errorCode, content, and traceId; do not output AK/SK.
    raise SystemExit(1)
data = result.json()["content"]

Response

HTTP 200, application/json.

Field Type Description
content.data array<object> Results on this page; an empty array when there are no records.
content.data[].id integer DataKit reporting record ID.
content.data[].workspaceUUID string UUID of the workspace to which the record belongs.
content.data[].workspaceName string or null Name of the workspace to which the record belongs; null when no match is found.
content.data[].hostName string Reported host name.
content.data[].os string Operating system.
content.data[].arch string Architecture.
content.data[].version string DataKit version.
content.data[].lastUpdateTime integer Last reporting time, in Unix seconds.
content.data[].onlineTime integer Recorded active duration, used to determine current-day activity.
content.data[].usageCores integer Number of cores reported.
content.data[].extend object or null Extended attributes reported during collection; may include IP, runtime_id, and so on depending on the actual deployment.
content.data[].status integer Record status. This API returns only visible, non-deleted records.
content.pageInfo object Pagination information.
content.pageInfo.pageIndex integer Current page number, starting from 1.
content.pageInfo.pageSize integer Number of records per page.
content.pageInfo.count integer Number of records returned on the current page.
content.pageInfo.totalCount integer Total number of records that meet the conditions; for some APIs, an empty page returns 0, as described in the usage notes.
{
  "code": 200,
  "content": {
    "data": [
      {
        "id": 1,
        "workspaceUUID": "wksp_example",
        "workspaceName": "生产监控",
        "hostName": "web-01",
        "os": "linux",
        "arch": "amd64",
        "version": "1.70.0",
        "lastUpdateTime": 1785456000,
        "onlineTime": 900,
        "usageCores": 4,
        "extend": {
          "ip": "192.0.2.10"
        },
        "status": 0
      }
    ],
    "pageInfo": {
      "pageIndex": 1,
      "pageSize": 50,
      "count": 1,
      "totalCount": 1
    }
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

For authentication, rate limiting, and common request errors, see Common Error Definitions.

HTTP Status errorCode Trigger Condition Message or Response Description Handling
406 ft.ParameterValidationFailed A query parameter is not declared or its value exceeds the constraints in the parameter table The message identifies the field or rule. Verify the parameter name, type, and value range.

Feedback

Is this page helpful?