Skip to content

eBPF-based security platform

Documentation: add Elasticsearch, alert rules and a SIEM export page

Daniel Borkmann822a9439199b
diff --git a/Documentation/concepts/background/index.rst b/Documentation/concepts/background/index.rst
index 5ce4ea79..e7fd82a5 100644
--- a/Documentation/concepts/background/index.rst
+++ b/Documentation/concepts/background/index.rst
@@ -27,4 +27,5 @@ its page.
pqc
oci
opentelemetry
+ siem-export
luajit
diff --git a/Documentation/concepts/background/opentelemetry.rst b/Documentation/concepts/background/opentelemetry.rst
index 59464e86..1dd3f87d 100644
--- a/Documentation/concepts/background/opentelemetry.rst
+++ b/Documentation/concepts/background/opentelemetry.rst
@@ -200,6 +200,8 @@ Related
-------
- :doc:`/operate/run/telemetry` to set up export on a target
+- :doc:`siem-export` for how the records reach a SIEM and what to
+ detect with them
- :doc:`/reference/formats/otlp` for the exported documents
- :doc:`/reference/systemd-units` for the timers and services
- :doc:`luajit` for the decoder sandbox
diff --git a/Documentation/concepts/background/siem-export.rst b/Documentation/concepts/background/siem-export.rst
new file mode 100644
index 00000000..1c6f8903
--- /dev/null
+++ b/Documentation/concepts/background/siem-export.rst
@@ -0,0 +1,162 @@
+..
+ SPDX-License-Identifier: BSD-2-Clause
+ Copyright (c) 2026 Authors of shirudo
+
+:page-type: Explanation
+:audience: Operators, SecOps
+
+SIEM export
+===========
+
+A target reports its own state and what its upatches observe as
+OpenTelemetry records, which :doc:`opentelemetry` explains. This page
+follows those records from the target into a SIEM or another backend,
+shows where their fields land, and explains which detections they
+support and why each one is built as it is.
+
+What a SIEM does
+----------------
+
+A security information and event management system, a SIEM, collects
+events from many sources into one store: hosts, network devices,
+identity providers and applications. It maps them to common fields so
+that one search spans every source, keeps them for investigation and
+compliance, and runs rules that correlate events and raise alerts.
+Splunk and Elastic Security are SIEMs.
+
+Other backends cover part of that. A log store such as Loki keeps and
+searches records, a database such as ClickHouse analyzes them in SQL,
+and Grafana charts and alerts on both. The same records serve each of
+them; what differs is the query language and what the backend charges
+for or limits.
+
+From target to backend
+----------------------
+
+A target pushes OTLP over HTTP with JSON bodies, through TLS 1.3 with a
+hybrid post-quantum key exchange, and nothing else. A SIEM has an
+ingest interface of its own, such as Splunk's HTTP Event Collector or
+Elasticsearch's bulk API. An OpenTelemetry Collector sits between them.
+It accepts the targets' requests, speaks the backend's protocol over
+ordinary TLS, batches and retries, and holds the backend's credentials,
+so a target carries only what it needs to reach the collector.
+
+The target keeps no spool. A map export that fails loses what the map
+collected in that interval, and a keepalive that fails leaves a gap
+until the next one. The collector's sending queue is the only buffer on
+the way. A collector can also filter or rewrite records before export,
+for example to drop the kernel configuration from keepalives, as
+:doc:`/operate/run/telemetry` shows.
+
+Where the fields land
+---------------------
+
+Every record carries the resource attribute ``host.name``, which names
+the target. The event name tells a keepalive, ``shirudo.keepalive``,
+from a map snapshot, ``shirudo.bpf.map.snapshot``. The record's
+attributes hold the few fields worth filtering and alerting on, among
+them ``shirudo.status`` and ``shirudo.tamper_attempts`` on a keepalive.
+The body holds the whole document: the ``shirudo status --json`` report,
+or what a map's decoder returned.
+
+Each exporter keeps that split in its own way:
+
+.. list-table::
+ :header-rows: 1
+ :widths: 19 27 29 25
+
+ * - Backend
+ - Target
+ - Verdict
+ - Body
+ * - ClickHouse
+ - ``ResourceAttributes['host.name']``
+ - ``LogAttributes['shirudo.status']``
+ - ``Body``, as JSON text
+ * - Elasticsearch
+ - ``host.name``
+ - ``shirudo.status``
+ - ``body.structured``
+ * - Loki
+ - Label ``host_name``
+ - Structured metadata ``shirudo_status``
+ - Log line
+ * - Splunk
+ - ``host``
+ - Indexed field ``shirudo.status``
+ - Event
+
+Loki makes ``host_name`` a label only when configured to, as
+:doc:`/operate/integrations/grafana` shows. Rules work best on the
+attributes, which every backend keeps as fields of their own, while the
+body is large, stored as text by some backends and refused above a size
+limit by others.
+
+What to detect
+--------------
+
+Three detections cover the keepalive, and
+:doc:`/operate/integrations/index` gives each of them for every backend.
+
+A target that goes silent is the first. A target that is down, a timer
+that was stopped, a network that fails and an attacker who stopped the
+export look the same from the backend: nothing arrives. A rule cannot
+match an event that does not exist, so the query compares the last
+keepalive of every target it knows against the current time. It knows
+the targets that reported within a longer window, such as a day, so a
+target silent for longer drops out of the alert. A
+keepalive runs five seconds after the previous run ends and may wait up
+to 30 seconds for the config operation lock, so two minutes without one
+spans several missed intervals.
+
+A verdict other than ``ok`` is the second. The keepalive's severity
+follows the verdict, ``WARN`` or ``ERROR``, so a rule on severity
+catches the same records.
+
+A rise of ``shirudo.tamper_attempts`` is the third. The attribute counts
+the refusals of the guards since boot, so a rise means something on the
+target tried an operation the guards refused. The counters start at
+zero each boot. A rule that took the largest count in a window minus the
+smallest would fire on every reboot. The examples subtract the earliest
+count from the latest instead, which a reboot makes negative. The price
+is that a rise close to a reboot can go unreported; the count in each
+keepalive still shows it.
+
+Map snapshots carry what upatches observe, such as the programs that
+``kernel-obs`` saw run. Their fields depend on the upatch's decoder, so
+rules on them are written per upatch. The host name and the time of a
+record join it to events from other sources.
+
+Volume
+------
+
+The keepalive's body includes the system section, and with it the
+kernel configuration, so a keepalive from a distribution kernel is a
+few hundred kilobytes. At one keepalive every five seconds that adds up
+to several gigabytes a day for each target. That matters to a SIEM
+priced or capped by ingested volume, and to backends that limit the size
+of a record or the rate of a stream. Dropping the kernel configuration
+at the collector cuts a keepalive to a few kilobytes, and
+``kernel_release`` and ``kernel_build_id`` still name the kernel.
+
+Limits
+------
+
+Telemetry is the target's own account of itself. It is not signed and
+not bound to the TPM, and root on a target can stop it or send a
+keepalive that reports ``ok`` with no refusals. A SIEM alert on a
+keepalive tells you where to look. The silence alert catches a target
+whose export was stopped, but not one whose root sends forged
+keepalives instead.
+
+Evidence of what a target runs is the TPM-signed record that ``shirudo
+attest`` produces and ``shirudo attest verify`` checks on the operator
+host, described in :doc:`/operate/run/attest`.
+
+Related
+-------
+
+- :doc:`opentelemetry` for the records and the protocol
+- :doc:`/operate/run/telemetry` to set up export on a target
+- :doc:`/operate/integrations/index` for the backend examples
+- :doc:`/reference/formats/otlp` for every field a target sends
diff --git a/Documentation/operate/index.rst b/Documentation/operate/index.rst
index 05ce86ef..34933cf8 100644
--- a/Documentation/operate/index.rst
+++ b/Documentation/operate/index.rst
@@ -24,8 +24,8 @@ refusal or verdict is an incident: follow
initialized target
- :doc:`run/index`: deliver packages, read status, export telemetry and
attest targets
-- :doc:`integrations/index`: send telemetry to ClickHouse, Splunk and
- Grafana
+- :doc:`integrations/index`: send telemetry to ClickHouse,
+ Elasticsearch, Grafana and Splunk
- :doc:`maintain/index`: signing keys, upgrades, backup, recovery and
decommissioning
- :doc:`troubleshoot/index`: failures by symptom, tampered targets and bug
diff --git a/Documentation/operate/integrations/clickhouse.rst b/Documentation/operate/integrations/clickhouse.rst
index b8b16235..74c85fe9 100644
--- a/Documentation/operate/integrations/clickhouse.rst
+++ b/Documentation/operate/integrations/clickhouse.rst
@@ -13,6 +13,10 @@ through the OpenTelemetry Collector's ClickHouse exporter. The exporter
writes OTLP logs to one table and each kind of metric to a table of its
own.
+This is a do-it-yourself example to get started from, not an
+integration that shirudo ships or maintains. Adapt retention, access
+control and sizing to your deployment.
+
Before you begin
----------------
@@ -24,7 +28,7 @@ Before you begin
ClickHouse exporter; Go 1.24 offers the hybrid key exchange the
targets require.
- A ClickHouse server the collector can reach, and a user for the
- collector that may create tables in its database and insert into
+ collector that may create its database and tables and insert into
them.
The exporter's log support is beta and its metric support alpha.
@@ -38,7 +42,7 @@ Set up the exporter
CREATE DATABASE shirudo;
CREATE USER otel IDENTIFIED BY '<password>';
- GRANT CREATE TABLE, INSERT, SELECT ON shirudo.* TO otel;
+ GRANT CREATE DATABASE, CREATE TABLE, INSERT, SELECT ON shirudo.* TO otel;
#. Add the exporter and the pipelines to the collector's configuration,
next to the ``otlp`` receiver:
@@ -69,7 +73,10 @@ Set up the exporter
``create_schema`` lets the exporter create its tables, ``otel_logs``
for logs and ``otel_metrics_gauge``, ``otel_metrics_sum`` and their
- siblings for metrics. Set it to ``false`` to create them yourself.
+ siblings for metrics. It also runs ``CREATE DATABASE IF NOT EXISTS``
+ at every start, which needs the ``CREATE DATABASE`` grant even though
+ the database exists. Set it to ``false`` to create the tables
+ yourself.
``ttl`` drops rows older than 30 days. ``CLICKHOUSE_PASSWORD`` comes
from the collector's environment.
@@ -124,6 +131,63 @@ Check the data
when the upatch ships no decoder. A decoder that emits metrics writes
to the metric tables instead.
+Alert on the data
+-----------------
+
+Each query below returns one row for every target that needs a look,
+so an alert fires when a query returns rows. Run them on a schedule,
+from Grafana with its ClickHouse data source or from any tool that can
+run SQL. :doc:`/operate/run/telemetry` explains each signal under what
+to alert on.
+
+#. Find targets that stopped sending keepalives. Two minutes covers
+ several keepalive intervals and the 30 seconds a keepalive may wait
+ for the config operation lock:
+
+ .. code-block:: sql
+
+ SELECT ResourceAttributes['host.name'] AS host,
+ max(Timestamp) AS last_seen
+ FROM shirudo.otel_logs
+ WHERE ServiceName = 'shirudo' AND EventName = 'shirudo.keepalive'
+ GROUP BY host
+ HAVING last_seen < now() - INTERVAL 2 MINUTE;
+
+#. Find targets that reported a verdict other than ``ok`` in the last
+ five minutes:
+
+ .. code-block:: sql
+
+ SELECT ResourceAttributes['host.name'] AS host,
+ LogAttributes['shirudo.status'] AS status,
+ max(Timestamp) AS last_seen
+ FROM shirudo.otel_logs
+ WHERE ServiceName = 'shirudo' AND EventName = 'shirudo.keepalive'
+ AND Timestamp > now() - INTERVAL 5 MINUTE
+ AND LogAttributes['shirudo.status'] != 'ok'
+ GROUP BY host, status;
+
+#. Find targets whose guards refused operations in the last ten
+ minutes:
+
+ .. code-block:: sql
+
+ SELECT ResourceAttributes['host.name'] AS host,
+ argMax(toInt64OrZero(LogAttributes['shirudo.tamper_attempts']), Timestamp)
+ - argMin(toInt64OrZero(LogAttributes['shirudo.tamper_attempts']), Timestamp)
+ AS new_attempts
+ FROM shirudo.otel_logs
+ WHERE ServiceName = 'shirudo' AND EventName = 'shirudo.keepalive'
+ AND Timestamp > now() - INTERVAL 10 MINUTE
+ GROUP BY host
+ HAVING new_attempts > 0;
+
+ The query subtracts the earliest count in the window from the latest.
+ The counters start at zero each boot, so a target that rebooted in
+ the window yields a negative difference and no row, where the
+ difference between the largest and smallest count would report every
+ reboot.
+
Next steps
----------
@@ -131,3 +195,5 @@ Next steps
- :doc:`/upatches/write/decoders` to turn a map into log records or
metrics
- :doc:`grafana` to chart the same data
+- :doc:`/concepts/background/siem-export` for how the records reach a
+ backend and what to build on them
diff --git a/Documentation/operate/integrations/elasticsearch.rst b/Documentation/operate/integrations/elasticsearch.rst
new file mode 100644
index 00000000..157b7b7c
--- /dev/null
+++ b/Documentation/operate/integrations/elasticsearch.rst
@@ -0,0 +1,192 @@
+..
+ SPDX-License-Identifier: BSD-2-Clause
+ Copyright (c) 2026 Authors of shirudo
+
+:page-type: How-to
+:audience: Operators, SecOps
+
+Export to Elasticsearch
+=======================
+
+Index the keepalives, map snapshots and decoder metrics of your targets
+in Elasticsearch, through the OpenTelemetry Collector's Elasticsearch
+exporter, and alert on them from Kibana or Elastic Security.
+
+This is a do-it-yourself example to get started from, not an
+integration that shirudo ships or maintains. Adapt retention, access
+control and sizing to your deployment.
+
+Before you begin
+----------------
+
+- Targets that export to a collector, as
+ :doc:`/operate/run/telemetry` describes, with the collector's ``otlp``
+ receiver set up there.
+- The OpenTelemetry Collector Contrib distribution, ``otelcol-contrib``,
+ built with Go 1.24 or later. The contrib distribution includes the
+ Elasticsearch exporter; Go 1.24 offers the hybrid key exchange the
+ targets require.
+- Elasticsearch 9.4 or later, whose ES|QL has the ``FIRST`` and ``LAST``
+ functions that the alert on tamper attempts uses, and Kibana.
+
+The exporter's log and metric support is beta.
+
+Set up the exporter
+-------------------
+
+#. In Kibana's Dev Tools console, create an API key that may only write
+ to the data streams the exporter uses:
+
+ .. code-block:: text
+
+ POST /_security/api_key
+ {
+ "name": "shirudo-otel",
+ "role_descriptors": {
+ "shirudo-otel": {
+ "indices": [
+ {
+ "names": ["logs-*.otel-*", "metrics-*.otel-*"],
+ "privileges": ["auto_configure", "create_doc"]
+ }
+ ]
+ }
+ }
+ }
+
+ Keep the ``encoded`` value of the answer for the collector.
+
+#. Add the exporter and the pipelines to the collector's configuration,
+ next to the ``otlp`` receiver:
+
+ .. code-block:: yaml
+
+ exporters:
+ elasticsearch:
+ endpoint: https://<elasticsearch-host>:9200
+ api_key: ${env:ELASTICSEARCH_API_KEY}
+ tls:
+ ca_file: /etc/otelcol/elasticsearch-ca.pem
+
+ service:
+ pipelines:
+ logs:
+ receivers: [otlp]
+ exporters: [elasticsearch]
+ metrics:
+ receivers: [otlp]
+ exporters: [elasticsearch]
+
+ ``ELASTICSEARCH_API_KEY`` holds the encoded key and comes from the
+ collector's environment, and ``ca_file`` names the CA that signed the
+ Elasticsearch certificate.
+
+#. Restart the collector.
+
+The exporter writes in its default ``otel`` mapping mode: log records go
+to the data stream ``logs-generic.otel-default`` and metrics to
+``metrics-generic.otel-default``. A document keeps the OTLP layout, with
+the attributes under ``attributes``, the resource attributes under
+``resource.attributes`` and a structured body under ``body.structured``.
+Elasticsearch's OpenTelemetry templates also offer each attribute under
+its own name, so ``host.name`` and ``shirudo.status`` work in queries.
+
+Check the data
+--------------
+
+#. In Discover, switch to ES|QL and list the latest keepalives:
+
+ .. code-block:: text
+
+ FROM logs-generic.otel-default
+ | WHERE event_name == "shirudo.keepalive"
+ | SORT @timestamp DESC
+ | KEEP @timestamp, host.name, shirudo.status, shirudo.tamper_attempts
+ | LIMIT 10
+
+ A target sends a keepalive every few seconds, so each target shows up
+ within a minute of the restart.
+
+#. Show the last verdict of every target and when it last reported:
+
+ .. code-block:: text
+
+ FROM logs-generic.otel-default
+ | WHERE event_name == "shirudo.keepalive"
+ | STATS status = LAST(shirudo.status, @timestamp),
+ last_seen = MAX(@timestamp) BY host.name
+ | SORT last_seen
+
+#. Read the map snapshots of one upatch:
+
+ .. code-block:: text
+
+ FROM logs-generic.otel-default
+ | WHERE shirudo.upatch.name == "<upatch>"
+ | KEEP @timestamp, host.name, shirudo.map.name, body.structured
+
+ ``body.structured`` holds what the map's decoder returned, or the
+ map's entries when the upatch ships no decoder. ES|QL returns it
+ whole and cannot select a field inside it. A decoder that emits
+ metrics writes to ``metrics-generic.otel-default``, with one field
+ per metric.
+
+Alert on the data
+-----------------
+
+Each query below returns one row for every target that needs a look.
+In Kibana, create an Elasticsearch query rule for each, with ES|QL as
+the query type, ``@timestamp`` as the time field and a time window at
+least as long as the query's; the rule alerts when the query returns
+rows. In Elastic Security, use the query in a detection rule of type
+ES|QL instead. :doc:`/operate/run/telemetry` explains each signal under
+what to alert on.
+
+#. Find targets that stopped sending keepalives. Two minutes covers
+ several keepalive intervals and the 30 seconds a keepalive may wait
+ for the config operation lock:
+
+ .. code-block:: text
+
+ FROM logs-generic.otel-default
+ | WHERE event_name == "shirudo.keepalive" AND @timestamp > NOW() - 1 day
+ | STATS last_seen = MAX(@timestamp) BY host.name
+ | WHERE last_seen < NOW() - 2 minutes
+
+ A target silent for longer than a day drops out of the query.
+
+#. Find targets that reported a verdict other than ``ok`` in the last
+ five minutes:
+
+ .. code-block:: text
+
+ FROM logs-generic.otel-default
+ | WHERE event_name == "shirudo.keepalive" AND @timestamp > NOW() - 5 minutes
+ AND shirudo.status != "ok"
+ | STATS reports = COUNT(*) BY host.name, shirudo.status
+
+#. Find targets whose guards refused operations in the last ten
+ minutes:
+
+ .. code-block:: text
+
+ FROM logs-generic.otel-default
+ | WHERE event_name == "shirudo.keepalive" AND @timestamp > NOW() - 10 minutes
+ AND shirudo.tamper_attempts IS NOT NULL
+ | STATS first_count = FIRST(shirudo.tamper_attempts, @timestamp),
+ last_count = LAST(shirudo.tamper_attempts, @timestamp) BY host.name
+ | EVAL new_attempts = last_count - first_count
+ | WHERE new_attempts > 0
+
+ The query subtracts the earliest count in the window from the latest.
+ The counters start at zero each boot, so a reboot in the window gives
+ a negative difference and no row.
+
+Next steps
+----------
+
+- :doc:`/reference/formats/otlp` for every field a target sends
+- :doc:`/upatches/write/decoders` to turn a map into log records or
+ metrics
+- :doc:`/concepts/background/siem-export` for how the records reach a
+ backend and what to build on them
diff --git a/Documentation/operate/integrations/grafana.rst b/Documentation/operate/integrations/grafana.rst
index b69a62c8..c3a1661c 100644
--- a/Documentation/operate/integrations/grafana.rst
+++ b/Documentation/operate/integrations/grafana.rst
@@ -13,6 +13,10 @@ Grafana, with the log records in Loki and the metrics in Prometheus. Both
accept OTLP directly, so the collector forwards to them with its
``otlphttp`` exporter.
+This is a do-it-yourself example to get started from, not an
+integration that shirudo ships or maintains. Adapt retention, access
+control and sizing to your deployment.
+
Before you begin
----------------
@@ -28,13 +32,36 @@ Before you begin
Set up Loki and Prometheus
--------------------------
-#. In Loki's configuration, keep structured metadata on. Loki 3 enables
- it by default; an older configuration may turn it off:
+#. In Loki's configuration, keep structured metadata on, raise the
+ size limit of a log line and make the target's host name a label:
.. code-block:: yaml
limits_config:
allow_structured_metadata: true
+ max_line_size: 4MB
+ otlp_config:
+ resource_attributes:
+ attributes_config:
+ - action: index_label
+ attributes:
+ - host.name
+
+ Loki 3 enables structured metadata by default; an older configuration
+ may turn it off. A keepalive carries the target's kernel
+ configuration, a few hundred kilobytes for a distribution kernel,
+ which can exceed Loki's default limit of 256 KB; Loki then refuses it
+ and the collector drops it. 4 MB is the largest request a target sends,
+ ``map_export.otlp_max_bytes`` by default, so every record fits.
+ Without the label, every target writes to the one stream
+ ``{service_name="shirudo"}`` and shares its rate limit.
+
+ With a distribution kernel, every target sends about 60 KB a second
+ in keepalives, and Loki accepts 4 MB a second per tenant by default.
+ For a fleet of more than a few dozen targets, raise
+ ``ingestion_rate_mb`` and ``ingestion_burst_size_mb``, or drop the
+ kernel configuration at the collector as
+ :doc:`/operate/run/telemetry` shows.
#. Start Prometheus with ``--web.enable-otlp-receiver``, and in
``prometheus.yml`` promote the target's host name to a label and accept
@@ -87,12 +114,18 @@ Check the data
{service_name="shirudo"} | shirudo_status != "" | shirudo_status != "ok"
- Loki turns ``service.name`` into the label ``service_name`` and stores
- the other attributes as structured metadata, with dots turned into
- underscores: ``shirudo.status`` becomes ``shirudo_status`` and
- ``host.name`` becomes ``host_name``. Only keepalives carry
+ Loki turns ``service.name`` and ``host.name`` into the labels
+ ``service_name`` and ``host_name`` and stores the other attributes as
+ structured metadata, with dots turned into underscores:
+ ``shirudo.status`` becomes ``shirudo_status``. Only keepalives carry
``shirudo.status``.
+#. List the keepalives of one target:
+
+ .. code-block:: text
+
+ {service_name="shirudo", host_name="<target>"} | shirudo_status != ""
+
#. Read the map snapshots of one upatch:
.. code-block:: text
@@ -107,6 +140,69 @@ Check the data
Which metrics exist depends on the decoders of the loaded upatches.
+Alert on the data
+-----------------
+
+Alert on the keepalives with rules that Loki's ruler evaluates. Each
+expression returns one series for every target that needs a look.
+:doc:`/operate/run/telemetry` explains each signal under what to alert
+on.
+
+#. Put the rules in a file in the ruler's rule directory, under the
+ tenant's name, ``fake`` when Loki runs without authentication:
+
+ .. code-block:: yaml
+
+ groups:
+ - name: shirudo
+ rules:
+ - alert: ShirudoTargetSilent
+ expr: |
+ sum by (host_name) (count_over_time({service_name="shirudo"} | shirudo_status != "" [1d]))
+ unless
+ sum by (host_name) (count_over_time({service_name="shirudo"} | shirudo_status != "" [2m]))
+ - alert: ShirudoTargetNotOk
+ expr: |
+ sum by (host_name) (count_over_time({service_name="shirudo"} | shirudo_status != "" | shirudo_status != "ok" [5m])) > 0
+ - alert: ShirudoTamperAttempts
+ expr: |
+ last_over_time({service_name="shirudo"} | shirudo_tamper_attempts != "" | unwrap shirudo_tamper_attempts [10m]) by (host_name)
+ -
+ first_over_time({service_name="shirudo"} | shirudo_tamper_attempts != "" | unwrap shirudo_tamper_attempts [10m]) by (host_name)
+ > 0
+
+ ``ShirudoTargetSilent`` fires for a target that sent keepalives in
+ the last day but none in the last two minutes, which covers several
+ keepalive intervals and the 30 seconds a keepalive may wait for the
+ config operation lock. A target silent for longer than a day drops
+ out of the rule. ``ShirudoTargetNotOk`` fires for a verdict other
+ than ``ok`` in the last five minutes. ``ShirudoTamperAttempts``
+ subtracts the earliest refusal count in ten minutes from the latest.
+ The counters start at zero each boot, so a reboot in the window gives
+ a negative difference and no alert.
+
+#. Point the ruler at the directory and at your Alertmanager in Loki's
+ configuration:
+
+ .. code-block:: yaml
+
+ ruler:
+ storage:
+ type: local
+ local:
+ directory: /etc/loki/rules
+ rule_path: /var/lib/loki/rules-temp
+ alertmanager_url: http://<alertmanager-host>:9093
+
+#. Restart Loki and list the alerts:
+
+ .. code-block:: console
+
+ $ curl -s http://<loki-host>:3100/prometheus/api/v1/alerts
+
+The same expressions work as queries of Grafana-managed alert rules
+with the Loki data source.
+
Next steps
----------
@@ -114,3 +210,5 @@ Next steps
- :doc:`/upatches/write/decoders` to turn a map into log records or
metrics
- :doc:`clickhouse` to keep the records for longer analysis
+- :doc:`/concepts/background/siem-export` for how the records reach a
+ backend and what to build on them
diff --git a/Documentation/operate/integrations/index.rst b/Documentation/operate/integrations/index.rst
index f1b06edc..37ebfaf8 100644
--- a/Documentation/operate/integrations/index.rst
+++ b/Documentation/operate/integrations/index.rst
@@ -5,16 +5,30 @@
Integrations
============
-Send what targets export into the tools you already run. Targets speak
-OTLP over HTTP with JSON bodies and TLS 1.3 with a hybrid post-quantum
-key exchange, and nothing else. Each page puts an OpenTelemetry Collector
-between the targets and one backend: the collector accepts the targets'
-requests, batches and retries, and speaks the backend's own protocol
-over ordinary TLS, so the backend needs no post-quantum support.
+Send what targets export into the tools you already run. These pages
+are do-it-yourself examples to get started from, not integrations that
+shirudo ships or maintains. Each one gives a collector configuration for
+one backend, queries that show the records arrive, and alerts for a
+target that goes silent, reports a verdict other than ``ok`` or counts
+tamper attempts. Adapt them to your deployment.
+
+Splunk and Elastic Security are SIEMs, ClickHouse keeps records for
+analysis in SQL, and Grafana charts them from Loki and Prometheus.
+
+Targets speak OTLP over HTTP with JSON bodies and TLS 1.3 with a hybrid
+post-quantum key exchange, and nothing else. Each page puts an
+OpenTelemetry Collector between the targets and one backend: the
+collector accepts the targets' requests, batches and retries, and speaks
+the backend's own protocol over ordinary TLS, so the backend needs no
+post-quantum support.
.. toctree::
:titlesonly:
clickhouse
- splunk
+ elasticsearch
grafana
+ splunk
+
+:doc:`/concepts/background/siem-export` explains how the records reach a
+backend and what to build on them.
diff --git a/Documentation/operate/integrations/splunk.rst b/Documentation/operate/integrations/splunk.rst
index d4b8018a..76290ffa 100644
--- a/Documentation/operate/integrations/splunk.rst
+++ b/Documentation/operate/integrations/splunk.rst
@@ -12,6 +12,10 @@ Index the keepalives and map snapshots of your targets in Splunk,
through the OpenTelemetry Collector's Splunk HEC exporter, which sends to
Splunk's HTTP Event Collector.
+This is a do-it-yourself example to get started from, not an
+integration that shirudo ships or maintains. Adapt retention, access
+control and sizing to your deployment.
+
Before you begin
----------------
@@ -64,7 +68,10 @@ Set up the exporter
``ca_file`` names the CA that signed the HEC endpoint's certificate.
The exporter takes each event's host from the ``host.name`` resource
attribute, so every event carries the name of the target that sent
- it.
+ it. The record's body becomes the event, and its attributes become
+ indexed fields under their own names, ``shirudo.status`` and
+ ``shirudo.tamper_attempts`` among them, next to ``otel.log.name``
+ for the event name.
#. Restart the collector.
@@ -89,8 +96,54 @@ Check the data
| sort last_seen
A target at the top whose ``last_seen`` falls behind has stopped
- sending. :doc:`/operate/run/telemetry` describes what else to alert
- on.
+ sending.
+
+Alert on the data
+-----------------
+
+Each search below returns one row for every target that needs a look.
+Save each one as an alert that runs every few minutes and triggers when
+the number of results is greater than zero.
+:doc:`/operate/run/telemetry` explains each signal under what to alert
+on.
+
+#. Find targets that stopped sending. Two minutes covers several
+ keepalive intervals and the 30 seconds a keepalive may wait for the
+ config operation lock:
+
+ .. code-block:: text
+
+ | tstats latest(_time) AS last_seen
+ WHERE index=shirudo sourcetype=shirudo earliest=-1d BY host
+ | where last_seen < relative_time(now(), "-2m")
+
+ A target silent for longer than a day drops out of the search.
+
+#. Find targets that reported a verdict other than ``ok`` in the last
+ five minutes:
+
+ .. code-block:: text
+
+ index=shirudo sourcetype=shirudo shirudo.status!=ok earliest=-5m
+ | stats count AS reports BY host, shirudo.status
+
+ ``!=`` matches only events that carry the field, so map snapshots
+ do not match.
+
+#. Find targets whose guards refused operations in the last ten
+ minutes:
+
+ .. code-block:: text
+
+ index=shirudo sourcetype=shirudo shirudo.tamper_attempts=* earliest=-10m
+ | stats earliest(shirudo.tamper_attempts) AS first_count,
+ latest(shirudo.tamper_attempts) AS last_count BY host
+ | eval new_attempts = last_count - first_count
+ | where new_attempts > 0
+
+ The search subtracts the earliest count in the window from the
+ latest. The counters start at zero each boot, so a reboot in the
+ window gives a negative difference and no row.
Next steps
----------
@@ -98,3 +151,5 @@ Next steps
- :doc:`/reference/formats/otlp` for every field a target sends
- :doc:`/upatches/write/decoders` to turn a map into log records or
metrics
+- :doc:`/concepts/background/siem-export` for how the records reach a
+ backend and what to build on them
diff --git a/Documentation/operate/run/telemetry.rst b/Documentation/operate/run/telemetry.rst
index 63f71bc7..3269a8ec 100644
--- a/Documentation/operate/run/telemetry.rst
+++ b/Documentation/operate/run/telemetry.rst
@@ -47,7 +47,9 @@ The keepalive record has the event name ``shirudo.keepalive``. Its body
is the ``shirudo status --json`` document with the system section, and
its attributes are ``shirudo.status`` (the verdict),
``shirudo.version_id`` and ``shirudo.tamper_attempts`` (the refusals the
-guards counted this boot). Its severity follows the verdict:
+guards counted this boot). The system section includes the kernel
+configuration, so a keepalive from a distribution kernel is a few hundred
+kilobytes. Its severity follows the verdict:
.. list-table::
:header-rows: 1
@@ -266,9 +268,35 @@ reboot.
The ``debug`` exporter prints what arrives. Replace it with the
exporters for your storage once records arrive;
- :doc:`/operate/integrations/index` sets up ClickHouse, Splunk and
- Grafana. A collector built
- with Go 1.24 or later offers ``X25519MLKEM768`` by default.
+ :doc:`/operate/integrations/index` sets up ClickHouse, Elasticsearch,
+ Grafana and Splunk. A collector built with Go 1.24 or later offers
+ ``X25519MLKEM768`` by default.
+
+#. Optionally, drop the kernel configuration from the keepalives before
+ the collector exports them. It makes up most of a keepalive, and
+ every keepalive repeats it:
+
+ .. code-block:: yaml
+
+ processors:
+ transform/drop-kernel-config:
+ log_statements:
+ - context: log
+ conditions:
+ - log.event_name == "shirudo.keepalive"
+ statements:
+ - delete_key(log.body["system"], "kernel_config")
+
+ service:
+ pipelines:
+ logs:
+ receivers: [otlp]
+ processors: [transform/drop-kernel-config]
+ exporters: [debug]
+
+ The ``transform`` processor is part of the contrib distribution,
+ ``otelcol-contrib``. ``kernel_release`` and ``kernel_build_id`` stay
+ in the system section and still name the kernel.
#. Restart the collector.