Skip to content

Commit 0478375

Browse files
committed
docs: write tutorial to export audit trail to datadog
1 parent 48b1aa3 commit 0478375

File tree

1 file changed

+167
-0
lines changed
  • tutorials/export-audit-trail-to-datadog

1 file changed

+167
-0
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
meta:
3+
title: Export Audit Trail to DataDog
4+
description: Learn how to export audit trail events to DataDog
5+
content:
6+
h1: Export Audit Trail to DataDog
7+
paragraph: Learn how to export audit trail events to DataDog
8+
tags: audit-trail log events
9+
categories:
10+
- audit-trail
11+
- instances
12+
dates:
13+
validation: 2025-02-06
14+
posted: 2025-02-06
15+
---
16+
17+
This guide will help you exporting audit trail events to DataDog. For that, it will depends on building a [custom OpenTelemetry Collector](https://opentelemetry.io/docs/collector/custom-collector/) that will collect Audit Trail events through the [Audit Trail receiver](https://github.com/scaleway/opentelemetry-collector-scaleway/tree/main/receiver/scwaudittrail) and export them with the [DataDog exporter](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/datadogexporter).
18+
19+
<Macro id="requirements" />
20+
21+
- A Scaleway account logged into the [console](https://console.scaleway.com)
22+
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
23+
- An [SSH key](/organizations-and-projects/how-to/create-ssh-key/)
24+
- An [Instance](/instances/how-to/create-an-instance/)
25+
26+
## Building the collector
27+
28+
The first step is to install the OpenTelemetry Collector Builder by following [this link](https://opentelemetry.io/docs/collector/custom-collector/#step-1---install-the-builder).
29+
30+
Once you have the `ocb` binary, you will create the manifest in YAML to configure the builder. Create a file `builder-config.yaml` with the following content:
31+
32+
```yaml
33+
dist:
34+
name: otelcol-audit-trail
35+
description: OpenTelemetry Collector for Audit Trail
36+
output_path: ./otelcol-audit-trail
37+
38+
exporters:
39+
- gomod:
40+
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter v0.118.0
41+
42+
processors:
43+
- gomod:
44+
go.opentelemetry.io/collector/processor/batchprocessor v0.118.0
45+
46+
receivers:
47+
- gomod:
48+
github.com/scaleway/opentelemetry-collector-scaleway/receiver/scwaudittrail v0.1.0
49+
50+
providers:
51+
- gomod: go.opentelemetry.io/collector/confmap/provider/envprovider v1.24.0
52+
- gomod: go.opentelemetry.io/collector/confmap/provider/fileprovider v1.24.0
53+
- gomod: go.opentelemetry.io/collector/confmap/provider/httpprovider v1.24.0
54+
- gomod: go.opentelemetry.io/collector/confmap/provider/httpsprovider v1.24.0
55+
- gomod: go.opentelemetry.io/collector/confmap/provider/yamlprovider v1.24.0
56+
```
57+
58+
Then you can build the collector by running the following command:
59+
60+
```
61+
./ocb --config builder-config.yaml
62+
```
63+
64+
You will have a new folder named `otelcol-audit-trail/` with the binary compiled inside named `otelcol-audit-trail`.
65+
66+
## Deploying the collector
67+
68+
The next thing to do is to upload the collector binary to your instance:
69+
70+
```
71+
scp otelcol-audit-trail/otelcol-audit-trail root@<IP ADDRESS>:/usr/local/bin/
72+
```
73+
74+
The remaining of the tutoial will happen inside the instance, you need to ssh to it.
75+
76+
```
77+
ssh root@<IP ADDRESS>
78+
```
79+
80+
## Configure the collector
81+
82+
The custom collector we just build needs a configuration to run. Create the file `/etc/opentelemetry-collector/config.yaml` with the following content:
83+
84+
```yaml
85+
receivers:
86+
scwaudittrail:
87+
access_key: <SCW_ACCESS_KEY>
88+
secret_key: <SCW_SECRET_KEY>
89+
organization_id: <SCW_DEFAULT_ORGANIZATION_ID>
90+
region: <SCW_DEFAULT_REGION>
91+
92+
processors:
93+
batch:
94+
send_batch_max_size: 1000
95+
send_batch_size: 100
96+
timeout: 10s
97+
98+
exporters:
99+
datadog:
100+
idle_conn_timeout: 10s
101+
api:
102+
key: <DD_API_KEY>
103+
site: <DD_SITE>
104+
105+
service:
106+
pipelines:
107+
logs:
108+
receivers: [scwaudittrail]
109+
processors: [batch]
110+
exporters: [datadog]
111+
```
112+
113+
Be sure to replace the following variables:
114+
- SCW_ACCESS_KEY: Scaleway API access key
115+
- SCW_SECRET_KEY: Scaleway API secret key
116+
- SCW_DEFAULT_ORGANIZATION_ID: Scaleway organization ID
117+
- SCW_DEFAULT_REGION: Scaleway region
118+
- DD_API_KEY: DataDog API key
119+
- DD_SITE: DataDog site (see documentation in [DataDog site](https://docs.datadoghq.com/getting_started/site/#access-the-datadog-site))
120+
121+
## Running the collector
122+
123+
Create the systemd service that will run the collector by creating the file `/etc/systemd/system/opentelemetry-collector.service` with the following content:
124+
125+
```
126+
[Unit]
127+
Description=OpenTelemetry Collector
128+
After=multi-user.target
129+
130+
[Service]
131+
ExecStart=/usr/local/bin/otelcol-audit-trail --config /etc/opentelemetry-collector/config.yaml
132+
Type=simple
133+
134+
[Install]
135+
WantedBy=multi-user.target
136+
```
137+
138+
Run the following command to update systemd services:
139+
140+
```
141+
systemctl daemon-reload
142+
```
143+
144+
Then you can enable and start the service by running:
145+
146+
```
147+
systemctl enable opentelemetry-collector.service
148+
systemctl start opentelemetry-collector.service
149+
```
150+
151+
You can ensure the service is running with the command:
152+
153+
```
154+
systemctl status opentelemetry-collector.service
155+
```
156+
157+
And you can follow the logs with the command
158+
159+
```
160+
journalctl -fu opentelemetry-collector.service
161+
```
162+
163+
To confirm that the collector is polling Audit Trail events you should see something like this in the logs:
164+
165+
```
166+
Feb 07 15:34:30 scw-beautiful-zhukovsky otelcol-audit-trail[1723]: 2025-02-07T15:34:30.687Z info [email protected]/receiver.go:80 Polling Audit Trail logs {"kind": "receiver", "name": "scwaudittrail", "data_type": "logs"}
167+
```

0 commit comments

Comments
 (0)