Import¶
POST /api/v1/log_index_cfg/import
Overview¶
Batch import log index templates, with support for duplicate name checking, skipping, and overwriting.
Body Request Parameters¶
| Parameter | 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[*].isFullLineIndex | int | Whether it is a full-line index; supports integer 0/1 or boolean false/true; for a new Scopedb index, the default is 1 and cannot be set to 0; when overwriting an existing index, 0/false can be switched to 1/true, while reverse switching is prohibited; if not passed, the original value is retained Allow empty: False |
|
| logIndexes[*].conditions | string | Matching condition Allow empty: False |
|
| logIndexes[*].duration | string | Storage duration Allow empty: False |
|
| logIndexes[*].storagePolicy | json | Long-term storage policy 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[*].cloneConfig | json | Complete clone index configuration; null is allowed when there is no clone index Allow empty: True |
|
| logIndexes[*].is_disable | boolean | Whether it is disabled Allow empty: False |
|
| repeatLogIndexNameOp | string | Handling strategy for duplicate log index names Allow empty: False Valid values: ['check', 'skip', 'recover'] |
Additional Parameter Notes¶
This API is specifically used to import log index templates.
Call Flow
- Prepare the
logIndexesarray, where each element represents a log index template. - Use
repeatLogIndexNameOpto specify the handling strategy when an index with the same name is encountered. - If the strategy is
checkand an index with the same name exists, the API returnsrepeat_nameand does not write to the database.
repeatLogIndexNameOp Description
| Value | Description |
|---|---|
| check | Only checks for duplicates; returns repeat_name if an index with the same name exists |
| skip | Skips existing indices with the same name and imports only indices that do not exist |
| recover | When the target workspace already has an index with the same name, overwrites that index's configuration according to the imported template |
Special Rules
- Templates with
name=defaultare ignored and not imported - External index templates are ignored and not imported
recoveronly overwrites internal indices with the same name and does not affectdefault
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 |
| isFullLineIndex | int | No | Whether it is a full-line index; supports integer 0/1 or boolean false/true; for a new Scopedb index, the default is 1 and cannot be set to 0; when overwriting an existing index, 0→1 is allowed while 1→0 is prohibited; if not passed, the original value is retained |
| conditions | string | No | Matching condition |
| duration | string | No | Storage duration |
| storagePolicy | json | No | Long-term storage policy |
| extend | json | No | Extended configuration |
| setting | json | No | Storage settings |
| fields | array | No | Field mapping |
| cloneConfig | json/null | No | Complete clone index configuration; pass null when there is no clone index |
| is_disable | boolean | No | Whether it is disabled |
Response Description
- On successful import,
successCountandfailCountare returned - If some objects fail, the response additionally includes
failedNames - In
checkmode, if duplicates are found,repeat_nameis returned
Example Request¶
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":"应用日志索引","directIndex":false,"isFullLineIndex":1,"conditions":"","duration":"7d","storagePolicy":{},"extend":{},"setting":{},"fields":[],"cloneConfig":{"name":"app-log-clone","desc":"应用日志克隆索引","isFullLineIndex":1,"conditions":"service = '\''api'\''","duration":"3d","storagePolicy":{},"extend":{"matchMode":"basic","filters":[{"name":"service","condition":"and","operation":"=","value":["api"]}]},"setting":{},"fields":[{"field":"host_alias","originalField":"host"}],"is_disable":false},"is_disable":false}]}'