Skip to content

Update Workspace Index Template



POST /api/v1/workspace/{workspace_uuid}/update_index_setting

Overview

Update the index template, hot storage, mappings, and retention policy for the specified workspace data type.

Before Calling and Usage Steps

First call Index Template List to confirm the current data type, storage engine, merge mode, and target log index UUID, and back up the current values before making changes. Template parameters are limited by engine capabilities: ES supports shards/replicas/advanced mappings, Doris mainly configures hot storage, and VolcTLS configures hot/cold/archive storage; SLS/Beaver prohibits this API. To apply template or mappings changes, you must also pass hotRetention; in this case, the template is constructed from the site default and then overridden with the parameters in this request, without performing a field merge with the existing template. Omitting shards, replicas, rollover thresholds, advanced switches, and similar fields may restore defaults or remove old values, or even disable existing advanced configuration. You must first read and submit the complete target template. The request example below applies only to workspaces where datastore.logging=doris has been confirmed. For ES, use the complete template. For VolcTLS, explicitly specify the target duration for each tier. To modify only the retention period, you can pass duration or storagePolicy. Omitting mappings does not automatically merge old mappings; when enabling advanced configuration, obtain the complete mappings first. After success, re-read the index template to verify; downstream updates and database commits are not in a single transaction, so on failure, first verify the actual state on both sides.

Path Parameters

Parameter Name Type Required Description
workspace_uuid string Y Target workspace UUID; not an account UUID, nor a collection Token.
Example: wksp_example001
How to obtain or enter: Obtain it from content.data[].uuid in Workspace List or content.wsInfo.uuid from a successful creation, and verify the site and workspace name.

Request Headers

Parameter Name Type Required Description
X-Df-SVersion string Must be consistent with the example; do not omit it and continue using this algorithm.
Example: v20240417
How to obtain or enter: Enter it in accordance with the original path and request body signature algorithm on this page.
X-Df-Access-Key string Y This API requires External API credentials with w write permission.
Example: <external-access-key>
How to obtain or enter: The site administrator assigns an External API AK with w permission; this is not a workspace OpenAPI Key.
X-Df-Signature string Y Compute the HMAC-SHA256 hex digest of the uppercase method, nonce, original full path, timestamp, and original UTF-8 request body joined by spaces.
Example: <hmac-sha256-hex>
How to obtain or enter: Use the matching SK to calculate it according to External API Signature Authentication and the Python template below.
X-Df-Timestamp string Y Do not reuse the fixed time in the example; it must fall within the site's signature validity window.
Example: 1785427200
How to obtain or enter: At send time, use str(int(time.time())) to generate the current Unix seconds.
X-Df-Nonce string Y Update this value and the signature each time the request is resent.
Example: 97d275ee9f774315a7885ba7347acbd9
How to obtain or enter: Regenerate with uuid.uuid4().hex for each request.

Body Request Parameters

Parameter Name Type Required Description
storagePolicy.longStorageEnabled boolean false explicitly disables it; as long as the storagePolicy object is submitted, omitting this key normalizes it to false, which may disable the original policy. To keep the original policy, omit the entire storagePolicy object.
Example: false
How to obtain or enter: Use a JSON boolean to enable or disable it, subject to engine and version conditions.
storagePolicy.longStorageDuration string Provide it when enabled; it can be omitted when disabled.
Example: 180d
How to obtain or enter: Select it from the set allowed by the site; it must be greater than the current duration or the duration in this request.
mappings.{mapping item} any Free-form structure; do not treat an example mapping key as a unified field supported by all engines.
Example: {}
How to obtain or enter: The site administrator exports it from the existing mapping configuration of the index engine, preserving that engine's structure.
data_type string Y Required enum: rum, logging, network, tracing, profiling, keyevent, security, backup_log, apm, dialtest. Merged mode usually uses apm, while split mode uses tracing/rum/profiling, etc.; this External declaration does not support rp or lineage, so do not copy the input parameters from other runtime contexts.
Null allowed: False
Allowed values: ['rum', 'logging', 'network', 'tracing', 'profiling', 'keyevent', 'security', 'backup_log', 'apm', 'dialtest']
Example: logging
How to obtain or enter: After confirming datastore and esIndexMerged from Index Template List, select a data type that actually exists in that mode.
cfg_uuid string Optional; only logging supports selecting a separate log index by this UUID. Do not provide it for non-log data types. The index must belong to the target workspace and must not be deleted.
Null allowed: False
Empty string allowed: True
Example:
How to obtain or enter: For the default index, omit it or use an empty string; to modify a custom log index, obtain the UUID from content.otherLogIndexSettings[].uuid in Index Template List.
hotRetention int Optional integer in hours; whether 0 is available is determined by the engine, and negative numbers are rejected. ES/Doris can configure the hot data duration; VolcTLS must provide a positive number of hours equal to whole days. To modify the template or mappings, this field must also be included; passing only shard/advanced fields will not apply them currently. When hotRetention is present, this template is completed with site defaults, and omitting other old fields may reset them; this is not a partial merge update.
Null allowed: False
Example: 24
How to obtain or enter: Read it from the current esIndexSettings or otherLogIndexSettings[].setting.hot_retention in Index Template List.
coldRetention int Optional integer in hours; currently validated and applied for VolcTLS. Whether other engines accept it is determined downstream and should not be regarded as a general capability. The VolcTLS default range is 30 to 1800 days; hot storage must also be provided and must be at least 7 days.
Null allowed: False
Example: 720
How to obtain or enter: Provide it only for VolcTLS according to low-frequency storage requirements, entering complete days in hours.
archiveRetention int Optional integer in hours; the VolcTLS default range is 60 to 1800 days, and hot storage must be at least 30 days. The total duration of hot, cold, and archive storage must not exceed 1800 days; the actual site range may override this.
Null allowed: False
Example: 1440
How to obtain or enter: Provide it only for VolcTLS according to archive storage requirements, entering complete days in hours.
storagePolicy json Optional long-term policy object for a single type, no longer wrapped in a logging key. Omitting it keeps the original policy; passing {} for a single policy normalizes it to longStorageEnabled=false, which may disable existing long-term storage. It is recommended to explicitly pass false to indicate disabling. Among the currently public types, it is recommended to configure long-term storage only for logging; only scopedb logs support enabling it. Long-term storage is the total retention period and must be greater than the standard retention period for that type. Logs support it only with scopedb and pay/enterprise/unlimited; metrics must comply with the billing type. pay and unlimited with Billing Center enabled require metric_point_total, and enterprise and others also reject explicit timeseries billing. By default in the repository, pay logs can select 90d/120d/180d/360d; pay metrics can additionally select 540d/720d; enterprise/unlimited logs allow 1d to 1800d, and metrics 1d to 3600d, and they must still be greater than the standard retention period. The actual selectable set and range are overridden by the site configuration.
Null allowed: False
Example: {"longStorageEnabled": false}
How to obtain or enter: Obtain it from the storagePolicy of the corresponding workspace-level or custom log index in Index Template List.
openAdvancedConfig int Optional integer; 0/1 is recommended. ES can set it; Doris/VolcTLS do not support this field even when 0 is passed, and SLS/Beaver prohibits index configuration through this API. Advanced configuration is processed only when it is submitted together with hotRetention. When hotRetention is present, this template is completed with site defaults, and omitting other old fields may reset them; this is not a partial merge update.
Null allowed: False
Example: 0
How to obtain or enter: After reading from the current index configuration, select 0 to disable or 1 to enable; use it only with engines that support advanced configuration.
mappings json Optional JSON object, not an index UUID. The mapping structure is defined by the downstream engine; Studio passes it through as an object and does not define a common type for each dynamic mapping entry. It attempts an update only when hotRetention is present and openAdvancedConfig is true; when omitted, it defaults to {}. When enabled, submit the verified complete mappings to avoid overwriting them with an empty object.
Null allowed: False
Example: {}
How to obtain or enter: The site administrator obtains the complete object from the current index advanced mapping configuration; this External module does not expose an API for reading mappings.
number_of_shards int Optional number of primary shards, an integer, used by ES; Doris/VolcTLS do not support this field. hotRetention must also be provided; otherwise, the template change is not applied. When hotRetention is present, this template is completed with site defaults, and omitting other old fields may reset them; this is not a partial merge update.
Null allowed: False
Example: 1
How to obtain or enter: First confirm the current value and ES support capabilities from Index Template List, then select according to the administrator's recommendation.
number_of_replicas int Optional number of replicas, an integer, used by ES; whether 0, which means no replicas, is allowed is determined by the engine. Doris/VolcTLS do not support this field, and template changes must include hotRetention. When hotRetention is present, this template is completed with site defaults, and omitting other old fields may reset them; this is not a partial merge update.
Null allowed: False
Example: 1
How to obtain or enter: Select according to ES high availability requirements, and first confirm the site's replica policy.
rollover_max_size int Optional integer, the underlying index rollover/split threshold. Studio does not perform unit conversion, and it should not be treated as the log byte split size loggingCutSize; use it only on ES paths that support this configuration, and it must include hotRetention. When hotRetention is present, this template is completed with site defaults, and omitting other old fields may reset them; this is not a partial merge update.
Null allowed: False
Example: 30
How to obtain or enter: Provide it according to the shard rollover policy of the target storage engine, and first confirm the threshold unit for that engine with the site administrator.
duration string Optional standard total retention period, a number followed by d; omit it or use an empty string to keep the original value. Non-VolcTLS workspace-level and custom log indexes use the retention period change path; for VolcTLS workspace-level, the standard total duration is mainly calculated from hot/cold/archive. Subject to the set/range allowed by the version.
Null allowed: False
Example: 7d
How to obtain or enter: Read it from the duration of the corresponding type or custom index in durationSet in Index Template List, then adjust it.

Additional Parameter Notes

Use site-level External API credentials with w permission. For authentication, see External API Signature Authentication. The example calculates the signature according to v20240417; use the same path, Query, and original request body for signing and sending. All examples are demonstration values; replace them with the actual target before execution. After a write request times out or returns 500, query the current state first and decide whether to retry after confirmation.

VolcTLS hot, cold, and archive parameters are all passed in hours, while standard duration is displayed in days; the default range for each tier can be overridden by the site. For complete rules, see the parameter table.

ES complete target request body example: first copy the current values from the Index Template List, then change only the values that need adjustment; the values below are examples only. When openAdvancedConfig=1, you must also submit the complete mappings object provided by the administrator; omitting this switch may disable the original advanced configuration.

{
  "data_type": "logging",
  "hotRetention": 24,
  "number_of_shards": 1,
  "number_of_replicas": 1,
  "rollover_max_size": 30,
  "openAdvancedConfig": 0
}

Request Example

import hashlib
import hmac
import json
import time
import uuid
from urllib.parse import urlencode
from urllib.request import Request, urlopen
from urllib.error import HTTPError, URLError

# This example applies only to workspaces where datastore.logging=doris has been confirmed.
# For ES, read and submit the complete target template first; do not directly copy only the hot storage parameters.
# Replace with the target site address and the External API AK/SK assigned by the administrator.
server = "https://external-api.guance.com"
access_key = "<external-access-key>"
secret_key = "<external-secret-key>"
method = 'POST'
path = '/api/v1/workspace/wksp_example001/update_index_setting'
query = {}
data = {'data_type': 'logging', 'hotRetention': 24}
full_path = path + ("?" + urlencode(query) if query else "")
body = "" if data is None else json.dumps(data, ensure_ascii=False, separators=(",", ":"))
timestamp = str(int(time.time()))
nonce = uuid.uuid4().hex
string_to_sign = " ".join([method, nonce, full_path, timestamp, body])
signature = hmac.new(secret_key.encode("utf-8"), string_to_sign.encode("utf-8"), hashlib.sha256).hexdigest()
headers = {
    "X-Df-Access-Key": access_key,
    "X-Df-Timestamp": timestamp,
    "X-Df-Nonce": nonce,
    "X-Df-Signature": signature,
    "X-Df-SVersion": "v20240417",
}
if data is not None:
    headers["Content-Type"] = "application/json"
request = Request(server + full_path, data=None if data is None else body.encode("utf-8"), headers=headers, method=method)
try:
    with urlopen(request, timeout=30) as result:
        payload = json.loads(result.read().decode("utf-8"))
except HTTPError as error:
    print("HTTP", error.code, error.read().decode("utf-8"))  # Keep errorCode, content, and traceId to determine whether the request has been committed.
    raise SystemExit(1)
except (URLError, TimeoutError):
    print("The request result is unknown. Query the target workspace configuration and task status first, and do not automatically retry the write request.")
    raise SystemExit(1)
print(json.dumps(payload, ensure_ascii=False, indent=2))

Response

HTTP 200 with a unified application/json envelope; External does not automatically inject a declaration. On success, content=true and no template details are returned; query the index template again to verify the actual values.

Field Type Description
content boolean true on success; this is not a list of updated fields. When hotRetention is missing, some template fields may be ignored; do not rely solely on true to determine that every item has been applied.
{
  "code": 200,
  "content": true,
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

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

The table below lists the business validation and confirmed main error branches for this API. Downstream services may also return other 4xx errors mapped from specific errors; ordinary 5xx and unknown exceptions are returned as ft.InternalServerError through global handling. For write requests, determine whether they have taken effect based on the current configuration and the error content; do not infer rollback solely from the HTTP status.

HTTP Status errorCode Trigger Condition Message or Response Description Handling Method
406 ft.ParameterValidationFailed A request field is missing, or a field value violates the declared validation conditions Parameter parsing failed Verify the parameter location, field name, type, and value.
400 ft.RequestJsonFormatError Invalid request JSON syntax Request JSON format error Correct the JSON according to content.reason, line, and column.
400 ft.JsonFormatError The JSON top level is not an object Some json file format error Submit a JSON object according to the parameter table; do not use an array or null as the entire request body.
406 ft.NotFoundWorkspace The workspace does not exist, has been deleted, or does not meet the current active status query Specified workspace not found Obtain a valid UUID again from the Workspace List and verify the status.
429 ft.OperationTooFrequently The storage configuration lock for the same workspace is occupied, or lock ownership has been lost during execution Your operation is too frequent. Please try again later. Later, read the current configuration first, then retry with a new nonce and signature; if the lock is lost during execution, you cannot conclude that none of the writes occurred.
400 ft.InvalidAction Although data_type is in the declared enum, it is not in the set supported by the current merged/split mode Invalid operation First view the index template and use a type actually supported by the workspace.
404 ft.NamespaceDatastoreNotFound The current data type has no valid storage engine configuration Storage type for {} not found First confirm from the index template that the type exists in datastore; if the configuration is missing, ask the administrator to handle it.
404 ft.ForbiddenIndexCfg The target type uses SLS or Beaver, which does not support index configuration through this API Index configuration for sls/beaver storage types is not supported Use the official configuration capability of the corresponding storage service, or have the site administrator adjust it.
404 ft.ForbiddenAdvancedCfg The Doris or VolcTLS request contains openAdvancedConfig Advanced configuration is not supported for storage type {} Remove this field and mappings, and configure according to the engine's supported capabilities.
404 ft.ForbiddenShardReplicasCfg The Doris or VolcTLS request contains shard/replica/rollover threshold fields Shard/replica configuration is not supported for storage type {} Remove number_of_shards, number_of_replicas, and rollover_max_size.
406 ft.InvalidParameter hotRetention is negative Parameter {} is invalid Provide a non-negative value in hours supported by the engine; VolcTLS must use a positive number of hours equal to whole days.
404 ft.LogIndexCfgNoExists The cfg_uuid used for retention period or hot storage updates does not belong to the current workspace or has been deleted The specified log index configuration does not exist Obtain the custom log index UUID again from the current workspace's index template list.
404 ft.MissingVolctlsHotRetention The VolcTLS request does not provide a valid hotRetention Volcengine storage: standard storage (hot storage) field is missing Provide a positive integer number of hot storage hours.
400 ft.InvalidHotRetention VolcTLS hot storage is not an integer multiple of 24 Volcengine storage: invalid hot data storage duration; it must be a number of hours equal to whole days Multiply the number of hot storage days by 24 and provide the hours for complete days.
400 ft.InvalidRetentionFullDayhours VolcTLS cold storage or archive is not an integer multiple of 24 Volcengine storage: invalid {} storage duration; it must be a number of hours equal to whole days Multiply the corresponding number of days by 24 before submitting.
400 ft.InvalidRetention A VolcTLS tier duration exceeds the range allowed by the site Volcengine storage: invalid {} storage duration; range is {} days Adjust according to the respective hot/cold/archive ranges.
400 ft.InvalidColdRententionHot VolcTLS cold storage is configured, but hot storage is less than the site minimum requirement When low-frequency storage exists in the storage engine, standard storage must be greater than or equal to {} days By default, hot storage must be at least 7 days; adjust according to actual site requirements.
400 ft.InvalidArchiveRententionHot VolcTLS archive storage is configured, but hot storage is less than the site minimum requirement When archive storage exists in the storage engine, standard storage must be greater than or equal to {} days By default, hot storage must be at least 30 days; adjust according to actual site requirements.
400 ft.InvalidAllRetention The total duration of all VolcTLS tiers exceeds the site range Volcengine storage: invalid total storage duration; range is {} days By default, the total duration must not exceed 1800 days; adjust the combination of tiers.
400 ft.FreeWKSPLimit The Free Plan/free edition attempts to change the standard retention period or long-term storage policy Invalid operation; the current workspace is on the Free Plan Keep the original values or handle it through the official upgrade process.
406 ft.InvalidDuration The format or allowed value of the standard or long-term retention period is invalid Invalid duration Use an allowed value for this version in the format of a number followed by d.
406 ft.InvalidDurationRange The standard retention period is out of range, or the long-term retention period is not greater than the standard value Exceeds the valid data retention duration range Adjust according to the actual version range.
400 ft.InvalidActionForbiddenChange The log long-term storage engine or version is not supported Returns the reason long-term storage is not supported according to the specific branch Enable it only in scopedb log workspaces on allowed versions.
406 ft.CurrentVersionUnsupportRp The version does not support retention period editing The current version does not support rp:{} Ask the administrator to confirm the workspace version.
500 ft.InternalServerError A database, cache, resource service, or unhandled parameter conversion exception, or the downstream response to the index template update does not contain a success flag Internal error First read back the index template and actual storage settings. After confirming which configurations have taken effect, handle only the failed parts to avoid repeatedly overwriting the complete template. Keep the traceId and contact the administrator.

Feedback

Is this page helpful?