Skip to content

Get Measurement Fields and Associated Tags



GET /api/v1/metric_info/measurement/schema

Overview

Get the fields, field types, and Tag information discovered for the specified Measurement on the current day.

Before Calling and Usage Steps

Query the field names, value types, units, and descriptions of a Measurement, as well as the Tags associated with each field. The query scope is fixed to the current day in the target Workspace's time zone; this API does not accept custom dates or time ranges.

  1. Obtain the exact Measurement name from content.data[].name in the Get Measurement List response, and use an API Key from the same Workspace.
  2. Pass this name to the Query parameter measurement. Use --data-urlencode to encode the name; to get localized descriptions, set the Accept-Language request header, for example zh.
  3. Read fields from content.fields[] and use name to construct subsequent metric queries; read the Tag name from the field's tags[], then call Get Metric Tag Values to obtain filterable values.

If no matching fields are discovered on the current day, fields: [] is returned. Check data reporting and query permissions for the current day; do not use this to conclude that historical data does not have the field. If measurement is missing, 406 is returned; if the parameter is present but is an empty string or contains only whitespace, the current implementation returns success with content: {}. Always enter a valid name in actual calls.

Associated Tags may be cached for up to about 1 hour; if supplementing an individual Tag fails, the field may still be returned successfully with tags empty or incomplete. Therefore, tags: [] does not prove that the metric field has no Tags; retry later or verify with a Tag query.

Request Headers

Parameter Type Required Description
Accept-Language string Selects the language for field/Tag descriptions; custom metadata takes precedence over built-in descriptions, and an empty string is returned when a description is missing.
Example: zh
How to obtain or enter: Enter the language in which descriptions should be returned, for example zh.
DF-API-KEY string Y AK identifier, used for authentication
Example: <DF-API-KEY>
How to obtain or enter: Create or obtain a Key with permissions for this API in API Key management of the target Workspace.

Query Request Parameters

Parameter Type Required Description
measurement string Y Required. Exact name of the Measurement. If the parameter is missing, validation fails; an empty or all-whitespace value currently returns an empty object, which does not mean a valid Measurement has been queried.
Allows null: False
Example: cpu
How to obtain or enter: Copy from content.data[].name in Get Measurement List; do not enter a field name or DQL expression.

Additional Parameter Notes

Use GET to read data from the Workspace that the current API Key belongs to.

Request Example

curl --get 'https://openapi.truewatch.com/api/v1/metric_info/measurement/schema' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Accept-Language: zh' \
  --data-urlencode 'measurement=cpu'

Response

HTTP 200, application/json. The result for a valid name contains measurement and fields; the result for an empty name is {}. Fields, units, descriptions, and the Tag catalog vary with the current day's data and metadata configuration.

Field Type Description
content.measurement string Measurement name in the request.
content.fields array<object> Metric fields discovered on the current day; an empty array when no fields match.
content.fields[].name string Metric field name.
content.fields[].value_type string Value type returned by the query service, such as float; may be an empty string when the type is missing.
content.fields[].type string When the value type is not empty, this is fixed to gauge; otherwise, it is an empty string. This field is not a complete classification of the original metric's Counter/Gauge semantics.
content.fields[].unit string Unit configured for the field, such as percent; may be an empty string if not configured.
content.fields[].description string Localized description of the field; custom configuration takes precedence over built-in descriptions; may be an empty string if not configured.
content.fields[].tags array<object> Array of Tag objects for the field; elements are not bare strings. The associated catalog may be cached or not yet fully retrieved; an empty array does not mean there are definitely no Tags.
content.fields[].tags[].name string Exact name of the Tag.
content.fields[].tags[].description string Tag description; may be an empty string.
content.declaration object or null Workspace common declaration attached to non-empty content; may be null or an empty object when not configured. This field is not added to the empty content returned for an empty name.
{
  "code": 200,
  "content": {
    "measurement": "cpu",
    "fields": [
      {
        "name": "usage_idle",
        "value_type": "float",
        "type": "gauge",
        "unit": "percent",
        "description": "",
        "tags": [
          {
            "name": "host",
            "description": ""
          }
        ]
      }
    ],
    "declaration": null
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Successful response when no fields are discovered for the current day:

{
  "code": 200,
  "content": {
    "measurement": "cpu",
    "fields": [],
    "declaration": null
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Current response when the parameter is present but has an empty name:

{
  "code": 200,
  "content": {},
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Response

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

HTTP Status errorCode Trigger Condition Message or Response Description Resolution
406 ft.ParameterValidationFailed measurement is missing, or Query parameters not declared by this API are appended, for example date/timeRange Request field validation failed; the message indicates the field or rule. Provide the exact Measurement name and pass only the Query fields in the parameter table; the time range is fixed to the current day.
403 ft.ForbiddenQuery The current credentials are not authorized to query the data corresponding to the request Insufficient query permissions. Check the API Key's query permissions and the authorization scope for the target data.
503 ft.QueryServiceUnavailable The dependent query service is temporarily unavailable The query service is temporarily unavailable; retry later. Check content.retryable; for transient errors, retry after a delay.