rsigma engine eval

rsigma engine eval

Added in v0.12.0

One-shot evaluation of Sigma rules against events from a file, stdin, or an inline argument.

Synopsis

rsigma engine eval [OPTIONS] [--rules <RULES> | --ruleset <NAME> [--ruleset <NAME> ...]]

Description

Loads rules from a file or directory, optionally applies one or more processing pipelines, reads events from --event (or stdin), and writes matched EvaluationResult JSON to stdout. Exits when the event source is exhausted.

Each run starts with empty correlation state. To carry correlation windows between runs, use daemon batch runs.

This is the right tool for ad-hoc threat hunting, forensic replay over .evtx and NDJSON files, and any “run rules against this data, then exit” workflow. For a long-running daemon with hot-reload and metrics, use engine daemon. For per-rule assertions over a corpus (a CI fixture harness with expected-vs-actual fire counts and a JUnit report), use rule backtest.

For a narrative tutorial see Evaluating Rules.

Flags

Required

Flag Description
-r, --rules <RULES> Path to a Sigma rule file or directory of rules (recursive). May also be supplied via eval.rules in a config file. Conflicts with --ruleset.
--ruleset <NAME> Named ruleset from the configuration to evaluate. Repeatable: several rulesets are evaluated side by side and every result carries its ruleset name. May also be supplied via eval.ruleset (one name) or eval.rulesets (several names, with optional when schema bindings). Conflicts with --rules. Unreleased

Configuration

Flag Default Description
--config <PATH> unset Load a specific YAML config file instead of running the discovery chain. CLI flags still take precedence over file values.
--dry-run off Print the effective eval section (defaults < file < env) and exit 0 without evaluating anything.

Input selection

Flag Default Description
-e, --event <EVENT> stdin Single event as a JSON string, or @path to read NDJSON or .evtx. Without this flag, reads NDJSON from stdin.
--jq <JQ> unset jq filter to extract the event payload from each input object. Example: --jq '.event', --jq '.records[]'. Mutually exclusive with --jsonpath. The env builtin is not available. Added in v0.27.0
--jsonpath <JSONPATH> unset JSONPath (RFC 9535) query to extract the event payload. Example: --jsonpath '$.event', --jsonpath '$.records[*]'.
--input-format <FORMAT> auto Input log format: auto, json, syslog, plain. With the logfmt and cef features: also logfmt, cef.
--syslog-tz <OFFSET> +00:00 Timezone offset for RFC 3164 syslog parsing. Format: +HH:MM or -HH:MM.
--syslog-strip-bom <BOOL> true Strip a leading UTF-8 BOM (U+FEFF) from RFC 5424 syslog messages. RFC 5424 treats the BOM as an encoding marker, not content. Pass --syslog-strip-bom false to keep it byte-for-byte.

Pipeline

Flag Description
-p, --pipeline <PIPELINES> Processing pipeline(s) to apply. Accepts the builtin names (ecs_windows, ecs_linux, fibratus_windows, sysmon) or YAML file paths. Repeatable; applied in priority order.

Dynamic sources referenced by pipelines are not resolved by engine eval. Dynamic references stay unresolved and a stderr note points you at pipeline resolve or engine daemon.

Output

The global --output-format, --color, --quiet, and --no-stats flags apply here too; see Output Formats. The flags below are eval-specific.

Flag Default Description
-o, --output <PATH> stdout Write detection and correlation results to a file instead of stdout. The file is created or truncated at start and flushed on exit, including when --fail-on-detection exits with code 1. Results use --output-format when set and NDJSON otherwise; --pretty still applies. The summary and diagnostics stay on stderr. Config key: eval.output. Added in v0.25.0
--finding-format <FORMAT> native native or ocsf. ocsf emits one class-2004 Detection Finding per match and composes with json or ndjson. table, csv, and tsv are a config error. Config key: eval.finding_format. Unreleased
--ocsf-version <VERSION> 1.1.0 1.1.0 or 1.3.0. Requires --finding-format ocsf. Config key: eval.ocsf_version. Unreleased
--pretty off Pretty-print JSON output. Kept for backwards compatibility; equivalent to --output-format json with pretty-printing on.
--emit-detections off Emit output for rules that only feed correlations, including correlations referenced by another correlation. By default, referenced rules are emitted only when a referencing correlation has top-level generate: true. Added in v0.24.0
--no-detections off Deprecated compatibility flag. Correlation-only detections are suppressed by default.
--include-event off Embed the full event JSON in every EvaluationResult. Equivalent to setting rsigma.include_event: "true" per-rule.
--match-detail <LEVEL> off Match-detail verbosity: off (field + value only), summary (adds matcher kind, selection, case sensitivity, and reports keyword/absence matches), or full (also records the matched pattern). See Evaluating Rules.

Correlation behavior

Flag Default Description
--suppress <DURATION> unset Suppress duplicate correlation alerts within the window (5m, 1h, 30s).
--action <ACTION> alert Post-fire action for correlations: alert (keep state, re-alert on next match) or reset (clear window state).
--correlation-event-mode <MODE> none Whether to embed contributing events in correlation output: none, full (deflate-compressed full bodies), refs (timestamp + ID only). Results with events also carry event_sources, and chained correlations carry the events their child correlations retained. Unreleased
--max-correlation-events <N> 10 Cap on stored events per correlation window when --correlation-event-mode is not none. Oldest evicted. A chained parent applies its own cap to the events its children deliver. Unreleased
--max-state-entries <N> 100000 Hard cap on correlation state entries across all correlations and group keys. When reached, the stalest entries are evicted to 90% capacity and a warning is logged.
--max-group-entries <N> unset Cap on retained entries within a single correlation group’s window state. Bounds within-window growth of chatty groups; oldest entries are dropped (session windows keep their span anchor). Unset = unbounded. Equivalent to the rsigma.max_group_entries custom attribute.
--timestamp-field <FIELD> unset Field name to prepend to the timestamp extraction priority list. Default list: @timestamp, timestamp, EventTime, TimeCreated, eventTime. Repeatable.
--dump-correlation-state off After replaying all events, print the final correlation window state (per correlation and group: current aggregate vs threshold, window entries, last alert, seconds to eviction) to stderr as JSON, for offline “why didn’t it fire?” diagnosis. Correlation mode only; ignored with --schema-routing. In ruleset mode the output is keyed by ruleset name, even with one ruleset, and it is printed with --schema-routing too and for rulesets without correlations. Unreleased

Performance (advanced)

Flag Default Description
--bloom-prefilter off Enable per-field bloom filter over positive substring needles. Useful for IOC-heavy rule sets against mostly-non-matching telemetry. See Performance Tuning.
--bloom-max-bytes <BYTES> 1048576 Memory budget for the bloom index (1 MiB default). No effect without --bloom-prefilter.
--cross-rule-ac off Enable the cross-rule Aho-Corasick pre-filter. Available when compiled with the daachorse-index Cargo feature. See Performance Tuning.

Field observability (offline coverage report)

The same gap and broken-coverage signals exposed by the daemon’s /api/v1/fields* endpoints are available offline as a one-shot report:

Flag Default Description
--observe-fields off Record the field keys of every evaluated event and emit a coverage report at end-of-run. The report has the same JSON shape as GET /api/v1/fields, so the same jq queries work against either runtime (suited for CI gap analysis).
--observe-fields-max-keys <N> 10000 Hard ceiling on distinct field names tracked. New keys are dropped after the cap (and counted via overflow_dropped in the report).
--observe-fields-report <PATH> unset Write the report to a file. When omitted (and --observe-fields is set), the report goes to stderr so detections on stdout stay machine-consumable.
# CI: keep stdout for detection NDJSON, stderr for logs, report in its own file
rsigma engine eval -r rules/ -e @events.ndjson \
    --observe-fields \
    --observe-fields-report coverage.json

# Quick interactive run: the report shows up on stderr alongside the
# "Processed N events, M matches." line
rsigma engine eval -r rules/ -e @events.ndjson --observe-fields

See Observability: detection coverage for the operator workflow shared with the daemon path.

Schema routing

Recognize each event’s schema and evaluate it against the pipeline-set bound to that schema (instead of applying one pipeline set to every event). See the Schema Routing guide.

Flag Default Description
--schema-routing off Classify each event and route it to its schema’s bound pipeline-set; detections feed one shared correlation store.
--schema-config <PATH> unset YAML with the schemas: signatures and routing: bindings (bindings, default_pipelines, on_unknown).
--schema-partition-rules off Gated: compile each platform-locked per-schema engine with only the rules whose product can apply. See Per-schema rule partitioning.
--on-unknown <POLICY> warn Policy for events that match no schema: warn, drop, passthrough, or error. Overrides the config value.

These flags may also be supplied via the eval.schema block in a config file (routing, config, on_unknown); a flag always wins over the file.

Logsource-aware evaluation

Skip rules whose product/service/category conflicts with the event’s declared logsource. Conflict-based and fail-open. See the Logsource-Aware Evaluation guide.

Flag Default Description
--logsource-routing off Enable conflict-based logsource pruning.
--logsource-field-map <MAP> product=product,service=service,category=category Event field names each dimension is read from, as product=...,service=...,category=....
--event-logsource <LOGSOURCE> unset Static event logsource applied when the field is absent, as product=windows,.... An -e @file.evtx input implies product: windows when unset.

These flags may also be supplied via the eval.logsource_routing block in a config file (enabled, field_map, event_logsource); a flag always wins over the file.

CI gating

Flag Description
--fail-on-detection Exit with code 1 when any detection or correlation fires.

Several rulesets

Unreleased

Repeat --ruleset to evaluate several named rulesets over the same events. Each ruleset is resolved independently and keeps its own pipelines and correlation state. Every result carries a ruleset field, and the table, CSV, and TSV views gain a leading RULESET column.

rsigma engine eval --ruleset win_a --ruleset win_b --event @events.ndjson

The configuration can supply the list, including schema bindings:

rulesets:
  win_a:
    sources: [rules/windows]
  cloud:
    sources: [rules/cloud]

eval:
  rulesets:
    - win_a
    - name: cloud
      when:
        schemas: [aws_cloudtrail]

when binds a ruleset to schema names. A bound ruleset receives only events whose classified schema matches, and events with no classified schema reach only unbound rulesets. A CLI --ruleset list replaces the configured list and carries no when. Setting eval.ruleset and eval.rulesets together, or either with eval.rules, is a configuration error.

--schema-routing is allowed with exactly one ruleset, and only when that ruleset declares no pipelines. --stats adds one line per ruleset with detection matches, correlation matches, and, for bound rulesets, skipped events.

Examples

Single inline event

rsigma engine eval -r rules/ -e '{"CommandLine":"cmd /c whoami"}'

NDJSON file with pretty output

rsigma engine eval -r rules/ --pretty -e @events.ndjson

Table view for interactive triage

rsigma engine eval -r rules/ -e @events.ndjson --output-format table

A width-aligned LEVEL | RULE | TYPE | DETAIL table appears on stdout. Use --output-format csv or --output-format tsv to pipe into a spreadsheet instead. See Output Formats.

Use --finding-format ocsf when a downstream collector expects OCSF Detection Finding JSON: stdout receives one class-2004 object per match (compact NDJSON), using the same serializer as the daemon’s ?format=ocsf sink. Add --ocsf-version 1.3.0 to select the other pinned schema. The flag composes with --output-format json or ndjson and is rejected with table, csv, or tsv. Unreleased

EVTX file (Windows Event Log)

rsigma engine eval -r rules/ -e @Security.evtx
rsigma engine eval -r rules/ -p sysmon -e @Microsoft-Windows-Sysmon%4Operational.evtx

Requires the evtx feature (included in release binaries and the Docker image). Records keep the nested Event.System.*/Event.EventData.* shape from the Windows XML; rules must use those full dotted paths. The builtin sysmon and ecs_windows pipelines do not flatten that nested EVTX shape; they help once events are already flat (or for Sysmon EventID routing on flat fields). See Input Formats.

Tail a JSON log file into the engine

tail -F /var/log/app.json | rsigma engine eval -r rules/

Extract events from a wrapper envelope

rsigma engine eval -r rules/ --jq '.records[]' < otlp-batch.ndjson

CI fixture: assert nothing matches

rsigma engine eval -r rules/ --fail-on-detection -e @ci/negative.ndjson

Exits 1 if any rule fires. Exits 0 if the fixture stays quiet.

Apply a builtin pipeline

rsigma engine eval -r rules/ -p ecs_windows -e '{"process.command_line": "whoami"}'

Correlation with suppression

rsigma engine eval -r rules/ --suppress 5m --action reset \
    --correlation-event-mode refs --max-correlation-events 50 \
    < security-events.ndjson

Exit codes

Code Meaning
0 Events processed cleanly. With --fail-on-detection, no rule fired. Per-rule parse errors are logged as warnings but do not change the exit code.
1 With --fail-on-detection, at least one detection or correlation fired.
2 The rules path or --event @path file could not be read. Use rule validate for a strict per-rule gate that fails on parse or compile errors.
3 Configuration error: missing --rules/--ruleset/eval.rules/eval.ruleset/eval.rulesets, an unknown or broken ruleset, a duplicate name, an unknown when schema, an invalid schema-routing combination, bad -p, malformed --suppress, invalid --jq filter, bad logsource options, etc.

See also