Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Yandex SIEM
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Audit Trails
  • Getting started
    • All guides
    • Creating a trail
    • Managing a trail
    • Drafting a trail specification
    • Handling errors
    • Viewing operations with service resources
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Management event reference
  • Data event reference
  • Release notes

In this article:

  • Updating a trail
  • Deleting a trail
  1. Step-by-step guides
  2. Managing a trail

Managing a trail

Written by
Yandex Cloud
View in Markdown
  • Updating a trail
  • Deleting a trail

You can update the destination object, event levels, audit log collection scopes, and other trail settings or delete the trail.

Updating a trailUpdating a trail

You can add conditions based on field values to data event filters using the CLI, Terraform, or API. When updating your filter policy, provide it fully with the other relevant filters preserved.

Management console
CLI
Terraform
API

To update a trail:

  1. In the management console, select the folder containing the trail.
  2. Navigate to Audit Trails.
  3. In the row with the trail, click and select Edit.
  4. Edit the trail settings. For a list of editable trail settings, see Trail settings.
  5. Click Save.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id.

If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

See the description of the CLI command for updating a trail:

yc audit-trails trail update --help

You can update a trail by specifying its parameters in one of these two ways:

In the YAML specification

Create a YAML specification containing the updated trail parameters and specify this file in the trail update command.

This method simplifies working with trail parameters and reduces error probability. In addition, you can only customize the registration of data events using the YAML specification.

  1. Draft the YAML specification based on the current trail settings and update the parameters as needed.

  2. Optionally, supplement the filter with conditions based on field values for the relevant service. Do it by setting the include_rules and exclude_rules rules in the filtering_policy.data_events_filters list item. For filter configuration examples, see Creating a trail.

  3. To update a trail, run this command:

    yc audit-trails trail update --file <file_path>
    
In command parameters

Use this method if your trail configuration is simple and contains few parameters.

Note

You can only customize the registration of data events using the YAML specification.

In the command, specify only the parameters you want to update. For example, to update the trail name, run this command:

yc audit-trails trail update \
  --name <trail_name> \
  --new-name <new_trail_name>

Command parameters:

  • --name: Name of the trail you need to update. Instead of a name, you can provide the trail ID in the --id parameter.
  • --new-name: New trail name. The name must be unique within the folder. This is an optional parameter.
  • --description: Trail description. This is an optional setting.

  • --labels: List of labels. This is an optional setting. You can specify one or more labels separated by commas in <key1>=<value1>,<key2>=<value2> format.

  • --service-account-id: Service account ID.

  • --destination-bucket: Name of the Yandex Object Storage bucket you want to upload audit logs to.

    You cannot use this parameter together with --destination-log-group-id or --destination-yds-stream.

  • --destination-bucket-object-prefix: Prefix that will be assigned to the objects with audit logs in the bucket. It is an optional parameter used in the full name of the audit log file.

    Note

    Use a prefix to store audit logs and third-party data in the same bucket. Do not use the same prefix for logs and other bucket objects because that may cause logs and third-party objects to overwrite each other.

  • --destination-log-group-id: ID of the Yandex Cloud Logging log group the audit logs will be uploaded to.

    You cannot use this parameter together with --destination-bucket or --destination-yds-stream.

  • --destination-yds-stream: Name of the Yandex Data Streams data stream the audit logs will be uploaded to.

    You cannot use this parameter together with --destination-bucket or --destination-log-group-id.

  • --destination-yds-database-id: ID of the YDB database used by Data Streams.

  • --destination-yds-codec: Event compression method when writing to Data Streams. The possible values are RAW (no compression, default), GZIP, ZSTD. Enable compression if you expect an event flow greater than 1 MB/s.

  • --filter-all-folder-id: Folder ID. The system will be logging management events for all resources in this folder.

  • --filter-all-cloud-id: Cloud ID. The system will be logging management events for all resources in this cloud.

  • --filter-all-organisation-id: Organization ID. The system will be logging management events for all resources in this organization.

  • --filter-some-folder-ids: List of folder IDs. The system will be logging management events for all resources in those folders, in the cloud specified in --filter-from-cloud-id.

    This parameter can only be used together with --filter-from-cloud-id.

  • --filter-from-cloud-id: ID of the cloud housing the folders specified in the --filter-some-folder-ids parameter.

    This parameter can only be used together with --filter-some-folder-ids.

  • --filter-some-cloud-ids: List of cloud IDs. The system will be logging management events for all resources in those clouds, in the organization specified in --filter-from-organisation-id.

    This parameter can only be used together with --filter-from-organisation-id.

  • --filter-from-organisation-id: ID of the organization housing the clouds specified under --filter-some-cloud-ids.

    This parameter can only be used together with --filter-some-cloud-ids.

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the guides on the Terraform website or its mirror.

If you do not have Terraform yet, install it and configure the Yandex Cloud provider.

To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), authenticate using the appropriate method.

  1. To update a trail created with Terraform, open the Terraform configuration file and update the trail description fragment:

    resource "yandex_audit_trails_trail" "basic_trail" {
      name        = "<trail_name>"
      folder_id   = "<folder_ID>"
      description = "<trail_description>"
      labels = {
        key = "value"
      }
      service_account_id = "<service_account_ID>"
    
      storage_destination {
        bucket_name   = "<bucket_name>"
        object_prefix = "<prefix>"
      }
    
      filtering_policy {
        management_events_filter {
          resource_scope {
            resource_id   = "<cloud_or_folder_organization_ID>"
            resource_type = "<type>"
          }
        }
    
        data_events_filter {
          service         = "<service_name>"
          included_events = ["<full_event_name>"]
    
          resource_scope {
            resource_id   = "<cloud_or_folder_organization_ID>"
            resource_type = "<type>"
          }
        }
      }
    }
    

    Where:

    • name: Name of the new trail. The naming requirements are as follows:

      • Length: between 3 and 63 characters.
      • It can only contain lowercase Latin letters, numbers, and hyphens.
      • It must start with a letter and cannot end with a hyphen.
    • folder_id: ID of the folder to create the trail in.

    • description: Trail description. This is an optional parameter.

    • labels: List of labels in key=value format. This is an optional parameter.

    • service_account_id: ID of the service account the trail uses to collect and upload audit logs.

      Based on the audit log collection scope, the service account must have the audit-trails.viewer role for the organization, cloud, or folder whose audit logs the trail will be collecting.

    Specify only one destination: storage_destination, logging_destination, or data_stream_destination.

    • logging_destination: Uploading logs to a Yandex Cloud Logging group.

      Replace the storage_destination section in the template:

      logging_destination {
        log_group_id = "<log_group_ID>"
      }
      
      • log_group_id: ID of the log group for the trail to save audit logs to.
    • storage_destination: Uploading logs to a Yandex Object Storage bucket:

      • log_group_id: Name of the bucket for the trail to save audit logs to.

      • object_prefix: Prefix that will be assigned to the objects with audit logs in the bucket. It is an optional parameter used in the full name of the audit log file.

        Note

        Use a prefix to store audit logs and third-party data in the same bucket. Do not use the same prefix for logs and other bucket objects because that may cause logs and third-party objects to overwrite each other.

    • data_stream_destination: Uploading logs to a data stream in Yandex Data Streams:

      Replace the storage_destination section in the template:

      data_stream_destination {
        database_id = "<database_ID>"
        stream_name = "<data_stream_name>"
        codec       = "RAW"
      }
      
      • stream_name: Name of the data stream for the trail to save audit logs to.
      • database_id: ID of the Yandex Managed Service for YDB database used by Data Streams.
      • codec: Event compression method when writing to Data Streams. The possible values are RAW (no compression, default), GZIP, and ZSTD. Enable compression if you expect an event flow greater than 1 MB/s.
    • filtering_policy: Settings of the filtering policy that determines which events to collect and include in the audit logs. The policy consists of filters pertaining to different levels of events. It contains the management_events_filter and data_events_filter sections.

      • management_events_filter: Management event filter.

        • resource_scope: Log collection scope. You can specify multiple resource_scope sections for scopes belonging to the same organization. For example, you can collect logs from one entire cloud and only from particular folders in another cloud. Service account permissions must allow collecting logs from the specified scopes.

          • resource_id: ID of the collection scope (organization, cloud, or folder).

          • resource_type: Scope type according to the specified ID:

            • organization-manager.organization: Organization.
            • resource-manager.cloud: Cloud.
            • resource-manager.folder: Folder.
      • data_events_filter: Data event filter. You can configure several filters of this type, one filter per service. A filter for one service has the following structure:

        • service: Name of the service in which the trail will process events. You can get it from the data event reference.

        • resource_scope: Places to collect data events from. You can configure this section the same way as the management event filter.

        • included_events: Full names of events to collect. You can replace it with excluded_events (full names of events to exclude). These parameters are mutually exclusive. If both are not set, selection is not limited to event names.

          Use the full name from the event_type field of the audit log. For example, yandex.cloud.audit.iam.CreateIamToken corresponds to the CreateIamToken event from the reference.

        • include_rule and exclude_rule: Optional rules with conditions based on field values. These apply together with event selection by names.

    For more on the properties of the yandex_audit_trails_trail resource, see this provider guide.

  2. Optionally, supplement the filter with conditions based on field values for the relevant service. To do this, under filtering_policy.data_events_filter, set the include_rule and exclude_rule. Use the Yandex Cloud provider version 0.225.0 or higher. For filter configuration examples, see Creating a trail.

  3. Apply the changes:

    1. In the terminal, navigate to the configuration file directory.

    2. Make sure the configuration is correct using this command:

      terraform validate
      

      If the configuration is valid, you will get this message:

      Success! The configuration is valid.
      
    3. Run this command:

      terraform plan
      

      You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.

    4. Apply the configuration changes:

      terraform apply
      
    5. Type yes and press Enter to confirm the changes.

    Check the trail settings using the management console or this CLI command:

    yc audit-trails trail get <trail_name>
    
  1. Get authenticated in the API and use the get REST API method or the TrailService/Get gRPC API call to get the trail settings.

  2. Update the trail parameters as needed.

  3. Optionally, supplement the filter with conditions based on field values for the relevant service. Do it by setting the includeRules and excludeRules rules in the filteringPolicy.dataEventsFilters list item in the REST API request. In the gRPC API, use include_rules and exclude_rules in filtering_policy.data_events_filters. For a filter configuration example, see Creating a trail.

  4. Use the update REST API method for the Trail resource or the TrailService/Update gRPC API call to update the trail. Provide the trail ID, updated parameters, and update mask.

    If updating the filtering policy, enable filteringPolicy in updateMask for the REST API or filtering_policy in update_mask.paths for the gRPC API.

Examples of filters from the guide on creating a trail can also be used to update a trail.

Deleting a trailDeleting a trail

Management console
CLI
Terraform
API

To delete a trail:

  1. In the management console, select the folder containing the trail.
  2. Navigate to Audit Trails.
  3. In the row with the trail, click and select Delete.
  4. In the window that opens, confirm the deletion.

To delete a trail, run this command:

yc audit-trails trail delete <trail_name_or_ID>

To find out the names and IDs of available trails, use this tutorial.

To delete a trail created using Terraform:

  1. Open the Terraform configuration file and delete the trail description section.

    Example of a trail description in a Terraform configuration:

    resource "yandex_audit_trails_trail" "basic_trail" {
      name        = "<trail_name>"
      folder_id   = "<folder_ID>"
      description = "<trail_description>"
      labels = {
        key = "value"
      }
      service_account_id = "<service_account_ID>"
    
      storage_destination {
        bucket_name   = "<bucket_name>"
        object_prefix = "<prefix>"
      }
    
      filtering_policy {
        management_events_filter {
          resource_scope {
            resource_id   = "<cloud_or_folder_organization_ID>"
            resource_type = "<type>"
          }
        }
    
        data_events_filter {
          service         = "<service_name>"
          included_events = ["<full_event_name>"]
    
          resource_scope {
            resource_id   = "<cloud_or_folder_organization_ID>"
            resource_type = "<type>"
          }
        }
      }
    }
    
  2. In the command line, navigate to the directory with the Terraform configuration file.

  3. Check the configuration using this command:

    terraform validate
    

    If the configuration is valid, you will get this message:

    Success! The configuration is valid.
    
  4. Run this command:

    terraform plan
    

    You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors detected in the configuration.

  5. Apply the configuration changes:

    terraform apply
    
  6. Type yes and press Enter to confirm the changes.

  7. To make sure the trail has been deleted, use this tutorial.

To delete a trail, use the delete REST API method for the Trail resource or the TrailService/Delete gRPC API call.

Was the article helpful?

Previous
Creating a trail
Next
Drafting a trail specification
© 2026 Direct Cursus Technology L.L.C.