grippo
Parse, match and scrub data faster and more efficiently.
grippo is a Rust library for parsing, matching, filtering and scrubbing data from any source: logs, events, JSON, XML, or a format you compose yourself. It tells you how each rule will run before you run it. Built for at-scale speed and efficiency.
Primitives, and what they cost
grippo is built from typed primitives, one per sub-pattern: a literal, an IPv4 address, a timestamp, a run of non-space. Each matches one thing and nothing else, so it doesn't carry a general engine's machinery.
Compose them. compose joins primitives into a parser with no pattern text:
use ;
let parser = literal
.then
.then
.then
.then
.build?;
That's the route to take for a new format. A composed parser runs on the same steps as the grok pattern it mirrors, gives the same fields, and costs no more.
Every matcher and parser reports a worst-case tier: Fixed, Byte, Literal, LiteralSet, Field, Regex or Backtracking, cheapest first. Most also report a cost in ns, measured on our bench host. A build can reject any pattern below the tier you set, so a slow rule fails when it loads.
docs/compose.md has the parts, and docs/field.md the scanners.
Grok and regex
Most rules are written as grok or regex today. grippo runs each pattern on the cheapest tier that gives the same answer, and stops there. The regex engine runs only for a pattern nothing cheaper can take. On our rule corpus that's 35 of 2,445 grok patterns (29 Nov 2026).
---
config:
theme: base
look: neo
fontFamily: Inter, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif
flowchart:
curve: linear
nodeSpacing: 40
rankSpacing: 64
padding: 18
wrappingWidth: 280
htmlLabels: true
elk:
preset: modelOrder
themeVariables:
fontSize: 15px
lineColor: "#64748B"
primaryTextColor: "#0F172A"
nodeBorder: "#334155"
clusterBorder: "#0072B2"
edgeLabelBackground: "#FFFFFF"
themeCSS: >-
p{margin:0}
.node[data-look] rect,.node[data-look] path,.node[data-look] polygon,.node[data-look] .outer-path{filter:drop-shadow(0 1px 2px rgba(15,23,42,.10)) drop-shadow(0 6px 14px rgba(15,23,42,.10))}
.node rect{rx:10px;ry:10px}
.cluster rect{rx:16px;ry:16px}
.node .label div{min-width:150px}
.node.decision .label div{min-width:0}
.cluster[data-look] rect{filter:none}
.nodeLabel{line-height:1.35}
.nodeLabel b{font-weight:600;font-size:15px;letter-spacing:-0.01em}
.nodeLabel span{font-size:12.5px;font-weight:400;color:#334155}
.cluster-label span.nodeLabel{display:inline-block;background:#FFFFFF;color:#0B2A3F;border:1.5px solid #0072B2;border-radius:999px;padding:2px 12px;font-size:11.5px;font-weight:700;letter-spacing:.09em;text-transform:uppercase}
.flowchart-link{stroke-width:1.75px}
.labelBkg{background:transparent!important}
span.edgeLabel{display:inline-block;background:#FFFFFF!important;color:#1E293B;border:1px solid #94A3B8;border-radius:999px;padding:2px 10px;font-size:12px;font-weight:500}
span.edgeLabel p{background:transparent!important}
.label-icon{width:20px;height:20px;vertical-align:-4px;margin-right:6px}
.icon-shape path[stroke-width="0"][fill="none"]{fill:#FFFFFF;stroke:#FFFFFF;stroke-width:12px;stroke-linejoin:round}
.icon-shape p{background:transparent!important;color:#0F172A}
.ingest .label-icon{color:#0E8A7D}
.xform .label-icon{color:#7B4FB0}
.load .label-icon{color:#0072B2}
.bus .label-icon{color:#A8517F}
.store .label-icon{color:#00785A}
.ui .label-icon{color:#D9480F}
.ext .label-icon{color:#64748B}
---
flowchart LR
accTitle: L4 Detail -- Where a pattern runs
accDescr: A pattern runs on the first tier that can answer it. One byte or a set of literals is a scan, with no engine. A grok or regex pattern that lowers runs on the field scanners, as native steps or generated code. Only a pattern neither can take falls back to the regex engine, and backtracking runs only when a build turns it on.
lit{"<b>Byte or literals?</b>"}
scan("<b>Byte or literal scan</b><br/><span>memchr, aho-corasick</span>")
lowers{"<b>Lowers?</b>"}
steps("<b>Field scanners</b><br/><span>native steps or generated code</span>")
regex("<b>Regex engine, fallback</b><br/><span>regex-automata</span>")
back("<b>Backtracking</b><br/><span>fancy-regex, opt-in</span>")
lit -->|"yes"| scan
lit -->|"no"| lowers
lowers -->|"yes"| steps
lowers -->|"no"| regex
regex -.->|"lookaround, backrefs"| back
class regex,back ext
class lit,lowers decision
class scan,steps part
%% merrow:begin
classDef ingest fill:#FFFFFF,stroke:#0E8A7D,stroke-width:3px,color:#0F172A
classDef xform fill:#FFFFFF,stroke:#7B4FB0,stroke-width:3px,color:#0F172A
classDef load fill:#FFFFFF,stroke:#0072B2,stroke-width:3px,color:#0F172A
classDef bus fill:#FFFFFF,stroke:#A8517F,stroke-width:3px,color:#0F172A
classDef store fill:#FFFFFF,stroke:#00785A,stroke-width:3px,color:#0F172A
classDef ui fill:#FFFFFF,stroke:#D9480F,stroke-width:3px,color:#0F172A
classDef ext fill:#F4F6F8,stroke:#94A3B8,stroke-width:1.5px,stroke-dasharray:5 4,color:#0F172A
classDef decision fill:#FFFFFF,stroke:#9A6700,stroke-width:3px,color:#0F172A
classDef error fill:#FFFFFF,stroke:#C2410C,stroke-width:3px,color:#0F172A
classDef control fill:#FFFFFF,stroke:#334155,stroke-width:3px,color:#0F172A
classDef part fill:#FFFFFF,stroke:#94A3B8,stroke-width:1.5px,color:#0F172A
%% merrow:end
Figure 1. L4 Detail -- Where a pattern runs. Up: L3 Components -- grippo.
strmatchtakes a regex or a glob, and answers one that is a byte, a literal or a fixed list of literals with a byte scan, a literal search or one literal-set automaton. No regex engine runs unless you ask for groups, and then only on a hit.groklowers a grok pattern or a plain regex onto thefieldscanners. A pattern with no%{...}is a regex, and its named groups are the fields.%{IPV4},%{TIMESTAMP_ISO8601},\d+,[^ ]+and the rest each run on a scanner exact to the regex.grok!compiles a fixed pattern into calls to them when your crate builds.- Anything else falls back to the regex engine, regex-automata, with the same answer.
tier()andGrok::explain()say which tier a pattern landed on and why, and a build can reject anything that falls back.
So porting a rule set needs no rewrite (though we do recommend you do that if you have time, it pays off).
Compiled stock grok patterns on our bench host (28 Nov 2026), against a DFA in front of PCRE2-JIT:
| Line | grippo | DFA + PCRE2-JIT | PCRE2-JIT alone |
|---|---|---|---|
| access log, hit | 326 ns | 621 ns | 253 ns |
| syslog, hit | 166 ns | 554 ns | 148 ns |
| access log, late miss | 118 ns | 178 ns | 3,758 ns |
PCRE2-JIT alone is quicker on a hit, but it pays heavily on a line that fails late, which is why it gets a DFA in front. Your mileage will vary with your data, so measure on your own lines before you plan capacity.
docs/grok.md and docs/strmatch.md have the detail. docs/performance.md has the method, the misses and the firewall line.
Formats and nesting
Stock parsers for syslog, CEF, LEEF, NDJSON, GELF, XML, CSV, key=value, dissect, CRI and web access logs, each behind a parse-* feature. Each is a layer, and layers nest. A chain is written as syslog > cef: the syslog parser hands its message to the CEF parser without copying it, and both write fields to your sink. A value is copied only when it has to be unescaped.
use register_stock;
use ;
Build the plan once per source. The parsers you name are the ones that run. Detection is opt-in, a hop at a time:
| Chain | What runs |
|---|---|
syslog > auto |
syslog, then the parser the message's content names |
auto* |
Detect the record, then every body and value below it |
ndjson > field("event"):cef |
JSON, then the value it wrote as event, as CEF |
docs/parse.md has chains and sinks, docs/formats.md each format, and docs/xml.md XML to JSON records as the bytes arrive.
CEL filters
expr runs CEL filter expressions as grippo checks, with no CEL interpreter. The record can be raw JSON, a text line, or the fields a parser chain wrote, so a filter reads straight off the layers above. The result is the one cel 0.14.5 gives, errors included: our tests run 4,096 generated filters through cel as well and compare.
use ;
let p = compile?;
assert_eq!;
Lowered filters run 21 to 75 times as fast as cel's interpreter on small records. A filter outside the subset is refused when it compiles, so you know before it runs. docs/expr.md has the subset and the figures.
Scrub
scrub finds secrets, credentials and PII, and masks or hashes each. Secrets use gitleaks' rules plus your own, and credentials are found by field name and in key=value text. PII is email addresses, card numbers, IBANs, phone numbers (with scrub-phone) and Australian ABN, ACN, TFN and Medicare numbers, each confirmed by its own check such as Luhn. It works on any record grippo reads, through any chain of layers in the stock formats, and writes each masked value back into the layer it came from, escaped for that format. It runs over every layer, or the one you scope it to.
You get the record back rewritten in place, or as a new copy when anything changed, and a report counting finds by rule that never holds a value. Build one Scrubber and share it across threads. docs/scrub.md has the rules, the scope and the report.
Build it right or it runs slow
Add grippo to a default build and it runs slower than our figures. Cargo never applies a dependency's build config to your binary, so these go in YOUR workspace:
# .cargo/config.toml
[]
= ["-C", "target-cpu=x86-64-v3", "-C", "target-feature=+pclmulqdq"]
# Cargo.toml
[]
= "fat"
= 1
- Without the CPU flags, sonic-rs and other crates in the tree fall back to plain loops, with no warning. aarch64 needs no flags.
- Then a profile-guided build (PGO), and BOLT on top. PGO alone took 8-28% off grok parsing. PGO and BOLT together took 300 JSON lines from 321 to 269 us.
- v3 needs Haswell (2013), Excavator (2015) or newer. On an older CPU the binary crashes with SIGILL.
docs/build-optimisation.md has the full recipe.
Documentation
- API reference: https://docs.rs/grippo
- docs/architecture.md: the parts and how a record moves through them.
- docs/parse.md, docs/formats.md, docs/grok.md, docs/strmatch.md and docs/field.md: parsers and primitives.
- docs/record.md: the record a filter or scrub reads, from JSON, text, XML or parser fields.
- docs/expr.md, docs/scrub.md and docs/xml.md: CEL filters, redaction and XML.
- docs/async.md: threads, tokio and what to share.
- docs/performance.md: every bench, its numbers and what they decided.
The default features are strmatch and parse. Each stock format, grok, scrub and XML sits behind its feature flag, so a build holds just what it uses. docs/feature-flags.md has the full list.
Help, contributing and licence
A bug or a question goes in an issue. CONTRIBUTING.md has how to work in this repo and the commands that test a change. Security reports follow SECURITY.md.
Apache-2.0. Third-party attributions are in NOTICE.
"If you want to spot an at scale amateur, look for a grok or regex on the hot path" - this crate helps you solve that problem.
You need your grippo in the wet.