Import¶
POST /api/v1/log_index_cfg/import
Overview¶
Batch 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[*].isFullLineIndex | int | Whether it is a full-line index; 0/false means keep the message field index, 1/true means full-line index, default 0; only workspaces with log storage as scopedb are allowed to set to 1 Allow empty: False |
|
| logIndexes[*].conditions | string | Matching conditions 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[*].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 Supplementary Description¶
This interface is used to import log index templates individually.
Call Flow
- Prepare the
logIndexesarray, each element represents a log index template. - Specify the handling strategy for encountering duplicate index names via
repeatLogIndexNameOp. - If the strategy is
checkand duplicate names exist, the interface will returnrepeat_nameand will not perform database operations.
repeatLogIndexNameOp Description
| Value | Description |
|---|---|
| check | Only check for duplicates; returns repeat_name when duplicate names exist |
| skip | Skip existing duplicate-named indices, only import non-existing indices |
| recover | When the target workspace already has a duplicate-named index, overwrite that index configuration according to the imported template |
Special Rules
- Templates with
name=defaultwill be ignored and not imported. - External index templates will be ignored and not imported.
recoveronly overwrites internal indices with the same name and will not operate ondefault.
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, 0 means keep the message field index, 1 means full-line index, default 0; only workspaces with log storage as scopedb are allowed to set to 1 |
| conditions | string | No | Matching conditions |
| 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 |
| is_disable | boolean | No | Whether disabled |
Return Description
- Returns
successCount,failCountupon successful import. - If some objects fail, the return will additionally include
failedNames. - In
checkmode, if duplicates are found, returnsrepeat_name.
Request Example¶
curl 'https://openapi.guance.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,"isFullLineIndex":0,"conditions":"","duration":"7d","storagePolicy":{},"extend":{},"setting":{},"fields":[],"is_disable":false}]}'