Skip to main content

pySigma VictoriaLogs (LogsQL) backend

Project description

pySigma backend for VictoriaLogs (LogsQL)

CI PyPI Python License: MIT

Convert Sigma detection rules to LogsQL queries that run against VictoriaLogs.

Sigma rule (YAML)
        │
        ▼
   pySigma core
        │
        ▼
 VictoriaLogsBackend  ──►  field:="value" AND other:~"regex"

Install

The recommended way is via sigma-cli's plugin system:

pip install sigma-cli
sigma plugin install victorialogs

Or directly as a library:

pip install pysigma-backend-victorialogs

First query

sigma convert -t victorialogs path/to/rule.yml

Programmatic use:

from sigma.collection import SigmaCollection
from sigma.backends.victorialogs import VictoriaLogsBackend

rule = SigmaCollection.from_yaml("""
title: SSH login failure
logsource:
    product: linux
    service: auth
detection:
    sel:
        program: sshd
        message|contains: "Failed password"
    condition: sel
""")

print(VictoriaLogsBackend().convert(rule)[0])
# program:="sshd" AND message:~"Failed password"

See docs/getting_started.md for the full walkthrough including a local VictoriaLogs container.


Compatibility

Component Supported versions
Python 3.10, 3.11, 3.12, 3.13, 3.14
pySigma ^1.1.0
VictoriaLogs v1.50.0 (pinned by digest in CI)

CI pins victoriametrics/victoria-logs:v1.50.0 by sha256 digest for reproducibility; bumps follow the procedure in CONTRIBUTING.md. Older or newer VL versions are not actively tested but should work as long as they parse the LogsQL constructs listed in docs/mapping.md.

Mapping summary

Sigma feature LogsQL output
field: value field:="value"
field|contains: x field:~"x" (regex)
field|startswith: x field:="x"* (native prefix)
field|endswith: x field:~"x$" (regex anchor)
field|re: pattern field:~"pattern"
field|cidr: 10.0.0.0/8 field:ipv4_range("10.0.0.0/8")
field|cidr: ::1/128 field:ipv6_range("::1/128")
field|gte: 1024 field:>=1024
field|fieldref: other field:eq_field(other)
field|exists: true field:*
field: null field:""
field IN [a, b] field:in("a", "b")
event_count correlation _time:Xm <search> | stats by (g) count() as event_count | filter event_count:>=N

Full reference: docs/mapping.md.

Pipelines

Sigma rules use a neutral field taxonomy (Image, CommandLine, EventID, …) that does not match how any specific log shipper writes records. Pick a pipeline that matches your ingestion path:

Pipeline Targets Renames
victorialogs (no-op placeholder) none
victorialogs_windows_eventlog Winlogbeat / Vector ECS Windows ingest EventIDwinlog.event_id, EventData→winlog.event_data.*, channel selectors
victorialogs_journald systemd-journal native fields Image_EXE, CommandLine_CMDLINE, MessageMESSAGE, …
victorialogs_caddy Caddy v2 JSON access logs cs-methodrequest.method, cs-uri-*request.uri, sc-statusstatus, …
victorialogs_suricata Suricata EVE JSON dst_ipdest_ip, QueryNamedns.rrname, TlsServerNametls.sni, …
victorialogs_podman podman/docker journald CONTAINER_* ContainerNameCONTAINER_NAME, ImageNameIMAGE_NAME, …
sigma convert -t victorialogs -p victorialogs_journald rule.yml
sigma convert -t victorialogs -p victorialogs_windows_eventlog rule.yml
sigma convert -t victorialogs -p victorialogs_caddy rule.yml

Each pipeline applies only to rules whose logsource matches its target (e.g. product: linux for journald, category: webserver for Caddy, category: network or product: zeek|suricata for the EVE pipeline); other rules pass through untouched. Stack pipelines with multiple -p flags when, for example, podman containers ship through journald.

Output formats

Format Output
default Plain LogsQL query strings (one per rule)
vmalert vmalert rule group YAML (type: vlogs) for VictoriaLogs

vmalert (deploy as alerting rules)

sigma convert -t victorialogs -f vmalert -p victorialogs_journald \
    rules/*.yml > sigma-rules.yaml

The output is a single rule group ready to feed to vmalert pointed at a VictoriaLogs datasource:

vmalert \
    -datasource.url=http://victorialogs:9428 \
    -rule.defaultRuleType=vlogs \
    -rule=sigma-rules.yaml \
    -notifier.url=http://alertmanager:9093

Each Sigma rule becomes one alert with expr wrapped as <query> | stats count() as matches | filter matches:>0 (correlation rules already aggregate and pass through unwrapped). vmalert auto-prepends _time:<group_interval>, so the emitted expressions are time-agnostic by design — change the evaluation window via the group interval (default 5m) rather than editing every query. Sigma level maps to labels.severity and id to labels.sigma_id. Requires vmalert ≥ v1.93 (when type: vlogs was added). See docs/mapping.md §14 for the full mapping.

Limitations

  • Temporal correlations (temporal, temporal_ordered) are unsupported — LogsQL has no native multi-event window join.
  • -search.maxQueryLen defaults to 16 KiB; seven SigmaHQ rules emit queries above this. Raise the flag at VL startup if you need them: victoria-logs -search.maxQueryLen=524288 ...
  • No native single-character wildcard — Sigma ? routes to regex.
  • Case-sensitivity is the default (LogsQL :=).

Full details and workarounds: docs/limitations.md.

Documentation

License

MIT © aris1009

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysigma_backend_victorialogs-0.1.1.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysigma_backend_victorialogs-0.1.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file pysigma_backend_victorialogs-0.1.1.tar.gz.

File metadata

File hashes

Hashes for pysigma_backend_victorialogs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 305a62822262ec002c5a818ebf8072cf1072b3712b1bd30081ab35a2bb271eba
MD5 c68b31bc0c0c105048e4d2319cb1db02
BLAKE2b-256 582b0f94821fe81d95c704f3d2ff3ab220ce768bc1469799248ab1a5c4684165

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysigma_backend_victorialogs-0.1.1.tar.gz:

Publisher: release-please.yml on aris1009/pySigma-backend-victorialogs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pysigma_backend_victorialogs-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pysigma_backend_victorialogs-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a0112d0c902883b9c2da6f68887a11bad4b2ba9a472c7d46fef8bff5550ae86
MD5 41e4c6c9551ec8051b487c0be9a9a174
BLAKE2b-256 71e8b9d41d06289c0662089d23f19945946ba8e28872ead62f97bbb241966ed0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysigma_backend_victorialogs-0.1.1-py3-none-any.whl:

Publisher: release-please.yml on aris1009/pySigma-backend-victorialogs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page