Ingest#

Reference · Operators

The collector writes into otel.otel_logs. checked_mv verifies each record’s TPM quote once, and the result is routed either to the audit store or to the reject log. Neither otel_logs nor checked keeps a row.

Schema: tools/backend/sql/10-ingest.sql

Views, functions and jobs#

shirudo.checked_mv

materialized view, on insert.

Splits the quote with a regex, calls tpm_quote_check(attest, sig, ak, sha256(body)) once per record and writes the parsed JSON answer to checked.

shirudo.keepalive_mv

materialized view, on insert.

checked → keepalive for accepted rows.

shirudo.rejected_mv

materialized view, on insert.

checked → rejected for refused rows, with reject as reason.

tpm_quote_check()

executable_pool UDF, clickhouse/tpm_quote_check_function.xml.

Runs shirudo-quote-check (pool of 4). Returns one JSON line: ok, reason, ak_name, ak_public, reset_count, clock.

otel.otel_logs#

Null engine: holds no rows, feeds the views on it

Landing table for the OpenTelemetry Collector’s ClickHouse exporter. It holds nothing; it exists so the exporter has a target and checked_mv has a source.

  • The columns match what the exporter inserts. Only Timestamp, ResourceAttributes[‘host.name’], LogAttributes[‘shirudo.quote’], Body and EventName are used.

  • Log records with any other event name are dropped.

Engine:

Null

Defined in:

tools/backend/sql/10-ingest.sql

Written by:

otelcol-contrib, configured by tools/backend/otelcol.yaml

Fires on insert:

checked_mv into checked

Queried by:

nothing in the schema

Row size:

0 B stored. About 2 KB per record on the wire (body ~0.9 KB plus quote).

Scale:

Nodes × 1 record per minute, passing through: 10,000 nodes ≈ 170 inserts/s.

Reference fleet:

0 B

Columns (16)

Column

Type

Meaning

Timestamp

DateTime64(9)

Becomes checked.time.

TraceId

String

OTLP trace context. Unused.

SpanId

String

OTLP trace context. Unused.

TraceFlags

UInt8

OTLP trace context. Unused.

SeverityText

LowCardinality(String)

Unused.

SeverityNumber

UInt8

Unused.

ServiceName

LowCardinality(String)

Unused.

Body

String

The keepalive body: a compact JSON string that the quote signs.

ResourceSchemaUrl

LowCardinality(String)

Unused.

ResourceAttributes

Map(LowCardinality(String), String)

host.name is taken from here.

ScopeSchemaUrl

LowCardinality(String)

Unused.

ScopeName

String

Unused.

ScopeVersion

LowCardinality(String)

Unused.

ScopeAttributes

Map(LowCardinality(String), String)

Unused.

LogAttributes

Map(LowCardinality(String), String)

shirudo.quote: attest=…;sig=…;ak=… (base64 TPM structures).

EventName

String

Must be shirudo.keepalive.

shirudo.checked#

Null engine: holds no rows, feeds the views on it

One row per keepalive, accepted or not, with the checker’s answer and every body field split into its own column. The body fields and order_key/reject are DEFAULT expressions, so a test can insert just the first eleven columns and get the same row a real record would.

  • order_key = reset_count << 40 | clock. That leaves 24 bits for reset_count and 40 for clock; a record outside that range is rejected as clock_range.

  • reject is computed in order: checker failure (bad_signature, body_mismatch, malformed), then schema, then clock_range. Empty means accepted.

Engine:

Null

Defined in:

tools/backend/sql/10-ingest.sql

Written by:

checked_mv on insert into otel.otel_logs; tests, which insert here directly

Fires on insert:

keepalive_mv into keepalive; rejected_mv into rejected; nodes_mv into nodes; keepalive_latest_mv into keepalive_latest; boot_first_mv into boot_first

Queried by:

nothing in the schema

Row size:

0 B stored.

Scale:

Same rate as otel_logs. Each row costs one tpm_quote_check call (pool of 4 processes).

Reference fleet:

0 B

Columns (35)

Column

Type

Meaning

received

DateTime64(3)

When the backend received the record. Freshness (check 2) and retention count from it.

DEFAULT now64(3)

time

DateTime64(9)

The OTLP Timestamp the target put on the log record. Not trusted for ordering.

host_name

String

host.name resource attribute: what the node claims to be called. Not an identity.

quote

String

The shirudo.quote attribute as sent.

body

String

The JSON body as sent.

ok

UInt8

1 when tpm_quote_check accepted the quote.

reason

LowCardinality(String)

The checker’s reason on failure.

ak_name

String

Attestation key name, from the checker.

ak_public

String

Public area of the attestation key, from the checker. Goes only to nodes.

reset_count

UInt64

TPM reset counter from the quote.

clock

UInt64

TPM clock from the quote.

schema

String

Body schema. Must be shirudo.keepalive/1 or 1.x, else the record is rejected as schema.

DEFAULT JSONExtractString(body, 'schema')

boot_id

String

Identifies the boot that sent the record. Tamper baselines in boot_first are per boot.

DEFAULT JSONExtractString(body, 'boot_id')

version_id

String

Build identifier of the shirudo binary: SHA-256 over its git commit (with -dirty), config.mk and Makefile.shirudo. Printed by shirudo version –version-id. Check 3 requires it to be in expected_builds.

DEFAULT JSONExtractString(body, 'version_id')

config_root

Nullable(String)

Digest of the node’s configuration. One of the keys that groups peers for check 7.

DEFAULT JSONExtract(body, 'config_root', 'Nullable(String)')

kernel_release

String

Running kernel, e.g. 7.4.2. Groups peers (check 7) and is matched against kernel_vulns via kver().

DEFAULT JSONExtractString(body, 'kernel_release')

image_id

Nullable(String)

OS image the node says it booted. Joins to sbom_images.

DEFAULT JSONExtract(body, 'image_id', 'Nullable(String)')

image_version

Nullable(String)

Version of that image.

DEFAULT JSONExtract(body, 'image_version', 'Nullable(String)')

image_root

Nullable(String)

Verity root of the image. When it matches the SBOM’s root the binding is verified.

DEFAULT JSONExtract(body, 'image_root', 'Nullable(String)')

verdict

LowCardinality(String)

The node’s own overall verdict. Check 3 requires ok.

DEFAULT JSONExtractString(body, 'verdict')

cond

UInt64

Condition pairs, two bits each. Check 3 requires the low seven pairs to read 0x1555 (all OK).

DEFAULT JSONExtractUInt(body, 'cond')

flags

UInt64

Bits 0–3 are faults and fail check 3 (bit 2: outcomes file damaged, bit 3: tamper counters unreadable). Bit 4: sync in progress. Bit 5: snapshot unsettled.

DEFAULT JSONExtractUInt(body, 'flags')

tamper

Array(UInt64)

Tamper counters. Their sum must not rise within a boot (check 3). Empty when unreadable.

DEFAULT JSONExtract(body, 'tamper', 'Array(UInt64)')

tree_id

Nullable(String)

The upatch tree the node follows. NULL means no tree, and checks 4–7 are skipped.

DEFAULT JSONExtract(body, 'tree_id', 'Nullable(String)')

generation

Nullable(UInt64)

Publication generation of the tree the node has seen.

DEFAULT JSONExtract(body, 'generation', 'Nullable(UInt64)')

base_seq

Nullable(UInt64)

The record’s window starts after this operation seq (exclusive).

DEFAULT JSONExtract(body, 'base_seq', 'Nullable(UInt64)')

last_seq

Nullable(UInt64)

Last operation the node has applied (inclusive end of the window).

DEFAULT JSONExtract(body, 'last_seq', 'Nullable(UInt64)')

base_root

Nullable(String)

Hash-chain root at base_seq, 64 hex digits.

DEFAULT JSONExtract(body, 'base_root', 'Nullable(String)')

projection_root

Nullable(String)

Hash-chain root after last_seq. Check 4 refolds the tree to reproduce it.

DEFAULT JSONExtract(body, 'projection_root', 'Nullable(String)')

mask

Nullable(String)

Base64, two bits per operation in the window: 1 applied, 2 selector did not match, 3 attach module not loaded, 0 not reached. Decoded by mask_code().

DEFAULT JSONExtract(body, 'mask', 'Nullable(String)')

set_sha256

String

Hash of the upatch set the node has loaded. Check 6 recomputes it.

DEFAULT JSONExtractString(body, 'set_sha256')

count

UInt64

Number of upatches loaded. Shown as loaded in node_status.

DEFAULT JSONExtractUInt(body, 'count')

not_ok

UInt64

Reported by the node and stored. No check reads it.

DEFAULT JSONExtractUInt(body, 'not_ok')

order_key

UInt64

reset_count << 40 | clock. The TPM’s own ordering, never a wall clock.

DEFAULT bitOr(bitShiftLeft(reset_count, 40), clock)

reject

LowCardinality(String)

Empty if accepted, else malformed, bad_signature, body_mismatch, schema or clock_range.

DEFAULT multiIf( ok != 1, if(reason = '', 'malformed', reason), schema != 'shirudo.keepalive/1' AND NOT startsWith(schema, 'shirudo.keepalive/1.'), 'schema', reset_count >= 16777216 OR clock >= 1099511627776, 'clock_range', '')

shirudo.keepalive#

Stored

Every accepted record with its quote and body, kept for audit. No check reads this table.

  • A record sent twice has the same key and collapses into one row on merge.

  • quote and body are ZSTD-compressed.

Engine:

ReplacingMergeTree

Order by:

(ak_name, reset_count, clock)

TTL:

toDateTime(received) + INTERVAL 3600 SECOND. The default of keepalive_retention_seconds in settings; tools/backend/sql/apply-retention.sh rewrites it from the setting

Defined in:

tools/backend/sql/10-ingest.sql

Written by:

keepalive_mv on insert into checked

Fires on insert:

nothing

Queried by:

audit and ad-hoc queries only

Row size:

~200 B per record compressed (README).

Scale:

Nodes × 1,440 records per day × retention. 30 days of retention is 432M rows ≈ 86 GB.

Reference fleet:

600k rows ≈ 120 MB at the default 1 hour

Columns (30)

Column

Type

Meaning

received

DateTime64(3)

When the backend received the record. Freshness (check 2) and retention count from it.

time

DateTime64(9)

The OTLP Timestamp the target put on the log record. Not trusted for ordering.

host_name

String

host.name resource attribute: what the node claims to be called. Not an identity.

quote

String CODEC(ZSTD(1))

The signed quote, ZSTD(1).

body

String CODEC(ZSTD(1))

The signed body, ZSTD(1).

ak_name

String

Name of the TPM attestation key. This is the node’s identity everywhere in the schema.

reset_count

UInt32

TPM reset counter from the quote. First half of the ordering.

clock

UInt64

TPM clock from the quote. Second half of the ordering.

schema

LowCardinality(String)

Body schema. Must be shirudo.keepalive/1 or 1.x, else the record is rejected as schema.

boot_id

String

Identifies the boot that sent the record. Tamper baselines in boot_first are per boot.

version_id

String

Build identifier of the shirudo binary: SHA-256 over its git commit (with -dirty), config.mk and Makefile.shirudo. Printed by shirudo version –version-id. Check 3 requires it to be in expected_builds.

config_root

Nullable(String)

Digest of the node’s configuration. One of the keys that groups peers for check 7.

kernel_release

LowCardinality(String)

Running kernel, e.g. 7.4.2. Groups peers (check 7) and is matched against kernel_vulns via kver().

image_id

Nullable(String)

OS image the node says it booted. Joins to sbom_images.

image_version

Nullable(String)

Version of that image.

image_root

Nullable(String)

Verity root of the image. When it matches the SBOM’s root the binding is verified.

verdict

LowCardinality(String)

The node’s own overall verdict. Check 3 requires ok.

cond

UInt64

Condition pairs, two bits each. Check 3 requires the low seven pairs to read 0x1555 (all OK).

flags

UInt64

Bits 0–3 are faults and fail check 3 (bit 2: outcomes file damaged, bit 3: tamper counters unreadable). Bit 4: sync in progress. Bit 5: snapshot unsettled.

tamper

Array(UInt64)

Tamper counters. Their sum must not rise within a boot (check 3). Empty when unreadable.

tree_id

Nullable(String)

The upatch tree the node follows. NULL means no tree, and checks 4–7 are skipped.

generation

Nullable(UInt64)

Publication generation of the tree the node has seen.

base_seq

Nullable(UInt64)

The record’s window starts after this operation seq (exclusive).

last_seq

Nullable(UInt64)

Last operation the node has applied (inclusive end of the window).

base_root

Nullable(String)

Hash-chain root at base_seq, 64 hex digits.

projection_root

Nullable(String)

Hash-chain root after last_seq. Check 4 refolds the tree to reproduce it.

mask

Nullable(String)

Base64, two bits per operation in the window: 1 applied, 2 selector did not match, 3 attach module not loaded, 0 not reached. Decoded by mask_code().

set_sha256

String

Hash of the upatch set the node has loaded. Check 6 recomputes it.

count

UInt64

Number of upatches loaded. Shown as loaded in node_status.

not_ok

UInt64

Reported by the node and stored. No check reads it.

shirudo.rejected#

Stored

Every refused record and why. Check 1 counts a node’s rejections in the last hour.

Engine:

MergeTree

Order by:

received

TTL:

toDateTime(received) + INTERVAL 7 DAY

Defined in:

tools/backend/sql/10-ingest.sql

Written by:

rejected_mv on insert into checked

Fires on insert:

nothing

Queried by:

node_status_mv into node_status

Row size:

~1 KB (estimate: raw quote and body, sorted by time so little cross-row compression).

Scale:

Refused records × 7 days. Near zero normally; one bad node at 1 per minute adds ~10,000 rows a week.

Reference fleet:

≈ 10 MB per misbehaving node

Columns (8)

Column

Type

Meaning

received

DateTime64(3)

When it arrived.

reason

LowCardinality(String)

malformed: quote missing or unparseable. bad_signature: does not verify or wrong signer. body_mismatch: quote is over a different body. schema: unknown major version. clock_range: counters too large for order_key.

host_name

String

Claimed host name.

ak_name

String

Key name, when the checker got far enough to read one.

reset_count

UInt64

From the quote, if parsed.

clock

UInt64

From the quote, if parsed.

quote

String CODEC(ZSTD(1))

As sent, ZSTD(1).

body

String CODEC(ZSTD(1))

As sent, ZSTD(1).