Uploading audit logs to SIEM KUMA
In this tutorial, you will create an Audit Trails trail that will provide audit logs to the KUMA collector.
The solution
- A trail uploads logs to an Yandex Object Storage bucket with encryption enabled.
- The bucket is mounted as a part of the file system
on the server with the KUMA collector installed. - The KUMA collector receives event data from the mounted bucket and forwards it for processing.
To configure delivery of audit log files to KUMA:
- Prepare your cloud.
- Prepare the environment.
- Create a bucket.
- Create a trail.
- Mount the bucket on a server.
- Configure the KUMA collector.
If you no longer need the resources you created, delete them.
Prepare your cloud
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Required paid resources
The cost of support for a new Yandex Cloud infrastructure includes:
- Fee for data storage, operations with data, and outgoing traffic (see Yandex Object Storage pricing).
- Fee for a symmetric encryption key and cryptographic operations (see Yandex Key Management Service pricing).
- (Optional) Fee for a continuously running VM (see Yandex Compute Cloud pricing).
- (Optional) Fee for using a dynamic or static external IP address (see Yandex Virtual Private Cloud pricing).
In addition, to complete the tutorial you will need a KUMA user license (not supplied by Yandex Cloud).
Prepare the environment
Create service accounts
The infrastructure you are creating will require two service accounts: one for the Object Storage bucket, the second for the trail in Audit Trails.
To create the service accounts:
- In the management console
, go to the folder you want to create an infrastructure in. - In the list of services, select Identity and Access Management.
- Click Create service account.
- Enter a name of the service account for the bucket:
kuma-bucket-sa
. - Click Create.
- Repeat steps 3-5 to create the
kuma-trail-sa
service account for the trail.
Create a static access key
To mount the bucket on a server with a KUMA collector installed, create a static access key for the kuma-bucket-sa
service account:
-
In the management console
, go to the folder you want to create an infrastructure in. -
In the list of services, select Identity and Access Management.
-
In the left-hand panel, select
Service accounts. -
Select the
kuma-bucket-sa
service account. -
In the top panel, click
Create new key and select Create static access key. -
Specify the key description and click Create.
-
Save the ID and secret key: you will need them later when mounting the bucket on the server.
Alert
After you close the dialog, the key value will become unavailable.
Create an encryption key
To create a new symmetric encryption key:
-
In the management console
, go to the folder you want to create an infrastructure in. -
In the list of services, select Key Management Service.
-
In the left-hand panel, select
Symmetric keys. -
Click Create key and set the key attributes:
- Name:
kuma-key
. - Encryption algorithm, e.g.
AES-256
.
- Name:
-
Click Create.
Assign roles to the service accounts
-
To assign roles for a folder to service accounts:
Management console-
In the management console
, go to the folder you want to create an infrastructure in. -
Go to the Access bindings tab.
-
Click Configure access.
-
In the window that opens, select Service accounts.
-
Select the
kuma-trail-sa
service account from the list, use the search if required. -
Click
Add role; in the window that opens, select theaudit-trails.viewer
role.Repeat this step and add the
storage.uploader
role. -
Click Save.
-
Repeat steps 3-7 to assign the
storage.viewer
role for the folder to thekuma-bucket-sa
service account.
-
-
To assign the
kms.keys.encrypterDecrypter
role for the encryption key created earlier to the service accounts:Management console- In the management console
, go to the folder you want to create an infrastructure in. - In the list of services, select Key Management Service.
- In the left-hand panel, select
Symmetric keys and click on the line withkuma-key
. - Go to
Access bindings and click Assign bindings. - Select the
kuma-trail-sa
service account. - Click
Add role and select thekms.keys.encrypterDecrypter
role. - Click Save.
- Repeat steps 3-7 to assign the
kms.keys.encrypterDecrypter
role for the encryption key to thekuma-bucket-sa
service account.
- In the management console
Create a bucket
To create a bucket for the trail to save audit logs to:
-
In the management console
, go to the folder you want to create an infrastructure in. -
In the list of services, select Object Storage.
-
At the top right, click Create bucket.
-
In the ** Name** field, enter a name for the bucket, e.g.,
my-audit-logs-for-kuma
.Note
Bucket names must be unique throughout Object Storage, which means you cannot create two buckets with the same name even in different folders belonging to different clouds.
-
In the Max size field, set the size of the bucket you are creating or enable No limit.
-
Leave all other parameters as they are and click Create bucket.
-
On the page with a list of buckets that opens, select the new bucket.
-
In the left-hand menu, select
Securityand go to the Encryption tab. -
In the KMS Key field, select the previously created
kuma-key
. -
Click Save.
Create a trail
To create a trail:
-
In the management console
, go to the folder you want to create an infrastructure in. -
Select Audit Trails.
-
In the window that opens, click Create trail:
-
In the Name field, enter a name for the trail:
kuma-trail
. -
Under Destination, configure the destination object:
- Destination:
Object Storage
. - Bucket: Bucket you created earlier, e.g.,
my-audit-logs-for-kuma
. - Object prefix: 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:
-
Make sure the Encryption key field contains the encryption key named
kuma-key
. If the encryption key is not set, click Add and select this key. -
Under Collecting management events, configure the collection of management event audit logs:
- Collecting events: Select
Enabled
. - Resource: Select
Folder
. - Folder: Automatically populated field containing the name of the current folder.
- Collecting events: Select
-
Under Service account above, select the
kuma-trail-sa
service account. -
Under Collecting data events, keep the
Disabled
value. -
Click Create.
-
Mount the bucket on a server
Perform this action on the server you are going to install the KUMA collector on. As a server, you can use a Yandex Compute Cloud VM or your own hardware. In this tutorial, we will use a Compute Cloud VM.
To mount the bucket on a server:
-
Create a virtual machine from the Ubuntu 22.04 LTS public image.
-
Create a new user named
kuma
:sudo useradd kuma
-
Create the
kuma
user's home directory:sudo mkdir /home/kuma
-
Create a file with a static access key and grant permissions for it to the
kuma
user:sudo bash -c 'echo <access_key_ID>:<secret_access_key> > /home/kuma/.passwd-s3fs' sudo chmod 600 /home/kuma/.passwd-s3fs sudo chown -R kuma:kuma /home/kuma
Where
<access_key_ID>
and<secret_access_key>
are the previously saved values of the static access key of thekuma-bucket-sa
service account. -
Install the s3fs
package:sudo apt install s3fs
-
Create a directory that will serve as a mount point for the bucket and grant permissions for it to the
kuma
user:sudo mkdir /var/log/yandex-cloud/ sudo chown kuma:kuma /var/log/yandex-cloud/
-
Mount the bucket you created earlier by specifying its name:
sudo s3fs <bucket_name> /var/log/yandex-cloud \ -o passwd_file=/home/kuma/.passwd-s3fs \ -o url=https://storage.yandexcloud.net \ -o use_path_request_style \ -o uid=$(id -u kuma) \ -o gid=$(id -g kuma)
You can configure automatic mounting of the bucket at operating system start-up by opening the
/etc/fstab
file (sudo nano /etc/fstab
command) and adding the following line to it:s3fs#<bucket_name> /var/log/yandex-cloud fuse _netdev,uid=<kuma_uid>,gid=<kuma_gid>,use_path_request_style,url=https://storage.yandexcloud.net,passwd_file=/home/kuma/.passwd-s3fs 0 0
Where:
-
<bucket_name>
: Name of the bucket you created earlier, e.g.,my-audit-logs-for-kuma
. -
<kuma_uid>
:kuma
user ID in the VM operating system. -
<kuma_gid>
:kuma
user group ID in the VM operating system.To learn
<kuma_uid>
and<kuma_gid>
, run theid kuma
command in the terminal.
-
-
Make certain that the bucket is mounted:
sudo ls /var/log/yandex-cloud/
If everything is configured correctly, the command will return the current contents of the audit event bucket.
The Yandex Cloud event transfer setup is complete. The events will reside in JSON
/var/log/yandex-cloud/{audit_trail_id}/{year}/{month}/{day}/*.json
Configure the KUMA collector
For this step, you will need the distribution and license files included with KUMA. Use them to install and configure the collector in the KUMA network infrastructure. For more information, see this guide
Once the setup is successfully completed, audit events will start being delivered to KUMA. The KUMA web interface allows you to search for related events
How to delete the resources you created
To stop paying for the resources you created: