Skip to content

Create



POST /api/v1/field_cfg/add

Overview

Creates custom field descriptions, aliases, and display unit configurations for the current workspace.

Before You Call and Usage Steps

Use an API Key from the target workspace. This configuration adds display aliases, descriptions, units, and categories to existing fields; it does not create collected fields, modify actual data types, or backfill historical data. Custom configurations with the same field source and exactly the same name (case-sensitive) cannot be duplicated; different sources may use the same name.

Before creating, check existing custom configurations by source and name; even with coverInner=false, hiding a built-in configuration with the same name is not prevented. Success returns the newly created record rather than need_confirm; sysField is handled by the server, so do not submit sysField in the Body.

Cache clearing occurs after the write is committed; a 500 may still be returned if the database write succeeded but cache clearing failed. On failure, first check the list/detail to verify whether the record was created or modified rather than recreating it directly; same-name concurrency protection may briefly reject requests. After success, read back to confirm the configuration. The refresh of displayed data queries depends on the corresponding cache and query path.

Request Headers

Parameter Name Type Required Description
DF-API-KEY string Y OpenAPI authentication credential for the workspace.
Example: <DF-API-KEY>
How to obtain or enter: Obtain an OpenAPI Key with the required permissions from the API Key management of the target workspace.

Body Request Parameters

Parameter Name Type Required Description
aliasI18n.zh string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example: 主机
How to obtain or enter: Enter the zh display text; omit this key when this language does not need to be modified.
aliasI18n.en string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example: Host
How to obtain or enter: Enter the en display text; omit this key when this language does not need to be modified.
aliasI18n.zh-hant string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example:
How to obtain or enter: Enter the zh-hant display text; omit this key when this language does not need to be modified.
aliasI18n.id string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example:
How to obtain or enter: Enter the id display text; omit this key when this language does not need to be modified.
aliasI18n.ja string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example:
How to obtain or enter: Enter the ja display text; omit this key when this language does not need to be modified.
aliasI18n.ko string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example:
How to obtain or enter: Enter the ko display text; omit this key when this language does not need to be modified.
descI18n.zh string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example: 主机
How to obtain or enter: Enter the zh display text; omit this key when this language does not need to be modified.
descI18n.en string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example: Host
How to obtain or enter: Enter the en display text; omit this key when this language does not need to be modified.
descI18n.zh-hant string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example:
How to obtain or enter: Enter the zh-hant display text; omit this key when this language does not need to be modified.
descI18n.id string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example:
How to obtain or enter: Enter the id display text; omit this key when this language does not need to be modified.
descI18n.ja string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example:
How to obtain or enter: Enter the ja display text; omit this key when this language does not need to be modified.
descI18n.ko string or null Updates only this language; an empty string or null clears the original value for this language, and the actual display may still fall back to other languages.
Example:
How to obtain or enter: Enter the ko display text; omit this key when this language does not need to be modified.
name string Y Required, non-empty, up to 256 characters, case-sensitive. Creation rejects names containing the basic Chinese character range; modification does not perform the same Chinese character check, so keeping a real non-Chinese field name is recommended.
Allows null: False
Allows empty string: False
Maximum length: 256
Example: host
How to obtain or enter: Enter the real collected field name; first check for a configuration with the same source and name in the Field List.
alias string Y Required for creation; may be omitted on modification to retain existing languages; when submitted, it must be non-empty and up to 256 characters. In the same request, aliasI18n.zh takes precedence.
Allows null: False
Allows empty string: False
Maximum length: 256
Example: 主机
How to obtain or enter: Enter the Chinese alias displayed in the console; put English and other languages in aliasI18n.
aliasI18n object Optional object; unknown language keys are ignored, values should be strings, and null is converted to an empty string. Only the submitted languages are merged while other languages are retained; compatible with alias/aliasEn falling back between zh/en.
Allows null: False
Example: {"en": "Host"}
How to obtain or enter: Fill in according to the supported languages, submitting only the languages to update.
unit string Optional, up to 256 characters, defaults to an empty string; omitting it on modification clears it, and when fieldType=string it is cleared regardless of the value passed. This entry point does not perform the InvalidUnit business validation.
Allows null: False
Maximum length: 256
Allows empty string: True
Example:
How to obtain or enter: Select a valid display unit identifier according to Unit Description; enter an empty string for string.
fieldType string Optional in the declaration but recommended to always submit explicitly; omitting it on creation saves an empty string, while omitting it on modification returns 500. When string, unit is forced to be empty; for other types, the passed unit is used; historical number/time/percent cannot be submitted directly as enumerations of the current write API.
Allows null: False
Allows empty string: True
Allowed values: ['text', 'int', 'float', 'boolean', 'string', 'long']
Example: string
How to obtain or enter: Select text/int/float/boolean/string/long according to the actual field.
category string Optional, defaults to system when omitted; omitting it on modification also resets it to system rather than retaining the original category.
Allows null: False
Allows empty string: False
Allowed values: ['system', 'business', 'other']
Example: business
How to obtain or enter: Select system/business/other according to the purpose.
fieldSource string Optional, defaults to an empty string when absent. Supports lineage/logging/object/custom_object/keyevent/tracing/rum/security/network/billing and empty values. Omitting it on modification changes it to the general source rather than retaining the old value.
Allows null: False
Allows empty string: True
Allowed values: ['lineage', 'logging', 'object', 'custom_object', 'keyevent', 'tracing', 'rum', 'security', 'network', 'billing']
Example: logging
How to obtain or enter: Select according to the target data category; explicitly enter an empty string for general fields.
desc string Optional, up to 3000 characters, empty string allowed; omitting it on modification retains the old language values, and an explicit descI18n.zh takes precedence.
Allows null: False
Allows empty string: True
Maximum length: 3000
Example: 主机名称
How to obtain or enter: Enter the field's business meaning/how it is obtained; put other languages in descI18n.
descI18n object Optional object; language merging/clearing/fallback works the same as aliasI18n; OpenAPI does not accept a separate descEn parameter, so enter the English description in the en key of this object.
Allows null: False
Example: {"en": "Host name"}
How to obtain or enter: Submit descriptions to add, update, or clear by language code.
coverInner boolean Optional boolean. The historical confirmation branch is disabled: false does not prevent creating a custom field with the same name, nor does it return need_confirm. Lists are still overridden by custom fields over built-in ones, but built-in records are not modified.
Allows null: False
Example: false
How to obtain or enter: This may be omitted in the current implementation; after writing, verify the override from coverInner in the list.

Additional Parameter Notes

For unit information, see Unit Description. need_confirm confirmation is currently not required; coverInner does not control list overriding.

3. Usage notes for Field Management

3.1. Field Management provides field descriptions for field queries.
When performing the following function queries, if field descriptions need to be returned, set fieldTagDescNeeded (at the same level as queries) to true.
A value_desc field (at the same level as values and columns) will be added to the returned series.

Function Field Source/fieldSource
SHOW_FIELD(namespace=...) Uses the corresponding field source by namespace; L is logging and LN is lineage, compatible with the source mapping of dedicated SHOW field functions
SHOW_TAG_KEY ""
SHOW_OBJECT_HISTORY_FIELD "object"
SHOW_BACKUP_LOG_FIELD "logging"
SHOW_PROFILING_FIELD "tracing"
SHOW_OBJECT_FIELD "object"
SHOW_LOGGING_FIELD "logging"
SHOW_EVENT_FIELD "keyevent"
SHOW_TRACING_FIELD "tracing"
SHOW_RUM_FIELD "rum"
SHOW_CUSTOM_OBJECT_FIELD "custom_object"
SHOW_CUSTOM_OBJECT_HISTORY_FIELD "custom_object"
SHOW_NETWORK_FIELD "network"
SHOW_SECURITY_FIELD "security"
SHOW_UNRECOVERED_EVENT_FIELD "keyevent"
SHOW_TRACING_METRIC_FIELD "tracing"
SHOW_RUM_METRIC_FIELD "rum"
SHOW_NETWORK_METRIC_FIELD "network"

Note: The field descriptions for SHOW_FIELD_KEY use custom metric configuration and measurements-meta.json on the DataKit side.

3.2. Field Management provides unit information for queries

DQL query unit loading (units is added to the series in query_data results):
When querying metric data, the loaded unit information is derived from custom metric fields overriding the official metric fields (measurements-meta.json).
When querying non-metric data, the loaded unit information is the unit defined in Field Management.

3.3. Query function notes when Field Management provides unit information

When performing a DQL query, if the function used is not within the range of the configured unitWhiteFuncs functions, no unit is added, for example: count.
unitWhiteFuncs contains two categories of functions, normal and special. When a special function is used, a fixed suffix /s is added to the unit, unit = {"unit": unit, "suffix": "/s"}
The unitWhiteFuncs functions are described below:

unitWhiteFuncs:
  normal:
    - avg
    - bottom
    - top
    - difference
    - non_negative_difference
    - distinct
    - first
    - last
    - max
    - min
    - percentile
    - sum
    - median
    - mode
    - spread
    - moving_average
    - abs
    - cumsum
    - moving_average
    - series_sum
    - round
    - window
  special:
    - derivative
    - non_negative_derivative
    - rate
    - irate

4. Notes on same-name field priority

4.1. Custom fields take precedence over built-in fields.
4.2. Fields with a specific source (fieldSource) take precedence over general field sources.


Request Example

curl --request POST 'https://openapi.guance.com/api/v1/field_cfg/add' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"name":"host","alias":"主机","aliasI18n":{"en":"Host"},"fieldType":"string","fieldSource":"logging","category":"business","unit":"","desc":"主机名称","descI18n":{"en":"Host name"},"coverInner":false}'

Response

HTTP 200, application/json. The example below shows the main fields that can be read directly.

Field Type Description
content.id integer Record ID, not used for API addressing.
content.workspaceUUID string Workspace the configuration belongs to; built-in configurations belong to the system workspace.
content.status integer Record status: 0 normal, 3 soft-deleted; this detail returns only valid records belonging to the current workspace.
content.deleteAt integer Deletion time in Unix seconds; -1 if not deleted.
content.declaration object Common declaration of the current calling workspace.
content.uuid string Field configuration UUID; use this value in subsequent operations. It is not the actual field name.
content.name string Actual field name, case-sensitive.
content.alias string Alias; lists display it in the requested language, while detail/create/modify responses retain the compatible field value.
content.aliasEn string Compatible English alias; may fall back to Chinese.
content.aliasI18n object Raw alias mapping for six languages; an empty language value does not necessarily mean the display is empty.
content.desc string Description; lists display it in the requested language, while other responses use the compatible field value.
content.descEn string Compatible English description; may fall back to Chinese.
content.descI18n object Raw description mapping for six languages.
content.fieldType string Configured data type; does not change the actual collected field type. Historical built-in records may have values outside the create Body.
content.fieldSource string Applicable source; an empty string indicates a general configuration.
content.unit string Display unit; forced to be empty when saved with fieldType=string.
content.sysField integer 1 built-in, 0 custom. Built-in configurations cannot be modified/deleted through this API.
content.category string system system field, business business field, other other; older records may be empty.
content.creator string Creator identity, which may be an API Key or a system identity.
content.updator string Updater identity; an empty string if not yet updated.
content.createAt integer Creation time in Unix seconds.
content.updateAt integer Update time in Unix seconds; may be -1 if not yet updated.
content.aliasI18n.zh string Raw zh alias, usually empty when not provided; list display falls back by language.
content.aliasI18n.en string Raw en alias, usually empty when not provided; list display falls back by language.
content.aliasI18n.zh-hant string Raw zh-hant alias, usually empty when not provided; list display falls back by language.
content.aliasI18n.id string Raw id alias, usually empty when not provided; list display falls back by language.
content.aliasI18n.ja string Raw ja alias, usually empty when not provided; list display falls back by language.
content.aliasI18n.ko string Raw ko alias, usually empty when not provided; list display falls back by language.
content.descI18n.zh string Raw zh description, usually empty when not provided; list display falls back by language.
content.descI18n.en string Raw en description, usually empty when not provided; list display falls back by language.
content.descI18n.zh-hant string Raw zh-hant description, usually empty when not provided; list display falls back by language.
content.descI18n.id string Raw id description, usually empty when not provided; list display falls back by language.
content.descI18n.ja string Raw ja description, usually empty when not provided; list display falls back by language.
content.descI18n.ko string Raw ko description, usually empty when not provided; list display falls back by language.
{
  "code": 200,
  "content": {
    "id": 10,
    "uuid": "field_example",
    "workspaceUUID": "wksp_example",
    "name": "host",
    "alias": "主机",
    "aliasEn": "Host",
    "aliasI18n": {
      "zh": "主机",
      "en": "Host",
      "zh-hant": "主機",
      "id": "",
      "ja": "",
      "ko": ""
    },
    "desc": "主机名称",
    "descEn": "Host name",
    "descI18n": {
      "zh": "主机名称",
      "en": "Host name",
      "zh-hant": "主機名稱",
      "id": "",
      "ja": "",
      "ko": ""
    },
    "fieldType": "string",
    "fieldSource": "logging",
    "category": "business",
    "unit": "",
    "sysField": 0,
    "status": 0,
    "creator": "wsak_example",
    "updator": "",
    "createAt": 1785427200,
    "updateAt": -1,
    "deleteAt": -1,
    "declaration": {}
  },
  "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 Handling
406 ft.ParameterValidationFailed A request field is missing, or a field value violates the declared validation conditions Parameter parsing failed Check the parameter location, field name, type, and value.
400 ft.RequestJsonFormatError The request JSON syntax is invalid Request JSON format error Fix the JSON according to content.reason, line, and column.
400 ft.FieldCustomNameRepeat A custom configuration with the same source and name already exists in the same workspace, or a concurrent create/modify was rejected This custom field name already exists: {} First query existing records by source and name to avoid concurrent same-name submissions; after confirming the result, decide whether to modify or rename.
500 ft.InternalServerError The write, post-commit cache clearing, or response assembly failed Internal error First check the submitted status in the list/detail, then decide whether to retry to avoid duplicate creation.
406 ft.NotSupportedChinese The new name contains basic Chinese characters Chinese field names are not supported Use an actual non-Chinese field name and put the Chinese display name in alias.

Feedback

Is this page helpful?