Skip to content
SlateGitOrgPublic

About

Log-source silence detection that derives each feed's alert delay from a negative-binomial hour-of-week baseline, so sparse feeds stay quiet at night and a dead firewall is caught in minutes.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

quietfeed

CI

quietfeed

quietfeed detects log sources that have stopped forwarding. It fits a negative-binomial baseline per source and hour of the week, then derives each source's alert delay from that baseline instead of using one flat timeout: a firewall that sends 1,500 events every five minutes alarms after one empty bucket, while a badge reader that is legitimately silent all night is given a delay that runs into the morning. It also catches partial drops (one collector of three down) and ingest-clock skew. All data is synthetic and produced by a seeded generator in this repository; there is no live SIEM.

The problem

A SOC ingests about 40 sources (firewalls, domain controllers, VPN, proxy, EDR, EHR audit, badge readers, DNS). When a source stops forwarding because of an agent crash, a syslog route change or an expired TLS certificate, every detection that reads it goes blind and nothing alerts. The usual guard is "no events for 24 hours". That is too slow for a busy firewall, and a short flat rule (1 hour) is too noisy for sparse sources that are silent at night. Partial drops and clock skew are not caught by either.

How it works

flowchart LR
    G["gen<br/>seeded counts + lag samples<br/>+ injected incidents"] --> B["baseline<br/>168 hour-of-week slots<br/>NB mean + dispersion r"]
    H["holiday calendar<br/>YAML"] --> B
    B --> S["silence<br/>running log P(0 events)"]
    B --> P["partial<br/>1 h volume tail<br/>+ collector share"]
    B --> K["skew<br/>hourly median lag shift"]
    S --> A["alerts<br/>one open alert per<br/>(source, type), JSONL"]
    P --> A
    K --> A
    A --> E["evaluate<br/>vs injected incidents<br/>and flat 1 h / 24 h rules"]
    G --> E
Loading
  • Generator (gen): 5-minute event counts for 40 sources over 6 weeks (weeks 1-4 train, 5-6 evaluate), a true mean constant within each hour-of-week slot, negative-binomial overdispersion, a holiday, per-collector counts for fw-01 and proxy-01, 20 ingest-lag samples per source per hour, and five injected incidents (ids 1-3, 5 and 6).
  • Baseline (baseline): per source and slot, the mean of the 48 training observations; one dispersion r per source by pooled method of moments, r = sum(m^2) / sum(s^2 - m) over slots with mean >= 1, clamped to [0.5, 1000]. Holidays use the Sunday profile.
  • Silence (silence): the running sum of log P(0) over the current zero-run, P0 = (r / (r + mu))^r using each bucket's own slot mean. An alert fires when the sum drops below log(alpha), alpha = 1e-6. delays evaluates this for each of the 2,016 start buckets of a week.
  • Partial (partial): a 1-hour sliding-window volume test with a moment-matched negative-binomial lower tail (tail < 1e-6 and observed/expected < 0.6), plus a binomial lower-tail test of each collector's share against its trained share, so the dead collector is named.
  • Skew (skew): hourly median ingest lag against the trained median; an alert needs a shift above 300 s for 2 consecutive hours.
  • Alerts (alerts): one open alert per (source, type); closed after 3 consecutive buckets at or above the slot's 25th-percentile count; JSONL sorted by (time, source, type).
  • Compare / evaluate (compare, evaluate): flat "no events for 1 h" and "no events for 24 h" rules on the same data, and a match of alerts to injected ground truth.

Quick start

python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"

quietfeed generate --out data --seed 7
quietfeed fit --data data
quietfeed delays --data data -s fw-03 -s badge-07
quietfeed scan --data data
quietfeed evaluate --data data
pytest -q

generate --sample-day N also writes that day's counts as sample.csv.

Example output

Run on seed 7 (quietfeed generate, quietfeed fit, then the commands below).

$ quietfeed delays -s fw-03 -s ehr-audit-02 -s badge-07 -s proxy-01 -s dc-02
source        business hours  median  worst case  worst start
fw-03                  5 min   5 min       5 min    Mon 00:00
ehr-audit-02           5 min  10 min      20 min    Mon 00:00
badge-07              40 min   7.8 h      47.7 h    Fri 18:00  gap>24h
proxy-01               5 min   5 min       5 min    Mon 00:00
dc-02                  5 min   5 min      10 min    Mon 00:00
$ quietfeed scan
8 alerts -> data/alerts.jsonl

$ quietfeed evaluate
                                    quietfeed  flat 1 h  flat 24 h
1. fw-03 outage, 3 h                    5 min    60 min     missed
2. ehr-audit-02 outage, 2 h            15 min    55 min     missed
3. badge-07 outage, 6 h                40 min    60 min     missed
5. proxy-01 collector c2 down, 8 h      5 min    missed     missed
6. dc-02 clock 2 h behind             120 min    missed     missed
false alerts (total)                        0       618          0
false alerts per source-week            0.000     7.725      0.000

Incident ids follow the spec: 4 (badge-07 natural night and weekend zero-runs) and 7 (the holiday) are not failures, so they have no row; the tests assert they raise no alert.

badge-07 has a blind spot of 47.7 hours starting Friday 18:00: a silence that begins then is statistically unremarkable until Sunday evening, and the report says so with gap>24h instead of paging on every quiet night. The "business hours" column is the median delay for outages that start on a weekday (Monday to Friday) between 08:00 and 18:00.

Design decisions

  • Delay derived from the model, not configured. The smallest silence window whose probability falls below alpha is computed per source and slot. Trade-off: sparse sources get long delays by construction; the blind spot is reported rather than hidden.
  • One dispersion per source, one mean per slot. 48 observations per slot are too few to fit r per slot; pooling r across slots keeps tails stable. Trade-off: a source whose overdispersion varies a lot by hour is fitted less tightly.
  • Plain-mean slot estimates with a holiday calendar. Holidays are declared in YAML and scored with the Sunday profile. Without the calendar, a holiday looks like a mass partial drop (a test asserts this).
  • Collector share as a separate test. A load balancer hides a dead collector from the total volume test for a long time; a binomial test on shares names it.
  • Flat rules as baselines in the same pipeline. Both run on identical data and the same lifecycle, so the evaluation table compares like with like.
  • Partial alerts have a 1 h refractory period. The 1-hour sliding window keeps reporting a drop for up to 12 buckets after the volume recovers, so a new partial alert for the same source is held back for 12 buckets after one closes. Trade-off: a second, separate partial drop inside that hour is not reported until it ends.
  • Integer bucket time, no clock. Everything is an offset from the dataset's first Monday, so results do not depend on time zone, locale or wall clock.

Testing

74 tests cover generator determinism (SHA-256 of the arrays), baseline accuracy against the generator's true means, delay values and a hypothesis property (delay never increases as the slot mean rises with r fixed), each injected incident, a scan that starts inside a zero-run, false-alert limits on the clean weeks, the holiday calendar, the alert lifecycle, byte-identical repeated scans, a fingerprint of the NumPy random streams and the CLI. NumPy and SciPy are pinned to one minor version (numpy>=2.5,<2.6, scipy>=1.18,<1.19) because the exact counts above come from seeded Generator streams that NumPy only guarantees within a minor release.

GITHUB_ACTIONS=true CI=true COLUMNS=80 pytest -q

Project layout

src/quietfeed/
  gen.py        seeded dataset generator and incident definitions
  baseline.py   hour-of-week negative-binomial fit, JSON round trip
  nbmodel.py    negative-binomial helpers
  silence.py    zero-run log-probability, per-source delay report
  partial.py    volume-drop and collector-share tests
  skew.py       ingest-lag shift detection
  alerts.py     alert lifecycle and JSONL output
  scan.py       runs all detectors over a dataset
  compare.py    flat 1 h and 24 h baselines
  evaluate.py   matching to ground truth and the comparison table
  timeline.py   bucket arithmetic, holiday calendar
  cli.py        typer commands
tests/          pytest and hypothesis tests

License

MIT

About

Log-source silence detection that derives each feed's alert delay from a negative-binomial hour-of-week baseline, so sparse feeds stay quiet at night and a dead firewall is caught in minutes.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages