Updating a log group
- In the management console
, select the folder containing your log group. - Select Cloud Logging.
- Next to the log group, click
. - In the menu that opens, click Edit.
- Update the log group settings.
- Click Save.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To access a log group, use its name or unique ID. To find them out, get a list of log groups in the folder.
To update log group settings, such as the record retention period, run this 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 retention period for log group records.You can only set the record retention period in hours, minutes, or seconds, e.g.,
1hor1440m.
Result:
id: af3mu6hnd0**********
folder_id: aoek6qrs8t**********
cloud_id: aoegtvhtp8**********
created_at: "2023-06-22T09:51:43.614Z"
name: default
status: ACTIVE
retention_period: 86400s
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To update the settings of a log group created with Terraform:
-
Open the Terraform configuration file and edit the setting, such as the record retention period, in the log group description as needed:
... resource "yandex_logging_group" "group1" { name = "test-logging-group" folder_id = "<folder_ID>" retention_period = "5h" } ...Where:
-
name: Log group name. This is an optional parameter. -
folder_id: Folder ID. This is an optional parameter. It defaults to the value specified in the provider settings. -
retention_period: New retention period for log group records.You can only set the record retention period in hours, minutes, or seconds, e.g.,
1hor1440m.
For more information about
yandex_logging_groupproperties, see this Terraform provider guide. -
-
Check the configuration using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.You can check the log group update in the management console
or using this CLI command:yc logging group get <log_group_name>
To update a log group, use the update REST API method for the LogGroup resource or the LogGroupService/Update gRPC API call.
Request example
The example below uses grpcurl. To run this example, authenticate with the API and clone the cloudapi
In our example, we are updating the record retention period.
Create a file named payload.json:
{
"log_group_id": "<log_group_ID>",
"retention_period": "24h",
"update_mask": {
"paths": ["retention_period"]
}
}
Send this request:
grpcurl -rpc-header "Authorization: Bearer $(yc iam create-token)" \
-d @ \
-import-path ~/cloudapi/ \
-import-path ~/cloudapi/third_party/googleapis/ \
-proto ~/cloudapi/yandex/cloud/logging/v1/log_group_service.proto \
logging.api.cloud.yandex.net:443 yandex.cloud.logging.v1.LogGroupService.Update < payload.json
Response:
{
"id": "e23omac87b3a********",
"description": "Update log group",
"createdAt": "2023-03-25T05:39:24.058608338Z",
"createdBy": "ajego134p5h1********",
"modifiedAt": "2023-03-25T05:39:24.058608338Z",
"metadata": {
"@type": "type.googleapis.com/yandex.cloud.logging.v1.UpdateLogGroupMetadata",
"logGroupId": "e23ff0on5amv********"
}
}