Updates the configuration of a Logstore, including data retention, storage tiers, sharding, and tracking settings.
Prerequisites
Before you begin, make sure that you have:
Activated Simple Log Service (SLS)
Installed and configured the SLS CLI
Syntax
aliyunlog log update_logstore \
--project_name=<value> \
--logstore_name=<value> \
[--ttl=<value>] \
[--enable_tracking=<value>] \
[--shard_count=<value>] \
[--append_meta=<value>] \
[--auto_split=<value>] \
[--max_split_shard=<value>] \
[--preserve_storage=<value>] \
[--encrypt_conf=<value>] \
[--hot_ttl=<value>] \
[--mode=<value>] \
[--telemetry_type=<value>] \
[--infrequent_access_ttl=<value>]For global parameters such as --access-id, --access-key, --region-endpoint, and --format-output, see Global parameters.
Parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
--project_name | String | Yes | aliyun-test-project | The name of the project. Projects isolate resources and control access. For more information, see Manage projects. |
--logstore_name | String | Yes | logstore-a | The name of the Logstore. The name is immutable after creation and must be unique within the project. Naming rules: lowercase letters, digits, hyphens (-), and underscores (_); must start with a lowercase letter and end with a lowercase letter or digit; 3 to 63 characters. |
--ttl | Integer | No | 30 | Total data retention period in days. Valid values: 1 to 3650. Set to 3650 for permanent storage. When the retention period elapses, SLS deletes the expired data. The value of --ttl equals the sum of --hot_ttl, --infrequent_access_ttl, and the Archive storage retention period. |
--shard_count | Integer | No | 2 | The number of shards. This parameter is accepted by the CLI but silently ignored. To adjust the number of shards, use SplitShard or MergeShard. For more information, see Shard range. |
--enable_tracking | Boolean | No | true | Enable (true) or disable (false) WebTracking. |
--append_meta | Boolean | No | false | Record (true) or skip (false) the public IP addresses of clients. |
--auto_split | Boolean | No | true | Enable (true) or disable (false) automatic shard splitting. |
--max_split_shard | Integer | No | 64 | Maximum number of shards that automatic splitting can create. Valid values: 1 to 256. Required when --auto_split is true. |
--encrypt_conf | String | No | -- | Encryption configuration as a JSON string. For the data structure, see EncryptConf. |
--telemetry_type | String | No | None | The type of observable data stored in the Logstore. None (default): logs. Metrics: time-series data. |
--hot_ttl | Integer | No | 7 | Retention period for the hot storage tier in days. Minimum: 7. Maximum: the value of --ttl. Set to -1 to keep all data in hot storage. After this period, data moves to the Infrequent Access (IA) tier. Storage tier transition rules: hot to IA requires at least 7 days in hot storage; IA to Archive requires at least 30 days in IA; hot to Archive (skipping IA) requires at least 30 days in hot storage. For more information, see Configure intelligent tiered storage. |
--mode | String | No | standard | The Logstore type. standard (default): Standard Logstore. Supports log analysis, real-time monitoring, and interactive analysis. You can use this type of Logstore to build a comprehensive observability system. query (CLI value: lite): Query Logstore. Optimized for high-performance queries at roughly half the index traffic cost. Does not support SELECT statements. Best for large datasets with long retention periods, or when log analysis is not required. For more information, see Manage a Logstore. |
--infrequent_access_ttl | Integer | No | 30 | Retention period for the IA tier in days. Data must remain in the IA tier for at least 30 days before it can move to the Archive storage tier. For more information, see Configure intelligent tiered storage. |
When you lower the --ttl value, SLS deletes all newly expired data within 1 hour. For example, changing retention from 5 days to 1 day causes SLS to delete the previous 4 days of log data within 1 hour. The storage usage shown on the Usage Details page of the SLS console updates the next day.
The shard count cannot be modified through update_logstore. The CLI accepts the --shard_count parameter without error, but the value is silently ignored. To adjust the number of shards, use SplitShard or MergeShard.
Examples
Set the data retention period to 30 days and enable web tracking for the logstore-a Logstore in the aliyun-test-project project:
aliyunlog log update_logstore \
--project_name="aliyun-test-project" \
--logstore_name="logstore-a" \
--ttl=30 \
--enable_tracking=trueA successful command returns no output. Run the following command to verify the update:
aliyunlog log get_logstore \
--project_name="aliyun-test-project" \
--logstore_name="logstore-a" \
--format-output=jsonCheck that the ttl and enable_tracking fields in the JSON output match the values you set.
References
Error codes -- troubleshoot failed API calls
UpdateLogStore API -- the underlying REST API for this command
Manage a Logstore by using Java SDK and Manage a Logstore by using Python SDK -- SDK alternatives
Alibaba Cloud OpenAPI Explorer for SLS -- common SDK integration