grok_rs
the grok_rs
is a rust port of Elastic Grok processor, inspired by grok-go and grok
Usage
[]
= "0.1.2"
Example
Only with default patterns
let grok = default;
let pattern = grok
// USERNAME are defined in grok-patterns
.compile
.unwrap;
let result = pattern.parse.unwrap;
println!;
the output is:
{
"USERNAME": String(
"admin",
),
}
With user-defined patterns
let mut grok = default;
grok.add_pattern;
let pattern = grok.compile.unwrap;
let result = pattern.parse.unwrap;
println!;
the output is:
{
"NAME": String(
"admin",
),
}
With named_capture_only
is true
let grok = default;
let pattern = grok
.compile
.unwrap;
let result = pattern.parse.unwrap;
println!;
the output is:
{
"email": String(
"admin@example.com",
),
}
With type
let mut grok = default;
grok.add_pattern;
let pattern = grok.compile.unwrap;
let result = pattern.parse.unwrap;
println!;
the output is:
{
"digit": Int(
123,
),
}
Notice
grok_rs
is based on regex crate, so lacks several features that are not known how to implement efficiently. This includes, but is not limited to, look-around and backreferences. In exchange, all regex searches in this crate have worst case O(m * n)
time complexity, where m
is proportional to the size of the regex and n
is proportional to the size of the string being searched.
Elastic Grok compliance
This crate declares compatible with elastic grok patterns v8.14.0, which is tagged at 2024-06-05.