Customize export of audit logs via API for integration with any SIEM system
This is an instruction for configuring the export of audit logs via API to your SIEM system. The settings on the side of SIEM-system you need to perform on your own according to its official documentation. For integration with RuSIEM and Wazuh systems use the instructions Set up integration with RuSIEM SIEM system and Set up integration with Wazuh SIEM system.
You can also upload audit logs manually in the control panel.
- Create a service user.
- Get an IAM token for the account.
- Get a script to export audit logs.
- Set up and run the script.
- Configure log ingestion in the SIEM system.
1. Create a service user
Add a service user with permission in the access area Account and role member.
Users can be added by the Account Owner or users with the role of iam.admin.
2. Get an IAM token for the account
Get an IAM token for the account for the service user you created in step 1.
3. Get a script for exporting audit logs to the SIEM system
We have prepared a script for exporting audit logs - it allows you to upload logs to a file and send them to a specified IP address or endpoint via syslog or HTTP/HTTPS.
-
Open the CLI.
-
Clone the script repository:
git clone https://github.com/t-rex-general/auditlog-integration.gitThe script files will be saved to the
auditlog-integrationfolder in the working directory.
4. Set up and run the script
The script allows you to get logs in several ways:
- to upload to a file;
- send to the IP address via the
syslogprotocol; - send to the endpoint via
HTTP/HTTPSprotocol.
Customize the script depending on the desired way of getting logs:
Upload to file
Send via syslog
Send via HTTP/HTTPS
-
Open the CLI.
-
Create a virtual environment:
python3 -m venv .venv -
Activate the virtual environment:
source .venv/bin/activate -
Go to the script folder:
cd auditlog-integration -
Install the necessary dependencies:
pip3 install -r requirements.txt -
Create an
.envconfiguration file:touch .env -
Open the
.envconfiguration file:nano .env -
Fill in
the .envconfiguration file:8.1 Add a block with parameters for authentication in the API of the Audit-Logs service:
AUDIT_LOGS_URL=<base_url>/v1/logs
USERNAME=<username>
PASSWORD=<password>
ACCOUNT_ID=<account_id>Specify:
<base_url>- URL to access the audit logs API in the required pool. You can see the list of URLs in the instructions List of URLs;<username>- the name of the service user you created in step 1;<password>- password of the service user. If the password contains the characters[]\^$.|?*+()and escape them by putting a backslash in front of the character.\;<account_id>- account number, can be viewed in control panel in the upper right corner.
8.2 Add a block with parameters for sending events:
TRANSPORT_TYPE=fileBy default, logs are saved in the script folder in the
events.txtfile.8.3 Add a line with the API invocation interval:
POLL_INTERVAL=<poll_interval>Specify
<poll_interval>- interval of API call in seconds (default is 30).8.4. Exit the save file by successively pressing Ctrl+X → Y → Enter.
8.5 Optionally: change the name of the file where the logs are saved, for this purpose in the script folder in the file
savers.pyin the blockclass FileSaverchange the value in the fieldself.filename. -
Run the script:
python3 main.py
-
Open the CLI.
-
Create a virtual environment:
python3 -m venv .venv -
Activate the virtual environment:
source .venv/bin/activate -
Go to the script folder:
cd auditlog-integration -
Install the necessary dependencies:
pip3 install -r requirements.txt -
Create an
.envconfiguration file:touch .env -
Open the
.envconfiguration file:nano .env -
Fill in
the .envconfiguration file:8.1 Add a block with parameters for authentication in the API of the Audit-Logs service:
AUDIT_LOGS_URL=<base_url>/v1/logs
USERNAME=<username>
PASSWORD=<password>
ACCOUNT_ID=<account_id>Specify:
<base_url>- URL to access the audit logs API in the required pool. You can see the list of URLs in the instructions List of URLs;<username>- the name of the service user you created in step 1;<password>- password of the service user. If the password contains the characters[]\^$.|?*+()and escape them by putting a backslash in front of the character.\;<account_id>- account number, can be viewed in control panel in the upper right corner.
8.2 Add a block with parameters for sending events:
TRANSPORT_TYPE=syslog
SYSLOG_HOST=<syslog_host>
SYSLOG_PORT=<syslog_port>Specify:
<syslog_host>- IP address of the SIEM system;<syslog_port>- port on the specified IP address.
The IP address and port can be viewed in the settings of your SIEM system.
8.3 Add a line with the API invocation interval:
POLL_INTERVAL=<poll_interval>Specify
<poll_interval>- interval of API call in seconds (default is 30).8.4. Exit the save file by successively pressing Ctrl+X → Y → Enter.
-
Run the script:
python3 main.py
-
Open the CLI.
-
Create a virtual environment:
python3 -m venv .venv -
Activate the virtual environment:
source .venv/bin/activate -
Go to the script folder:
cd auditlog-integration -
Install the necessary dependencies:
pip3 install -r requirements.txt -
Create an
.envconfiguration file:touch .env -
Open the
.envconfiguration file:nano .env -
Fill in
the .envconfiguration file:8.1 Add a block with parameters for authentication in the API of the Audit-Logs service:
AUDIT_LOGS_URL=<base_url>/v1/logs
USERNAME=<username>
PASSWORD=<password>
ACCOUNT_ID=<account_id>Specify:
<base_url>- URL to access the audit logs API in the required pool. You can see the list of URLs in the instructions List of URLs;<username>- the name of the service user you created in step 1;<password>- password of the service user. If the password contains the characters[]\^$.|?*+()and escape them by putting a backslash in front of the character.\;<account_id>- account number, can be viewed in control panel in the upper right corner.
8.2 Add a block with parameters for sending events:
TRANSPORT_TYPE=http
HTTP_URL=<http_url>
HTTP_USERNAME=<http_username>
HTTP_PASSWORD=<http_password>
HTTP_VERIFY_SSL=<verify_ssl>Specify:
<http_url>- URL of the endpoint where the SIEM system receives logs;<http_username>- user name of the SIEM system;<http_password>- SIEM system user password;<verify_ssl>- whether TLS(SSL) certificate verification is required when connecting to the SIEM system:true- perform verification,false- do not verify.
8.3 Add a line with the API invocation interval:
POLL_INTERVAL=<poll_interval>Specify
<poll_interval>- interval of API call in seconds (default is 30).8.4. Exit the save file by successively pressing Ctrl+X → Y → Enter.
-
Run the script:
python3 main.py
5. Configure log reception in the SIEM system
Configure log reception in your SIEM system. Use the official documentation of your SIEM system.