Skip to main content

audit-archiver

audit-archiver stores every Massdriver event in one or more sinks: S3 (or an S3-compatible store), Splunk, Datadog, and a local directory.

Each sink gets the request body exactly as Massdriver signed it. The automation responds 204 only after every configured sink accepted the event. When a sink fails, the automation responds 500, and Massdriver retries the event. The retry writes only to the sinks that failed.

SinkWhat it writes
S3One object for each event, at <prefix>/YYYY/MM/DD/HH/<time>-<id>.json. The time is the event time in UTC, such as 20261124T055403.482913Z. The object has the content type application/cloudevents+json and the metadata webhook-id. A redelivered event writes the same key.
SplunkOne HEC event. event is the body as a string. time is the event time. The indexed fields are webhook_id and event_type.
DatadogOne log. message is the body as a string, and Datadog parses it as JSON. The log also has webhook_id, ddsource:massdriver, and the service and ddtags that you set.
DiskOne file for each event, at <dir>/YYYY/MM/DD/HH/<time>-<id>.json. A redelivered event overwrites its file.

Settings​

The config file is YAML, at CONFIG_FILE (default /etc/massdriver-automations/config.yaml). Each section that is set turns on its sink. Set at least one. An unknown key stops the automation at start. config.example.yaml has every key, with comments.

KeyDefault
s3.bucketRequired with s3.
s3.regionAWS_REGIONThe region of the bucket. Use auto for Cloudflare R2.
s3.prefixeventsThe first part of each key.
s3.endpointThe URL of an S3-compatible store, such as MinIO or Cloudflare R2. The sink then uses path-style URLs.
s3.object_lock.modeGOVERNANCE or COMPLIANCE. Each object gets this retention mode. The bucket must have Object Lock turned on.
s3.object_lock.daysRequired with object_lock. Days to retain each object, counted from when the sink writes it.
splunk.urlRequired with splunk. The base URL of the HTTP Event Collector, such as https://splunk.example.com:8088.
splunk.token_envSPLUNK_HEC_TOKENThe environment variable that holds the HEC token.
splunk.indexEmpty uses the default index of the token.
splunk.sourcemassdriver
splunk.sourcetypemassdriver:cloudevent
datadog.sitedatadoghq.comYour Datadog site, such as datadoghq.eu or us5.datadoghq.com.
datadog.urlhttps://http-intake.logs.<site>The intake URL, for a proxy.
datadog.api_key_envDD_API_KEYThe environment variable that holds the API key.
datadog.servicemassdriver
datadog.tagsTags for each log, such as [env:prod, team:platform].
disk.dirRequired with disk. The directory for the files.
yaml
s3:
bucket: acme-massdriver-audit
region: us-east-1
prefix: events
object_lock:
mode: COMPLIANCE
days: 365

splunk:
url: https://splunk.example.com:8088
index: massdriver

datadog:
site: datadoghq.com
tags: [env:prod, team:platform]

The bundle's Settings params have the keys of the config file, with these differences:

  • Each sink has an enabled toggle in place of the presence of its section.
  • S3 Object Lock is object_lock_days (0 sets no retention) and object_lock_mode (default COMPLIANCE), in place of object_lock. Region is required.
  • splunk.token_env, datadog.api_key_env, and datadog.url are not params. The bundle reads the SPLUNK_HEC_TOKEN and DD_API_KEY secrets.
  • Disk writes inside the container, and a restart loses the files. Use it only to test.

Secrets​

Variable
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEYThe S3 credentials. The sink also reads the other standard AWS sources: a profile, web identity (IRSA, EKS Pod Identity), or the instance or task role.
AWS_REGIONThe region of the bucket, when s3.region is not set.
SPLUNK_HEC_TOKENThe HEC token, or the variable that splunk.token_env names.
DD_API_KEYThe Datadog API key, or the variable that datadog.api_key_env names.
OTEL_EXPORTER_OTLP_HEADERSHeaders for the OTLP endpoint of Tracing, such as authorization=Bearer abc123.

MASSDRIVER_SIGNING_SECRET is a common setting, and is required. audit-archiver does not call the Massdriver API, so it needs no MASSDRIVER_API_KEY.

Permissions​

The automation needs no Massdriver permissions. When deployed with the bundle, the service account needs organization:manageEventDestinations to create the destination.

The S3 credentials need s3:PutObject on the bucket. With Object Lock, they also need s3:PutObjectRetention.

On ECS, when the S3 sink is on, Endpoint is empty, and the AWS_ACCESS_KEY_ID secret is not set, the bundle creates a task role that can call s3:PutObject on <bucket>/<prefix>/*, and s3:PutObjectRetention with Object Lock.

Host​

The bundle serves the automation at Ingress > Host, such as audit-archiver.automations.acme.com. Only /hooks/massdriver must be public. On ECS, an empty host uses audit-archiver.<domain of the cluster's hosted zone>. Refer to Deploy.

Event destination​

The bundle creates a destination that selects every event: no event types, no attributes, and no condition. An attribute filter would drop the events that have no attributes, such as access token and service account events.

To create it yourself:

shell
mass event destination create \
--name audit-archiver \
--url https://audit-archiver.example.com/hooks/massdriver

Copy the signing secret that the command prints into MASSDRIVER_SIGNING_SECRET.

The destination receives events that occur after you create it. To archive older events, read them with the auditLogs query.

Run​

shell
docker run -p 8080:8080 \
-v "$PWD/config.yaml:/etc/massdriver-automations/config.yaml:ro" \
-e MASSDRIVER_SIGNING_SECRET=whsec_... \
-e AWS_ACCESS_KEY_ID=... \
-e AWS_SECRET_ACCESS_KEY=... \
-e SPLUNK_HEC_TOKEN=... \
-e DD_API_KEY=... \
ghcr.io/massdriver-cloud/massdriver-automations:0.3 run audit-archiver

Limits​

  • The automation stores the webhook-id header, which equals the event id. It does not store the webhook-timestamp header, which is the time of the delivery attempt, not of the event.
  • Each sink has 8 seconds to accept an event. A slower sink makes the event fail, and Massdriver retries it.
  • The automation remembers which sinks hold an event for one hour, in memory. After a restart, or on a second replica, a retry writes to every sink again. S3 writes the same key. Splunk and Datadog can then hold a duplicate; use webhook_id to drop it in a search.
  • In a bucket with versioning, which Object Lock needs, a redelivered event adds a version of the same key.
  • Splunk responds 200 when it receives an event, before it indexes it, unless the token uses indexer acknowledgment. The automation does not use acknowledgment.
  • The automation refuses a body larger than 1 MB. Datadog accepts a log of up to 1 MB.
  • Some S3-compatible stores refuse the checksum headers of new AWS SDKs. Set AWS_REQUEST_CHECKSUM_CALCULATION=when_required for such a store. Do not set it for AWS S3 with Object Lock, which needs a checksum on each write.