Monitor and export telemetry#
A target pushes two kinds of telemetry to a collector: a status keepalive and snapshots of the maps its upatches keep. Both leave as OTLP/HTTP requests with JSON bodies, sent by one-shot commands that systemd timers start. Nothing connects to the target. This page shows how to choose the destination, set up the collector, check the pipeline and decide what to alert on.
Telemetry is the target’s own account of itself, so it tells you where to look, not what is true. The keepalive carries a quote by the target’s TPM attestation key, which shows that its body is unchanged since that key signed it, but not that the key lives in a genuine TPM. Map snapshots carry no proof of origin at all. Evidence that a target cannot forge comes from the TPM, through Attest targets.
What a target sends#
Timer |
Runs |
Sends |
|---|---|---|
|
|
One log record, |
|
|
One record per pinned map to every destination the config names: JSON lines, OTLP, or both. With no destination, the dump goes to the journal. |
Both timers start their service 5 seconds after boot. The keepalive
timer starts it again 60 seconds after each run ends, the map-export
timer 5 seconds after. shirudo-map-export.service runs only while
/run/shirudo/bpffs/lsm_link exists.
A keepalive and a bpm tree sync stall each other rather than run at
once. Every target command holds the config operation lock for its whole
run, and a sync holds it until its last operation is applied. A
keepalive that starts during a sync waits up to 30 seconds for the lock;
when the sync is still running then, that run fails and sends nothing,
and the next run of the timer tries again. A sync that fetches and
applies for minutes therefore leaves a gap of about that length in the
node’s keepalives, which a backend’s threshold for a stale node must
allow for. See systemd units and timers.
The keepalive record has the event name shirudo.keepalive. Its body
is a string, the keepalive body that shirudo status --keepalive
prints: one compact JSON object of about a kilobyte with the verdict,
the conditions, the tamper and integrity counters, the build, the
config and image,
the tree the target follows and the upatches it has loaded
(shirudo status). Its one attribute, shirudo.quote, is
the TPM quote of the SHA-256 of the body by the attestation key of
shirudo attest. A target whose TPM does not answer sends no
keepalive. Its severity follows the verdict:
Severity |
Verdict |
|---|---|
|
|
|
|
|
Every other verdict, |
A map snapshot has the event name shirudo.bpf.map.snapshot. Its body
is what the map’s signed decoder returns, or the map’s entries when the
upatch ships no decoder for it. A decoder can return metrics instead of
a log record. Every request carries the resource attributes
service.name (shirudo), service.version and host.name.
OTLP documents describes every field.
Before you begin#
On the target,
shirudostands for the runtime image’s binary,/run/shirudo/runtime/usr/bin/shirudo(Run shirudo on the target).The keepalive and map-export services run that binary through their drop-ins (Install the unit drop-ins). Without them both services fail on an enforcing target and nothing is sent.
A collector that accepts OTLP over HTTP with JSON bodies, reachable from the target over TLS 1.3.
On the operator host, the source directory of the target’s config image and the key that signs config images.
Set the destination#
The destination belongs in the signed config image, in
etc/shirudo/shirudo.conf. The target ignores the host’s
/etc/shirudo/shirudo.conf while a config image is active.
In the config source directory, add the export settings to
etc/shirudo/shirudo.conf:map_export.otel_endpoint = https://<collector-host>:4318 map_export.tenant_id = <tenant>
<collector-host>is the collector’s DNS name.<tenant>is an optional label that the target sends as theX-Tenant-IDheader.Build, sign and activate the config, as described in Change the signed config.
Check the effective settings on the target:
target# shirudo config # shirudo config (authenticated config image; TPM settings from runtime image) ... map_export.json_path = map_export.otel_endpoint = map_export.tenant_id = config-boot-keys map_export.otel_insecure = false map_export.otel_retries = 3 map_export.s3_uri = map_export.log_record_max_bytes = 1048576 map_export.otlp_max_bytes = 4194304
The first line says that the settings come from the authenticated config image. This target’s config names no destination yet, so
map_export.otel_endpointis empty. After your update it shows your collector.
The config image accepts these keys:
Key |
Meaning |
|---|---|
|
Base URL of the collector. The target appends |
|
Value of the |
|
|
|
Retries after a failed request, 0 to 10. Default: 3. |
|
Absolute path of a file to which |
|
S3 location for a decoded snapshot too large for one OTLP
record. The collector then receives a record that points to the
object. Requires |
|
Largest log record, 1 to 8388608 bytes, at most
|
|
Largest request body before compression, 1 to 8388608 bytes. Default: 4194304. |
The only other key the config image’s shirudo.conf accepts is
eventlog.max_bytes. Configuration lists
every key, including those of the runtime image.
Set credentials and TLS material#
Credentials, headers and certificates are environment variables, not
configuration. systemd reads them for both services from
/etc/shirudo/map-export.env.
Write the variables your collector needs to
/etc/shirudo/map-export.env:OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer%20<token> OTEL_EXPORTER_OTLP_CERTIFICATE=/etc/shirudo/collector-ca.pem
OTEL_EXPORTER_OTLP_HEADERStakes comma-separated<key>=<value>pairs with percent-encoded values, so%20is a space. It refusesContent-Type,Content-Encoding,Content-Length,HostandUser-Agent.OTEL_EXPORTER_OTLP_CERTIFICATEnames the CA bundle that signed the collector’s certificate.<token>is your collector’s ingest token.Make the file readable by root alone:
target# chmod 0600 /etc/shirudo/map-export.env
The target also reads these variables:
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATEandOTEL_EXPORTER_OTLP_CLIENT_KEYfor mutual TLS, both or neitherOTEL_EXPORTER_OTLP_COMPRESSION:noneorgzipOTEL_EXPORTER_OTLP_TIMEOUT: milliseconds per attempt, 1 to 120000, default 10000OTEL_EXPORTER_OTLP_PROTOCOL: onlyhttp/jsonis acceptedAWS_REGIONorAWS_DEFAULT_REGION,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_SESSION_TOKEN,AWS_ENDPOINT_URL_S3andAWS_CA_BUNDLEformap_export.s3_uri
Each OTEL_EXPORTER_OTLP_* variable also has a _LOGS_ and a
_METRICS_ form, which wins over the generic one for its signal.
Environment variables lists them all.
The endpoint variables behave differently for the two services:
OTEL_EXPORTER_OTLP_LOGS_ENDPOINTandOTEL_EXPORTER_OTLP_ENDPOINTapply only whilemap_export.otel_endpointis empty.The keepalive sends when
map_export.otel_endpointor one of those two variables is set. It never falls back tolocalhost.upatch map --allsends OTLP only whenmap_export.otel_endpointis set. An endpoint variable alone does not turn the map export on.
/etc/shirudo/map-export.env is host state outside the signed
config, and root on the target can change it. While the signed config
names no endpoint, the file decides where keepalives go. Set the
endpoint in the signed config.
Set up the collector#
The target speaks OTLP/HTTP with JSON bodies and nothing else:
POST <base>/v1/logs and POST <base>/v1/metrics with
Content-Type: application/json, optional Content-Encoding: gzip
and X-Tenant-ID. It uses TLS 1.3 with the hybrid key exchange groups
X25519MLKEM768 and SecP256r1MLKEM768 only. A collector that
offers no hybrid group is refused, unless its exact DNS name is in
tls.classical_hosts in the runtime image’s
etc/shirudo/shirudo.conf, which takes a new runtime image and a
reboot.
Configure the OpenTelemetry Collector’s
otlpreceiver with TLS:receivers: otlp: protocols: http: endpoint: 0.0.0.0:4318 tls: cert_file: /etc/otelcol/collector.crt key_file: /etc/otelcol/collector.key min_version: "1.3" exporters: debug: verbosity: detailed service: pipelines: logs: receivers: [otlp] exporters: [debug] metrics: receivers: [otlp] exporters: [debug]
The
debugexporter prints what arrives. Replace it with the exporters for your storage once records arrive; Integrations sets up ClickHouse, Elasticsearch, Grafana and Splunk. A collector built with Go 1.24 or later offersX25519MLKEM768by default.Restart the collector. Keep the keepalive body a string on its way to storage: a processor that parses it into a structure or rewrites it breaks the quote.
Any HTTPS server that accepts those two requests works as a destination.
It answers 200 to accept. A 200 whose partialSuccess reports
rejected records counts as a failure. The target retries timeouts,
connection errors and the statuses 429, 502, 503 and
504, honors Retry-After, and does not retry any other status.
Check the pipeline#
Print the keepalive body the target reports, without quoting or sending it:
target# shirudo status --keepalive
Send one keepalive by hand:
target# shirudo status --otel
The command prints nothing. When no TPM answers or the quote fails, it prints
status: quote the keepalive: <reason>; nothing is sentand exits 1. When the send fails, it printsstatus: send the keepalive: <reason>and exits 1. When no endpoint is configured, it sends nothing and exits 0.Check that the collector printed a record with the event name
shirudo.keepalive, astringValuebody and the one attributeshirudo.quote.List the maps the loaded upatches pin:
target# shirudo upatch map Pinned maps (0): none
This target has no upatch with maps loaded. With maps, the command lists each map with its upatch, type and size.
Look at one map without draining it and without exporting it:
target# shirudo upatch map <upatch> <map> --peek
<upatch>and<map>are names from the list.--peekasks the serializer for the interval it is collecting and leaves it for the timer.Check that the timers run:
target# systemctl list-timers 'shirudo-*'
Map export without a destination#
shirudo-map-export.timer runs whether or not a destination is
configured. With no map_export.json_path and no
map_export.otel_endpoint, every run reads every pinned map, drains
the maps that have a serializer, and prints the dump to its standard
output, which systemd writes to the journal. That happens every 5
seconds, and drained records are gone for any later exporter.
If nothing consumes map snapshots, stop the timer:
target# systemctl disable --now shirudo-map-export.timer
Maps and decoders#
A map whose upatch ships a signed decoder for it exports what the decoder returns, a log record or metrics. A map without a decoder exports as a log record whose body lists the map’s entries.
One kind of map without a decoder fails: a per-CPU map whose value is an
unsigned BTF integer. The target classifies it as a metric, finds no
decoder to build the metric and prints upatch map: OTLP export
<upatch>/<map>: No data available. Give such a map a decoder.
Write a Lua decoder shows how.
What to alert on#
The keys below are those of the keepalive body,
shirudo status lists them and
Read shirudo status explains what each condition and verdict
means. What only the full report carries, such as the size of the
eventlog, is read with shirudo status --json on the target.
Signal |
What it means |
|---|---|
No keepalive from a host for several intervals |
The target is down or unreachable, the timer or its drop-in is
missing, or the commands fail. A keepalive also fails when
another |
|
Read Read shirudo status for each verdict.
|
A pair of |
|
|
A device an XDP upatch selects runs without it: its driver refuses the program or its XDP was turned off. Each reconcile pass retries it at a cost to the target until the device changes or the upatch is unloaded. Alert on it, and end it as Read shirudo status describes. |
A counter of |
Something on the target tried an operation the guards refused. The counters start at zero each boot. See Tamper counters. |
A counter of |
Something on the target tried to change or read the running
kernel, and |
Bit 0 of |
The register was bound twice in one TPM reset. |
Bit 1 of |
|
Bit 2 of |
The tree eventlog or the outcomes record does not agree with the tree state. |
|
The target runs another shirudo build. |
Limits#
A map snapshot has no proof of origin. Root on a target, or anyone who can reach the collector with valid credentials, can send records in a target’s name. A keepalive’s quote ties its body to an attestation key, but a key in software can sign a quote too, so a backend that has not tied the key to the target’s TPM treats the target as untrusted. Use Attest targets for evidence.
While the config cannot be verified,
statususes only the runtime image’s settings and the environment. While an activation is pending, it uses the pending config’s settings only when that config is the one mounted. To keep keepalives arriving in those states, also setOTEL_EXPORTER_OTLP_ENDPOINTin/etc/shirudo/map-export.env. The map export is refused in those states.The keepalive interval is 60 seconds after the previous run ends, not a fixed schedule. Size the alert for a missing keepalive to several intervals plus the 30-second lock wait, and to the longest tree sync your targets run.
Next steps#
Read shirudo status to read what the keepalive carries
OTLP documents for the records on the wire
Write a Lua decoder to give a map a decoder
shirudo upatch map and shirudo status for every option
Attest targets for evidence that the target cannot forge