Conversation
When per-rule converted queries are available, non-temporal correlation types (event_count, value_count, value_sum, value_avg, etc.) now wrap the referenced rules' queries in a WITH combined_events AS (q1 UNION ALL q2 ...) CTE. The aggregate then reads from combined_events instead of scanning the entire table unfiltered. This makes correlation queries self-contained: they only aggregate over rows that match the referenced detection rules, rather than all rows in the time window. Inspired by the pySigma Athena backend's combined_events CTE pattern. When no per-rule queries are available (standalone correlation rules), the backend falls back to the previous full-table scan with time filter.
…lations
Add a new output format that uses SQL window functions for event_count
correlation queries, producing a per-row sliding window that emits
every event crossing the threshold within its trailing window:
WITH combined_events AS (...),
event_counts AS (
SELECT *, COUNT(*) OVER (
PARTITION BY group_by
ORDER BY time
RANGE BETWEEN INTERVAL 'N' SECOND PRECEDING AND CURRENT ROW
) AS correlation_event_count
FROM combined_events
)
SELECT * FROM event_counts WHERE correlation_event_count >= threshold
The existing GROUP BY + HAVING approach remains the default, since both
have valid use cases (GROUP BY for periodic polling, window functions
for streaming/alerting).
Inspired by the pySigma Athena backend's window function pattern.
Add documentation for SELECT column selection, CLI backend options (-O key=value), CTE-based correlation pre-filtering, and the sliding_window output format. Update output format tables and CLI example sections in both the root README and rsigma-convert README.
Add paths-ignore to ci.yml so that pushes and PRs that only touch markdown files, docs, assets, LICENSE, or .gitignore do not trigger the full CI suite unnecessarily.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Inspired by the pySigma Athena backend, this PR adds two correlation improvements to the PostgreSQL backend:
CTE-based pre-filtering: non-temporal correlation types (
event_count,value_count,value_sum,value_avg, etc.) now wrap referenced rules' queries in aWITH combined_events AS (q1 UNION ALL q2 ...)CTE. The aggregate reads fromcombined_eventsinstead of scanning the entire table unfiltered. When no per-rule queries are available (standalone correlation rules), the backend falls back to the previous full-table scan with time filter.sliding_windowoutput format: a new output format forevent_countcorrelations that uses SQL window functions instead of GROUP BY + HAVING. It produces a per-row sliding window that emits every event crossing the threshold within its trailing window:The existing GROUP BY + HAVING approach remains the
defaultformat.Also includes:
ci.ymlnow skips runs for markdown, docs, assets, LICENSE, and .gitignore changes.Test plan
cargo fmt --all -- --checkpassescargo clippy --workspace --all-targets --all-features -- -D warningspasses