Tools for working with audit logs
You can upload audit logs to a Yandex Object Storage bucket, Yandex Cloud Logging log group, or data stream in Yandex Data Streams.
Depending on the log location, you need to use different tools to view them and search for events:
Yandex Query
Use Query to work with logs uploaded to a bucket or a data stream:
- If logs reside in a bucket, you can use analytical YQL queries to analyze Yandex Cloud resource events.
- If logs reside in a data stream, use streaming YQL queries to analyze Yandex Cloud resource events.
To use Yandex Query, set up a data binding based on the target object:
-
Create a service account named
bucket-yq-sa. -
Assign the
bucket-yq-saservice account thestorage.viewerrole for the folder containing the bucket with logs. -
Create a connection:
- In the management console
, select the folder containing the trail that delivers logs to the bucket. - Select Audit Trails.
- Select the trail that delivers logs to the bucket.
- Click Process in YQ.
- Select
bucket-yq-saService account. - Leave other parameters at their defaults.
- Click Create.
- In the management console
-
In the window with data binding options, click Create.
-
Run the appropriate query.
- Create a service account named
bucket-yq-sa. - Assign the
yds.editorrole to thebucket-yq-saservice account. - Create a connection. Make sure to specify the settings for the Data Streams connection type.
- Create a binding.
- Run the appropriate query.
Cloud Logging
Use Cloud Logging to work with logs uploaded to a log group.
You can filter logs using the filter expression language to analyze Yandex Cloud resource events.
To use Cloud Logging:
- Read logs in the log group.
- Filter the logs as needed.
jq
Use jq
Buckets store logs as JSON files. This means you can analyze Yandex Cloud resource events by retrieving the events you need from the files using jq filters
To use jq:
-
Install and set up s3fs or goofys to mount Object Storage buckets using FUSE
. -
Mount a bucket with audit logs to your file system using s3fs or goofys.
-
Install jq
. -
Run the command with the relevant
jqfilter.
Note
Example commands for log operations use jq together with find, where find provides all log files from the bucket for processing.