Skip to content

Import



POST /api/v1/log_index_cfg/import

Overview

Bulk import log index templates, supports duplicate name checking, skipping, and overwriting.

Body Request Parameters

Parameter Name Type Required Description
logIndexes array Y List of log index templates
Allow empty: False
logIndexes[*] None
logIndexes[*].name string Y Index name
Allow empty: False
logIndexes[*].desc string Index description
Allow empty: False
logIndexes[*].directIndex boolean Whether it is a native direct-write index
Allow empty: False
logIndexes[*].conditions string Matching conditions
Allow empty: False
logIndexes[*].duration string Storage duration
Allow empty: False
logIndexes[*].extend json Extended configuration
Allow empty: False
logIndexes[*].setting json Storage settings
Allow empty: False
logIndexes[*].fields array Field mapping configuration
Allow empty: False
logIndexes[*].is_disable boolean Whether disabled
Allow empty: False
repeatLogIndexNameOp string Duplicate log index name handling strategy
Allow empty: False
Allowed values: ['check', 'skip', 'recover']

Parameter Additional Explanation

This API is used to import log index templates individually.

Calling Process

  1. Prepare the logIndexes array, each element represents a log index template.
  2. Specify the handling strategy for encountering duplicate index names via repeatLogIndexNameOp.
  3. If the strategy is check and a duplicate name exists, the API will return repeat_name and will not persist the data.

repeatLogIndexNameOp Explanation

Value Description
check Only check for duplicates; returns repeat_name if a duplicate name exists
skip Skip existing duplicate-named indices, only import non-existing indices
recover When a duplicate-named index already exists in the target workspace, overwrite its configuration with the imported template

Special Rules

  • Templates with name=default are ignored and not imported.
  • External index templates are ignored and not imported.
  • recover only overwrites internal indices with the same name; it does not operate on default.

Template Fields

Field type Required Description
name string Yes Index name
desc string No Index description
directIndex boolean No Whether it is a native direct-write index
conditions string No Matching conditions
duration string No Storage duration
extend json No Extended configuration
setting json No Storage settings
fields array No Field mapping
is_disable boolean No Whether disabled

Return Explanation

  • Returns successCount, failCount upon successful import.
  • If some objects fail, the response will additionally include failedNames.
  • In check mode, if duplicates are found, returns repeat_name.

Request Example

curl 'https://openapi.truewatch.com/api/v1/log_index_cfg/import' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json' \
--data-raw '{"repeatLogIndexNameOp":"recover","logIndexes":[{"name":"app-log","desc":"Application log index","directIndex":false,"conditions":"","duration":"7d","extend":{},"setting":{},"fields":[],"is_disable":false}]}'

Response

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