Skip to main content

Temporal event-pattern matching over partitioned, timestamped event sequences, with explicit semantics and near-miss explanations.

Project description

epigrep

PyPI Python versions License: MIT

Grep is good at lines. Epigrep is for sequences.

Epigrep finds temporal patterns in partitioned, timestamped event streams — the kind of question that is awkward in grep, SQL, or ad-hoc pandas: "a config reload followed by an OOM within two minutes, with no readiness success in between, per pod." You describe the sequence; Epigrep returns the matches, their spans and captured values, and — for the near-misses — an explanation of why they did not match.

It is a small Rust core with Python bindings and an explicit, tested matching contract.

Install

pip install --pre epigrep

The current release is a release candidate, hence --pre. Prebuilt wheels cover Linux (x86_64, aarch64), macOS (Apple Silicon), and Windows (x64); other platforms build from the source distribution, which needs a Rust toolchain.

Quick start

from epigrep import Event, Pattern, explain, match

stream = [
    Event("api-0", 0,  "config_reload",     {"pod": "api-0"}),
    Event("api-0", 30, "readiness_success", {"pod": "api-0"}),
    Event("api-0", 70, "oom_killed",        {"pod": "api-0"}),
    Event("api-1", 0,  "config_reload",     {"pod": "api-1"}),
    Event("api-1", 90, "oom_killed",        {"pod": "api-1"}),
]

pattern = (
    Pattern.event("config_reload")
    .then("oom_killed", within=120, no="readiness_success")
    .build()
)

for m in match(pattern, stream):
    print(m.partition, list(m.indices))   # api-1 [3, 4]

# Why didn't the others match?
for nm in explain(pattern, stream):
    print(nm.partition, nm.reason)        # api-0 absence_blocked

api-1 matches: a reload, then an OOM 90s later, nothing in between. api-0 does not — a readiness_success lands in the gap, so the no= clause rules it out, and explain() tells you that rather than leaving you to work it out.

What you get back

For each start position, Epigrep returns either:

  • a match — participating event indices, the span (start and end timestamps), and any captured attribute values; or
  • a near-miss — for starts that cannot complete, the deepest partial path it reached and the reason the next step failed (predicate_failed, absence_blocked, window_exceeded, or no_successor), with structured detail.

schema(stream) summarises the event types and attributes present. Pandas dataframe helpers are available when pandas is installed; matching and explanation do not require it.

Patterns

Two construction surfaces are stable: the builder (above) for code written by hand, and a JSON pattern format for tools and agents that emit and validate patterns programmatically.

from epigrep import Pattern, pattern_from_json

ast = Pattern.event("A").then("B", within=5).build().to_json()
pattern = pattern_from_json(ast)   # validated; safe to match

A terse text DSL also exists (parse_pattern), but it is experimental and outside the 0.1 stability guarantee — prefer the builder or JSON format.

Semantics

Matching has an explicit, tested contract: ordering and tie-breaking, partitioning, match-consumption modes, inclusive windows, absence-between, capture/register equality, overlapping matches, and near-miss guarantees. A naive reference matcher is the source of truth; a second, independent implementation is checked against it by property tests. See the documentation.

Status

Alpha, published as a release candidate. The Python API and JSON pattern format are the intended stable surface; the text DSL is experimental. MIT licensed.

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

epigrep-0.1.0rc2.tar.gz (45.7 kB view details)

Uploaded Source

Built Distributions

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

epigrep-0.1.0rc2-cp39-abi3-win_amd64.whl (312.1 kB view details)

Uploaded CPython 3.9+Windows x86-64

epigrep-0.1.0rc2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (471.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

epigrep-0.1.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (465.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

epigrep-0.1.0rc2-cp39-abi3-macosx_11_0_arm64.whl (412.9 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file epigrep-0.1.0rc2.tar.gz.

File metadata

  • Download URL: epigrep-0.1.0rc2.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for epigrep-0.1.0rc2.tar.gz
Algorithm Hash digest
SHA256 73f2756e72bdfb0c98d9a041d08819e71fa98cfa16f7a638550ddc06943e44fa
MD5 e0d1393148a57c0f2a95f23751ccfe07
BLAKE2b-256 d3e1ffca2048c8c9779b40a6362a3177755ba52370abbcb1e028d197e686e3b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for epigrep-0.1.0rc2.tar.gz:

Publisher: release.yml on rikkhill/epigrep

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

File details

Details for the file epigrep-0.1.0rc2-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: epigrep-0.1.0rc2-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 312.1 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for epigrep-0.1.0rc2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 184bdbb7c814c78ebb47d19b5ca2b48c75143f99ba8d3d3639b6a3f578bfdc67
MD5 bc0eac23a1372ab2be1ccfbb3bf5985b
BLAKE2b-256 278e636008dbd430cdb2bf376faa9675a6a6d1ad290909c4da68c90c5672f0e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for epigrep-0.1.0rc2-cp39-abi3-win_amd64.whl:

Publisher: release.yml on rikkhill/epigrep

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

File details

Details for the file epigrep-0.1.0rc2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for epigrep-0.1.0rc2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2e09f4a5975b53c5951d45c35008f7bad9584d0f3b22037d2deac195f863129a
MD5 3e5f52921450f36efa256ed61f90c298
BLAKE2b-256 1f81f7f39da56a6b63f7ef34a3ef1b63d6a442cb5e78cc43c27043cd388202d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for epigrep-0.1.0rc2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on rikkhill/epigrep

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

File details

Details for the file epigrep-0.1.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for epigrep-0.1.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9f14e2e98ea6f2abf0c8ee0b40818dfe49f89d8ec68202d35019b6a664c8031e
MD5 5ee15e806cd4bf295e2f1434feb79588
BLAKE2b-256 a9bdb0c94728fd77591dc8f63d77c8b805b489544250b44dc002ff5ccd70beef

See more details on using hashes here.

Provenance

The following attestation bundles were made for epigrep-0.1.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on rikkhill/epigrep

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

File details

Details for the file epigrep-0.1.0rc2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for epigrep-0.1.0rc2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7cbce89ebc5bdaa2c9e40b2b2a2fc49a58dfc3195c756d0056992d852ce1073b
MD5 dcbca8a43d4cdc07bafbf03dbdc2543b
BLAKE2b-256 6ccfd40001dacb97c3918bee4f8c054cb0fe49d54dba92729582fe1a58074bf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for epigrep-0.1.0rc2-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on rikkhill/epigrep

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