Sigma
Match log events against Sigma detection rules, check that rules compile, and list the fields they use
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/sigma/index.md to help me query Sigma with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Turn matching log events into security alerts
Example output · captured
- Connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
WITH logs(event_id, event) AS (VALUES (1, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), (2, '{"EventID": 4624, "LogonType": 3, "TargetUserName": "admin"}'), (3, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "svc_backup"}')) SELECT l.event_id, i.title, i.level, i.tags
FROM logs AS l
CROSS JOIN sigma.main.sigma_rule_info('{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS i
WHERE sigma.main.sigma_match(l.event, '{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}')
ORDER BY l.event_id
| event_id | title | level | tags |
|---|---|---|---|
| 1 | Failed Network Logon | medium | ["attack.credential_access", "attack.t1110"] |
| 3 | Failed Network Logon | medium | ["attack.credential_access", "attack.t1110"] |
Quick start
Choose where to run Sigma, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'sigma' AS sigma (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-sigma-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'sigma' AS sigma (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-sigma:0.5.0'
);
3. Run a query
WITH logs(event_id, event) AS (VALUES (1, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), (2, '{"EventID": 4624, "LogonType": 3, "TargetUserName": "admin"}'), (3, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "svc_backup"}')) SELECT l.event_id, i.title, i.level, i.tags
FROM logs AS l
CROSS JOIN sigma.main.sigma_rule_info('{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS i
WHERE sigma.main.sigma_match(l.event, '{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}')
ORDER BY l.event_id
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'sigma' AS sigma
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
WITH logs(event_id, event) AS (VALUES (1, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), (2, '{"EventID": 4624, "LogonType": 3, "TargetUserName": "admin"}'), (3, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "svc_backup"}')) SELECT l.event_id, i.title, i.level, i.tags
FROM logs AS l
CROSS JOIN sigma.main.sigma_rule_info('{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS i
WHERE sigma.main.sigma_match(l.event, '{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}')
ORDER BY l.event_id
Query Farm operates Sigma for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use sigma as the catalog alias for the query below.
4. Run a query
WITH logs(event_id, event) AS (VALUES (1, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), (2, '{"EventID": 4624, "LogonType": 3, "TargetUserName": "admin"}'), (3, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "svc_backup"}')) SELECT l.event_id, i.title, i.level, i.tags
FROM logs AS l
CROSS JOIN sigma.main.sigma_rule_info('{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS i
WHERE sigma.main.sigma_match(l.event, '{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}')
ORDER BY l.event_id
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'sigma' AS sigma (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-sigma-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'sigma' AS sigma (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-sigma:0.5.0'
);
Overview
Evaluate Sigma detection rules against log/event rows for SQL, powered by pySigma

Run Sigma detection rules — the open, vendor-neutral standard for detection-as-code — directly over your log and event tables in SQL, powered by pySigma.
This extension brings SIEM-style threat detection and threat hunting into DuckDB. If you have events as rows (Windows Security logs, EDR telemetry, cloud audit trails, web/proxy logs, or any JSON records), you can take a Sigma rule and ask, per row, "does this event match?" — without exporting data to a separate SIEM. It is built for detection engineers, threat hunters, incident responders, and data engineers who want to test, triage, and measure detection coverage where the data already lives. It is a defensive security tool and part of Query Farm's cyber analytics cluster alongside YARA, IOC, CVE, PE, and X.509 workers.
Under the hood, each rule's YAML is parsed and compiled once by pySigma — the reference Sigma implementation maintained by SigmaHQ — into a boolean condition tree, then evaluated against every row. Compilation is cached by rule text, so a constant rule scanned across a whole log column compiles a single time and only the per-row match runs hot, keeping column scans cheap. The evaluator honors Sigma field modifiers (contains, startswith, endswith, regex, and the rest), wildcard string matching, numeric, boolean and null values, and the full selector grammar (1 of selection_*, all of them, and friends). Rules and their metadata, including MITRE ATT&CK tags, are read straight from the rule text.
The workflow is deliberately simple: keep your events as rows, express detection logic as Sigma YAML, and evaluate one against the other as an ordinary SQL predicate. Because a constant rule compiles once and only the boolean match runs per row, applying a detection across a whole log column stays cheap enough to run interactively. Beyond matching, the catalog also lets you validate a rule library before you trust it, and introspect a rule's header metadata and referenced fields for triage, index planning, and coverage analysis — so a single attached worker covers the detect / validate / plan loop of detection engineering.
A typical hunt applies a matcher predicate per row over a log table (for example in a WHERE clause against to_json(row)), while separate helpers validate that a rule library compiles and introspect rule metadata and referenced fields for planning. A browsable discovery table lists the field modifiers the evaluator supports.
Learn more from the Sigma documentation, the pySigma reference docs, and the pySigma source repository.
Catalog
Everything sigma exposes once attached — read straight from the worker's
released build.
main 1 view · 4 functions
Evaluate, validate, and introspect Sigma detection rules over log/event rows
Schema examples (9)
Does a failed-network-logon event match a brute-force detection rule?
SELECT sigma.main.sigma_match('{"EventID": 4625, "LogonType": 3}', '{title: Failed Network Logon, logsource: {service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS matched;
Validate that a process-creation rule parses and compiles.
SELECT sigma.main.sigma_check('{title: Process Create, logsource: {service: security}, detection: {sel: {EventID: 1}, condition: sel}}') AS valid;
Read a rule's title and severity level from its header metadata.
SELECT title, level
FROM sigma.main.sigma_rule_info('{title: Failed Logon, level: high, logsource: {service: security}, detection: {sel: {EventID: 4625}, condition: sel}}');
List the event fields a rule keys on, for index and coverage planning.
SELECT field
FROM sigma.main.sigma_match_fields('{title: Failed Network Logon, logsource: {service: security}, detection: {sel: {EventID: 4625, LogonType: 3}, condition: sel}}')
ORDER BY field;
5 more examples
Browse the field modifiers the evaluator supports.
SELECT modifier, kind FROM sigma.main.supported_modifiers ORDER BY modifier;
Run a small rule library over an event log: keep only the rules sigma_check accepts (dropping the cidr rule the engine cannot evaluate), then join each event to every usable rule it matches (-> event 1 failed_network_logon, event 3 encoded_powershell).
WITH rules(rule_name, rule) AS (VALUES ('encoded_powershell', '{title: Encoded PowerShell, level: high, logsource: {product: windows, category: process_creation}, detection: {selection: {Image|endswith: \powershell.exe, CommandLine|contains: " -enc "}, condition: selection}}'), ('failed_network_logon', '{title: Failed Network Logon, level: medium, logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}'), ('ssh_to_internal_net', '{title: SSH To Internal Network, level: low, logsource: {category: network_connection}, detection: {selection: {DestinationIp|cidr: 10.0.0.0/8, DestinationPort: 22}, condition: selection}}')), logs(event_id, event) AS (VALUES (1, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), (2, '{"EventID": 4625, "LogonType": 2, "TargetUserName": "alice"}'), (3, '{"EventID": 1, "Image": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "CommandLine": "powershell.exe -nop -enc SQBFAFgA"}'), (4, '{"EventID": 1, "Image": "C:\\Windows\\explorer.exe", "CommandLine": "explorer.exe"}')), usable AS (SELECT rule_name, rule FROM rules WHERE sigma.main.sigma_check(rule)) SELECT l.event_id, u.rule_name
FROM logs AS l
JOIN usable AS u ON sigma.main.sigma_match(l.event, u.rule)
ORDER BY l.event_id, u.rule_name;
Turn matches into alerts: label every event the rule matches with the rule's title, severity level and MITRE ATT&CK tags read from its header (-> events 1 and 3).
WITH logs(event_id, event) AS (VALUES (1, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), (2, '{"EventID": 4624, "LogonType": 3, "TargetUserName": "admin"}'), (3, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "svc_backup"}')) SELECT l.event_id, i.title, i.level, i.tags
FROM logs AS l
CROSS JOIN sigma.main.sigma_rule_info('{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS i
WHERE sigma.main.sigma_match(l.event, '{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}')
ORDER BY l.event_id;
| event_id | title | level | tags |
|---|---|---|---|
| 1 | Failed Network Logon | medium | ["attack.credential_access", "attack.t1110"] |
| 3 | Failed Network Logon | medium | ["attack.credential_access", "attack.t1110"] |
Tell a real non-match from a blind spot: per host, did the event match the rule, and which fields the rule keys on are missing from it (-> dc01 matched with nothing missing; ws17 lacks LogonType; fw02 lacks both EventID and LogonType).
WITH logs(host, event) AS (VALUES ('dc01', '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), ('ws17', '{"EventID": 4625, "TargetUserName": "bob"}'), ('fw02', '{"action": "deny", "dst_port": 3389}')) SELECT l.host, sigma.main.sigma_match(l.event, '{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS matched, coalesce(list(f.field ORDER BY f.field) FILTER (WHERE json_extract(l.event, '$.' || f.field) IS NULL), []) AS missing_fields
FROM logs AS l
CROSS JOIN sigma.main.sigma_match_fields('{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS f
GROUP BY l.host, l.event
ORDER BY l.host;
Find unsupported modifiers behind sigma_check rejections: for each rejected rule in a library, list the field modifiers it uses that are absent from supported_modifiers (-> ssh_to_internal_net [cidr]).
WITH rules(rule_name, rule) AS (VALUES ('encoded_powershell', '{title: Encoded PowerShell, level: high, logsource: {product: windows, category: process_creation}, detection: {selection: {Image|endswith: \powershell.exe, CommandLine|contains: " -enc "}, condition: selection}}'), ('failed_network_logon', '{title: Failed Network Logon, level: medium, logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}'), ('ssh_to_internal_net', '{title: SSH To Internal Network, level: low, logsource: {category: network_connection}, detection: {selection: {DestinationIp|cidr: 10.0.0.0/8, DestinationPort: 22}, condition: selection}}')), used AS (SELECT rule_name, unnest(regexp_extract_all(rule, '\|(\w+)', 1)) AS modifier FROM rules WHERE NOT sigma.main.sigma_check(rule)) SELECT rule_name, list(DISTINCT modifier ORDER BY modifier) AS unsupported_modifiers
FROM used
WHERE modifier NOT IN (SELECT modifier FROM sigma.main.supported_modifiers)
GROUP BY rule_name
ORDER BY rule_name;
supported_modifiers
Every Sigma field modifier the evaluator implements, one per row (discovery table).
List every supported Sigma field modifier and its family.
SELECT modifier, kind FROM sigma.main.supported_modifiers ORDER BY modifier;
Show only the affix modifiers (contains / startswith / endswith).
SELECT modifier, description
FROM sigma.main.supported_modifiers
WHERE kind = 'affix'
ORDER BY modifier;
Is the regular-expression modifier supported?
SELECT count(*) > 0 AS has_regex
FROM sigma.main.supported_modifiers
WHERE modifier = 're';
1 more example
Find unsupported modifiers behind sigma_check rejections: for each rejected rule in a library, list the field modifiers it uses that are absent from supported_modifiers (-> ssh_to_internal_net [cidr]).
WITH rules(rule_name, rule) AS (VALUES ('encoded_powershell', '{title: Encoded PowerShell, level: high, logsource: {product: windows, category: process_creation}, detection: {selection: {Image|endswith: \powershell.exe, CommandLine|contains: " -enc "}, condition: selection}}'), ('failed_network_logon', '{title: Failed Network Logon, level: medium, logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}'), ('ssh_to_internal_net', '{title: SSH To Internal Network, level: low, logsource: {category: network_connection}, detection: {selection: {DestinationIp|cidr: 10.0.0.0/8, DestinationPort: 22}, condition: selection}}')), used AS (SELECT rule_name, unnest(regexp_extract_all(rule, '\|(\w+)', 1)) AS modifier FROM rules WHERE NOT sigma.main.sigma_check(rule)) SELECT rule_name, list(DISTINCT modifier ORDER BY modifier) AS unsupported_modifiers
FROM used
WHERE modifier NOT IN (SELECT modifier FROM sigma.main.supported_modifiers)
GROUP BY rule_name
ORDER BY rule_name;
sigma_check (rule_yaml VARCHAR)
True if the Sigma rule parses and compiles with only supported modifiers; false for malformed YAML or unsupported features.
A well-formed rule with a logsource and condition validates as true.
SELECT sigma.main.sigma_check('{title: Failed Logon, logsource: {service: security}, detection: {selection: {EventID: 4625}, condition: selection}}');
A rule that is not valid Sigma YAML returns false rather than raising.
SELECT sigma.main.sigma_check('not a valid rule');
sigma_match (event_json VARCHAR, rule_yaml VARCHAR)
True if the JSON event matches the Sigma rule. Use per-row over a log column: WHERE sigma_match(to_json(t), rule).
A failed-logon event matches a rule requiring EventID 4625.
SELECT sigma.main.sigma_match('{"EventID": 4625, "LogonType": 3}', '{title: Failed Network Logon, logsource: {service: security}, detection: {selection: {EventID: 4625}, condition: selection}}');
Hunt per row over an inline log table, keeping only matching events.
SELECT event
FROM (VALUES ('{"EventID": 4625, "LogonType": 3}'), ('{"EventID": 1}')) AS logs(event)
WHERE sigma.main.sigma_match(event, '{title: Failed Network Logon, logsource: {service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}');
Run a small rule library over an event log: keep only the rules sigma_check accepts (dropping the cidr rule the engine cannot evaluate), then join each event to every usable rule it matches (-> event 1 failed_network_logon, event 3 encoded_powershell).
WITH rules(rule_name, rule) AS (VALUES ('encoded_powershell', '{title: Encoded PowerShell, level: high, logsource: {product: windows, category: process_creation}, detection: {selection: {Image|endswith: \powershell.exe, CommandLine|contains: " -enc "}, condition: selection}}'), ('failed_network_logon', '{title: Failed Network Logon, level: medium, logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}'), ('ssh_to_internal_net', '{title: SSH To Internal Network, level: low, logsource: {category: network_connection}, detection: {selection: {DestinationIp|cidr: 10.0.0.0/8, DestinationPort: 22}, condition: selection}}')), logs(event_id, event) AS (VALUES (1, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), (2, '{"EventID": 4625, "LogonType": 2, "TargetUserName": "alice"}'), (3, '{"EventID": 1, "Image": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "CommandLine": "powershell.exe -nop -enc SQBFAFgA"}'), (4, '{"EventID": 1, "Image": "C:\\Windows\\explorer.exe", "CommandLine": "explorer.exe"}')), usable AS (SELECT rule_name, rule FROM rules WHERE sigma.main.sigma_check(rule)) SELECT l.event_id, u.rule_name
FROM logs AS l
JOIN usable AS u ON sigma.main.sigma_match(l.event, u.rule)
ORDER BY l.event_id, u.rule_name;
3 more examples
SELECT sigma.main.sigma_match('{"EventID": 4625, "LogonType": 3}', '{title: Failed Network Logon, logsource: {service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS matched;
SELECT sigma.main.sigma_match('{"EventID": 1}', '{title: Failed Network Logon, logsource: {service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS matched;
SELECT event,
sigma.main.sigma_match(event, '{title: Failed Network Logon, logsource: {service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS matched
FROM (VALUES ('{"EventID": 4625, "LogonType": 3}'), ('{"EventID": 1}')) AS logs(event)
ORDER BY matched;
sigma_match_fields (rule_yaml VARCHAR)
One row per event field the rule references (for index/coverage planning)
List the distinct event fields a rule keys on (-> EventID, LogonType).
SELECT field
FROM sigma.main.sigma_match_fields('{title: Failed Network Logon, logsource: {service: security}, detection: {sel: {EventID: 4625, LogonType: 3}, condition: sel}}');
Tell a real non-match from a blind spot: per host, did the event match the rule, and which fields the rule keys on are missing from it (-> dc01 matched with nothing missing; ws17 lacks LogonType; fw02 lacks both EventID and LogonType).
WITH logs(host, event) AS (VALUES ('dc01', '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), ('ws17', '{"EventID": 4625, "TargetUserName": "bob"}'), ('fw02', '{"action": "deny", "dst_port": 3389}')) SELECT l.host, sigma.main.sigma_match(l.event, '{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS matched, coalesce(list(f.field ORDER BY f.field) FILTER (WHERE json_extract(l.event, '$.' || f.field) IS NULL), []) AS missing_fields
FROM logs AS l
CROSS JOIN sigma.main.sigma_match_fields('{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS f
GROUP BY l.host, l.event
ORDER BY l.host;
sigma_rule_info (rule_yaml VARCHAR)
One row of rule metadata: title, id, level, status, description, product, service, tags
Read a rule's title and severity level from its header.
SELECT title, level
FROM sigma.main.sigma_rule_info('{title: T, level: high, logsource: {service: security}, detection: {sel: {EventID: 1}, condition: sel}}');
Expand a rule's MITRE ATT&CK tags into one row per tag.
SELECT UNNEST(tags) AS tag
FROM sigma.main.sigma_rule_info('{title: T, tags: [attack.t1110], logsource: {service: security}, detection: {sel: {EventID: 1}, condition: sel}}');
Turn matches into alerts: label every event the rule matches with the rule's title, severity level and MITRE ATT&CK tags read from its header (-> events 1 and 3).
WITH logs(event_id, event) AS (VALUES (1, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), (2, '{"EventID": 4624, "LogonType": 3, "TargetUserName": "admin"}'), (3, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "svc_backup"}')) SELECT l.event_id, i.title, i.level, i.tags
FROM logs AS l
CROSS JOIN sigma.main.sigma_rule_info('{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS i
WHERE sigma.main.sigma_match(l.event, '{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}')
ORDER BY l.event_id;
| event_id | title | level | tags |
|---|---|---|---|
| 1 | Failed Network Logon | medium | ["attack.credential_access", "attack.t1110"] |
| 3 | Failed Network Logon | medium | ["attack.credential_access", "attack.t1110"] |
Try these queries
Does a failed-network-logon event match a brute-force detection rule?
SELECT sigma.main.sigma_match('{"EventID": 4625, "LogonType": 3}', '{title: Failed Network Logon, logsource: {service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS matched
Uses sigma_match
Validate that a process-creation rule parses and compiles.
SELECT sigma.main.sigma_check('{title: Process Create, logsource: {service: security}, detection: {sel: {EventID: 1}, condition: sel}}') AS valid
Uses sigma_check
Read a rule's title and severity level from its header metadata.
SELECT title, level
FROM sigma.main.sigma_rule_info('{title: Failed Logon, level: high, logsource: {service: security}, detection: {sel: {EventID: 4625}, condition: sel}}')
Uses sigma_rule_info
List the event fields a rule keys on, for index and coverage planning.
SELECT field
FROM sigma.main.sigma_match_fields('{title: Failed Network Logon, logsource: {service: security}, detection: {sel: {EventID: 4625, LogonType: 3}, condition: sel}}')
ORDER BY field
Uses sigma_match_fields
Browse the field modifiers the evaluator supports.
SELECT modifier, kind FROM sigma.main.supported_modifiers ORDER BY modifier
Uses supported_modifiers
Run a small rule library over an event log: keep only the rules sigma_check accepts (dropping the cidr rule the engine cannot evaluate), then join each event to every usable rule it matches (-> event 1 failed_network_logon, event 3 encoded_powershell).
WITH rules(rule_name, rule) AS (VALUES ('encoded_powershell', '{title: Encoded PowerShell, level: high, logsource: {product: windows, category: process_creation}, detection: {selection: {Image|endswith: \powershell.exe, CommandLine|contains: " -enc "}, condition: selection}}'), ('failed_network_logon', '{title: Failed Network Logon, level: medium, logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}'), ('ssh_to_internal_net', '{title: SSH To Internal Network, level: low, logsource: {category: network_connection}, detection: {selection: {DestinationIp|cidr: 10.0.0.0/8, DestinationPort: 22}, condition: selection}}')), logs(event_id, event) AS (VALUES (1, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), (2, '{"EventID": 4625, "LogonType": 2, "TargetUserName": "alice"}'), (3, '{"EventID": 1, "Image": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "CommandLine": "powershell.exe -nop -enc SQBFAFgA"}'), (4, '{"EventID": 1, "Image": "C:\\Windows\\explorer.exe", "CommandLine": "explorer.exe"}')), usable AS (SELECT rule_name, rule FROM rules WHERE sigma.main.sigma_check(rule)) SELECT l.event_id, u.rule_name
FROM logs AS l
JOIN usable AS u ON sigma.main.sigma_match(l.event, u.rule)
ORDER BY l.event_id, u.rule_name
13 more examples in the Catalog, each listed under the table or function it uses.
Sigma is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Indicators of compromise
Security & forensics
Pull indicators of compromise out of threat reports and defang or refang them safely
YARA
Security & forensics
Scan blobs and text for malware with YARA rules, straight from SQL
CVE
Security & forensics
Look up CVE records, flag known-exploited CVEs, score exploit likelihood, find open-source package advisories, and compute CVSS v3.1 scores