Copy the audit log into your SIEM
Send every change made in your organization, in the app or with a token, to your log platform once a day. The script reads yesterday's entries page by page and writes one JSON object per line, the format most log shippers read.
Runnable code: the code on this page, ready to clone and run, is in infranest-examples/examples/audit-log-to-siem. CI runs it against the sandbox.
The token
Make a token with Audit log → Read only. It can read the log and nothing else.
The script
sh
#!/bin/sh
# Writes yesterday's audit log as JSON lines to audit-YYYY-MM-DD.jsonl.
set -eu
DAY=$(date -u -d yesterday +%Y-%m-%d) # macOS: date -u -v-1d +%Y-%m-%d
URL="https://api.infranest.io/api/organizations/42/audit-logs?from=$DAY&to=$DAY&per_page=100"
: > "audit-$DAY.jsonl"
while [ -n "$URL" ] && [ "$URL" != "null" ]; do
page=$(curl -fsS "$URL" -H "Authorization: Bearer $INFRANEST_TOKEN" -H "Accept: application/json")
echo "$page" | jq -c '.data[]' >> "audit-$DAY.jsonl"
URL=$(echo "$page" | jq -r .next_page_url)
doneRun it once a day, shortly after midnight UTC, and point your log shipper (Filebeat, Vector, the Splunk forwarder, …) at the files.
fromandtoare dates (YYYY-MM-DD). Both are included.per_pagegoes up to 100. The answer is a page withdataand anext_page_url, which isnullon the last page.- Each entry has the
action(for exampledns_record.updated), who did it (user), what it was about (resource_type,resource_id), the details inmeta, andcreated_at. See the audit log reference. - Filter with
action(a part of the action name, such asdns_record) orresource_type.