Updating the record retention period
- In the management console, select the folder containing your log group.
- Select Cloud Logging.
- In the line with the log group, click .
- In the menu that opens, click Edit.
- Update the log group record retention period. The maximum record retention period is 3 days, and the minimum is 1 hour.
- Click Save.
If you don't have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To access a log group, use its name or unique ID. To find them, get a list of log groups in the folder.
Note
The record retention period can only be specified in hours, minutes, or seconds. For example, 1h
or 1440m
.
To update the period for retaining records in a log group, run the command:
yc logging group update --name=default --retention-period=24h
Where:
--name
: Name of the log group whose record retention period you want to update.--retention-period
: New record retention period.
Result:
id: af3mu6hnd0**********
folder_id: aoek6qrs8t**********
cloud_id: aoegtvhtp8**********
created_at: "2021-06-22T09:51:43.614Z"
name: default
status: ACTIVE
retention_period: 86400s
You can edit a log group's record retention period using the API update method.
For more information about Terraform, see the documentation.
To edit the record retention time in a log group created with Terraform:
-
Open the Terraform configuration file and edit the value of the
retention_period
parameter in the log group description:... resource "yandex_logging_group" "group1" { name = "test-logging-group" folder_id = "<folder ID>" retention_period = "5h" } ...
Where:
name
: Name of the log group. Optional.folder_id
: ID of the folder. Optional. By default, the value specified in the provider settings is used.retention_period
: Record retention period in the log group. Optional. The maximum record retention period is 3 days, the minimum is 1 hour. By default, the retention period is 3 days.
For more detailed information about the parameters of the
yandex_logging_group
resource in Terraform, see the provider documentation. -
Check the configuration using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If there are errors in the configuration, Terraform points them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
into the terminal and press Enter.You can verify that the log group has been updated in the management console or using the following CLI command:
yc logging group get <log group name>