Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
© 2022 Yandex.Cloud LLC
Yandex Cloud Logging
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Adding records
    • Reading records
    • Managing log groups
      • Creating a log group
      • Managing rights to access log groups
      • Updating the record retention period
      • Getting a list of log groups
      • Monitoring
      • Deleting a log group
  • Practical guidelines
    • All tutorials
    • Transmitting the Managed Service for Kubernetes cluster logs to Cloud Logging
    • Transferring logs from a VM instance to Cloud Logging
    • Transferring logs from COI to Cloud Logging
  • Concepts
    • Log group
    • Filter expression language
    • Quotas and limits
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • LogGroupService
      • LogIngestionService
      • LogReadingService
      • OperationService
    • REST
      • Overview
      • LogGroup
        • Overview
        • create
        • delete
        • get
        • list
        • listAccessBindings
        • listOperations
        • listResources
        • setAccessBindings
        • stats
        • update
        • updateAccessBindings
  • Questions and answers
  1. Step-by-step instructions
  2. Managing log groups
  3. Updating the record retention period

Updating the record retention period

Written by
Yandex Cloud
    Management console
    CLI
    API
    Terraform
    1. In the management console, select the folder containing your log group.
    2. Select Cloud Logging.
    3. In the line with the log group, click .
    4. In the menu that opens, click Edit.
    5. Update the log group record retention period. The maximum record retention period is 3 days, and the minimum is 1 hour.
    6. 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:

    1. 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.

    2. Check the configuration using the command:

      terraform validate
      

      If the configuration is correct, the following message is returned:

      Success! The configuration is valid.
      
    3. 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.

    4. Apply the configuration changes:

      terraform apply
      
    5. 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>
      

    Was the article helpful?

    Language / Region
    © 2022 Yandex.Cloud LLC