Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Object Storage
    • All tutorials
    • Getting statistics on object queries with S3 Select
    • Getting website traffic statistics with S3 Select
    • Getting statistics on object queries using Yandex Query
    • Generating a resource-by-resource cost breakdown report using S3 Select
    • Server-side encryption
    • Integrating an L7 load balancer with CDN and Object Storage
    • Blue-green and canary deployment of service versions
    • Analyzing logs in DataLens
      • Overview
      • Tools for working with audit logs
      • Sample requests for searching events
      • Configuring Yandex Query
    • Mounting buckets to the file system of Yandex Data Processing hosts
    • Using Object Storage in Yandex Data Processing
    • Importing data from Object Storage, processing and exporting to Managed Service for ClickHouse®
    • Mounting a bucket as a disk in Windows
    • Migrating data from Yandex Data Streams using Yandex Data Transfer
    • Using hybrid storage in Yandex Managed Service for ClickHouse®
    • Loading data from Yandex Managed Service for OpenSearch to Yandex Object Storage using Yandex Data Transfer
    • Automatically copying objects from one bucket to another
    • Recognizing audio files in a bucket on a regular basis
    • Training a model in Yandex DataSphere on data from Object Storage
    • Connecting to Object Storage from VPC
    • Migrating data to Yandex Managed Service for PostgreSQL using Yandex Data Transfer
    • Uploading data to Yandex Managed Service for Greenplum® using Yandex Data Transfer
    • Uploading data to Yandex Managed Service for ClickHouse® using Yandex Data Transfer
    • Uploading data to Yandex Managed Service for YDB using Yandex Data Transfer
    • Exchanging data between Yandex Managed Service for ClickHouse® and Yandex Data Processing
    • Uploading data from Yandex Managed Service for YDB using Yandex Data Transfer
    • Hosting a static Gatsby website in Object Storage
    • Migrating a database from Managed Service for PostgreSQL to Object Storage
    • Exchanging data between Yandex Managed Service for ClickHouse® and Yandex Data Processing
    • Importing data from Yandex Managed Service for PostgreSQL to Yandex Data Processing using Sqoop
    • Importing data from Yandex Managed Service for MySQL® to Yandex Data Processing using Sqoop
    • Migrating data from Yandex Object Storage to Yandex Managed Service for MySQL® using Yandex Data Transfer
    • Migrating a database from Yandex Managed Service for MySQL® to Yandex Object Storage
    • Exporting Greenplum® data to a cold storage in Yandex Object Storage
    • Loading data from Yandex Direct to a Yandex Managed Service for ClickHouse® data mart using Yandex Cloud Functions, Yandex Object Storage, and Yandex Data Transfer
    • Migrating data from Elasticsearch to Yandex Managed Service for OpenSearch
    • Uploading Terraform states to Object Storage
    • Locking Terraform states using Managed Service for YDB
    • Visualizing Yandex Query data
    • Publishing game updates
    • VM backups using Hystax Acura
    • Backing up to Object Storage with CloudBerry Desktop Backup
    • Backing up to Object Storage with Duplicati
    • Backing up to Object Storage with Bacula
    • Backing up to Yandex Object Storage with Veeam Backup
    • Backing up to Object Storage with Veritas Backup Exec
    • Managed Service for Kubernetes cluster backups in Object Storage
    • Developing a custom integration in API Gateway
    • URL shortener
    • Storing application runtime logs
    • Developing a skill for Alice and a website with authorization
    • Creating an interactive serverless application using WebSocket
    • Deploying a web application using the Java Servlet API
    • Developing a Telegram bot
    • Replicating logs to Object Storage using Fluent Bit
    • Replicating logs to Object Storage using Data Streams
    • Uploading audit logs to ArcSight SIEM
    • Exporting audit logs to SIEM Splunk systems
    • Creating an MLFlow server for logging experiments and artifacts
    • Operations with data using Yandex Query
    • Federated data queries using Query
    • Recognizing text in image archives using Vision OCR
    • Converting a video to a GIF in Python
    • Automating tasks using Managed Service for Apache Airflow™
    • Processing files with usage details in Yandex Cloud Billing
    • Deploying a web app with JWT authorization in API Gateway and authentication in Firebase
    • Searching for Yandex Cloud events in Yandex Query
    • Searching for Yandex Cloud events in Object Storage
    • Creating an external table from a bucket table using a configuration file
    • Migrating databases from Google BigQuery to Managed Service for ClickHouse®
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Bucket logs
  • Release notes
  • FAQ

In this article:

  • Getting started
  • Required paid resources
  • Set up your environment
  • Create a bucket for audit logs
  • Create service accounts
  • Assign permissions to service accounts
  • Create a trail
  • Create a connection between a trail and YQ
  • Execute a query to logs in Object Storage
  • How to delete the resources you created
  1. Tutorials
  2. Event search in audit logs
  3. Configuring Yandex Query

Configuring Yandex Query

Written by
Yandex Cloud
Updated at May 7, 2025
  • Getting started
  • Required paid resources
  • Set up your environment
    • Create a bucket for audit logs
    • Create service accounts
    • Assign permissions to service accounts
  • Create a trail
  • Create a connection between a trail and YQ
  • Execute a query to logs in Object Storage
  • How to delete the resources you created

Audit Trails support is integrated in Yandex Query. You can analyze events of Yandex Cloud resources by executing analytical and streaming YQL queries.

You can execute analytical queries for logs stored in a bucket and streaming queries for logs stored in a Yandex Data Streams data stream.

To connect a bucket with audit logs to Yandex Query and execute YQL queries:

  1. Set up your environment.
  2. Create a connection between a trail and YQ.
  3. Execute a query to logs in Object Storage.

If you no longer need the resources you created, delete them.

Getting startedGetting started

Sign up in Yandex Cloud and create a billing account:

  1. Navigate to the management console and log in to Yandex Cloud or register a new account.
  2. On the Yandex Cloud Billing page, make sure you have a billing account linked and it has the ACTIVE or TRIAL_ACTIVE status. If you do not have a billing account, create one and link a cloud to it.

If you have an active billing account, you can navigate to the cloud page to create or select a folder for your infrastructure to operate in.

Learn more about clouds and folders.

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

Required paid resourcesRequired paid resources

The cost of infrastructure support includes a fee for a bucket (see Pricing for Object Storage).

Set up your environmentSet up your environment

Create a bucket for audit logsCreate a bucket for audit logs

Management console
  1. In the management console, select the folder where you want to create a bucket, e.g., example-folder.
  2. Select Object Storage.
  3. Click Create bucket.
  4. On the bucket creation page:
    • Enter a name for the bucket according to the naming requirements.
    • In the Object read access, Object listing access, and Read access to settings fields, select Restricted.
    • Leave other parameters at their defaults.
  5. Click Create bucket.

Create service accountsCreate service accounts

Create the trail-sa service account:

Management console
  1. In the management console, navigate to example-folder.
  2. From the list of services, select Identity and Access Management.
  3. Click Create service account.
  4. Specify Name: trail-sa.
  5. Click Create.

Similarly, create a service account named bucket-yq-sa.

Assign permissions to service accountsAssign permissions to service accounts

Assign the audit-trails.viewer and storage.uploader roles to the trail-sa service account:

CLI
  1. The audit-trails.viewer role for an organization:

    yc organization-manager organization add-access-binding \
    --role audit-trails.viewer \
    --id <organization_ID> \
    --service-account-id <service_account_ID>
    

    Where --service-account-id is the trail-sa service account ID.

    Result:

    done (1s)
    

    For more information about the yc organization-manager organization add-access-binding command, see the CLI reference.

  2. The storage.uploader role for a folder:

    yc resource-manager folder add-access-binding example-folder \
      --role storage.uploader \
      --subject serviceAccount:<service_account_ID>
    

    Where --subject is the trail-sa service account ID.

    Result:

    done (1s)
    

    For more information about the yc resource-manager folder add-access-binding command, see the CLI reference.

Assign the bucket-yq-sa service account the storage.viewer role for example-folder:

CLI
yc resource-manager folder add-access-binding example-folder \
    --role storage.viewer \
    --subject serviceAccount:<service_account_ID>

Where --subject is the bucket-yq-sa service account ID.

Result:

done (1s)

For more information about the yc resource-manager folder add-access-binding command, see the CLI reference.

Create a trailCreate a trail

Management console
  1. In the management console, select example-folder.

  2. Select Audit Trails.

  3. Click Create trail.

  4. In the Name field, specify logsyq.

  5. Under Destination, configure the destination object:

    • Destination: Object Storage.
    • Bucket: Select the bucket you created earlier.
  6. Under Service account, select trail-sa.

  7. Under Collecting management events, configure the collection of management event audit logs:

    • Collecting events: Select Enabled.
    • Resource: Select Organization.
    • Organization: Automatically populated field containing the name of the current organization.
    • Cloud: Keep the default value, All.
  8. Under Collecting data events, select Disabled in the Collecting events field.

  9. Click Create.

Create a connection between a trail and YQCreate a connection between a trail and YQ

A connection must be created only the first time a trail is connected to YQ.

Management console
  1. In the management console, select example-folder.
  2. Select Audit Trails.
  3. Select the logsyq trail.
  4. Click Process in YQ.
  5. Create a connection.
    • Select the bucket-yq-sa Service account.
    • Leave other parameters at their defaults.
  6. Click Create.
  7. In the window with data binding options, click Create.

You will go to the page for creating a query to trail logs.

Execute a query to logs in Object StorageExecute a query to logs in Object Storage

Open the page to create an analytical query to Audit Trails logs:

Management console
  1. In the management console, select a folder with a trail.
  2. From the list of services, select Audit Trails.
  3. Select the trail for which a connection to YQ is configured.
  4. Click Process in YQ to go to the analytical query execution page.

Run event queries to bind audit-trails-logsyq-object_storage:

  1. Deleting a folder:

    1. Select this query from the list: 1. Find out who deleted the folder.

    2. Edit the query by specifying the folder ID:

      SELECT * FROM bindings.`audit-trails-logsyq-object_storage`
      WHERE
          JSON_VALUE(data, "$.event_type") = 'yandex.cloud.audit.resourcemanager.DeleteFolder' 
          and JSON_VALUE(data, "$.details.folder_name") = '<folder_ID>' 
          LIMIT 100;
      
    3. Click Execute.

  2. Enabling access via the serial console:

    1. Select this query from the list: 6. Changing a VM: Adding serial console access.

    2. Edit the query by specifying the number of displayed records:

      SELECT * FROM bindings.`<audit-trails-logsyq-object_storage>`
      WHERE
          JSON_VALUE(data, "$.event_type") = 'yandex.cloud.audit.compute.UpdateInstance' 
          and JSON_VALUE(data, "$.details.metadata_serial_port_enable") = '1' 
          LIMIT <number_of_records>;
      
    3. Click Execute.

  3. Changing access permissions for an Object Storage bucket:

    1. Select this query from the list: 11. Suspicious activity with the Audit Trails log repository (Object Storage bucket).

    2. Edit the query by specifying the number of displayed records:

      SELECT * FROM bindings.`audit-trails-logsyq-object_storage`
      WHERE
          (JSON_VALUE(data, "$.event_type") = 'yandex.cloud.audit.storage.BucketAclUpdate' 
          or JSON_VALUE(data, "$.event_type") = 'yandex.cloud.audit.storage.BucketPolicyUpdate') 
          LIMIT <number_of_records>;
      
    3. Click Execute.

  4. Assigning administrator permissions:

    1. Select this query from the list: 20. Assigning admin permissions (for a folder and cloud).

    2. Edit the query by specifying the number of displayed records:

      SELECT * FROM bindings.`audit-trails-logsyq-object_storage`
      WHERE
          JSON_VALUE(data, "$.details.access_binding_deltas.access_binding.role_id") = 'admin' 
          LIMIT <number_of_records>;
      
    3. Click Execute.

How to delete the resources you createdHow to delete the resources you created

If you created a separate bucket to follow these instructions, you can delete it to stop paying for bucket use.

Was the article helpful?

Previous
Sample requests for searching events
Next
Mounting buckets to the file system of Yandex Data Processing hosts
Yandex project
© 2025 Yandex.Cloud LLC