This project has ceased to be actively maintained at Everpure since November 2024. The repository will remain available for reference and community contributions. Currently being maintained by a community maintainer: @enygmator (feel free to reach out for contributions or issues)
Quick Query (QQ) is a high performance, high throughput, and low latency data processor that uses Hyperscan and PCRE2 for regex matching. It offers a simple and easy to use interface (a single config file) for configuring the input and output mechanisms.
QQ started out as a tool that parses log files into a local OLAP database, but has now evolved into being a more generic data processor that is highly configurable, and can be used in many use cases.
Prerequisites:
- Rust (the toolchain pinned in
rust-toolchain.toml), or runmake setup-rust protoc(protobuf-compiler,libprotobuf-dev), or runmake setup-protoccmake,ragel,build-essential,pkg-config(to build Hyperscan)
Hyperscan and Boost (needed to build Hyperscan) are downloaded from their upstream release URLs and built into
build/bymake install
Configuration:
All configuration can be easily done through a .config file.
An example .config file is provided at .config.sample.
Build:
git clone https://github.com/purestorage-openconnect/quick-query.git
cd quick-query
make installRun (QQ_TEST_CONFIG defaults to config/example_run_config.ron):
make -C tasks generate-test-logs # synthesizes tests/test_logs/generated.log
make run QQ_TEST_CONFIG=config/example_run_config.ronUse Ctrl+C to stop QQ (socket inputs keep it running; with stdin from a terminal, you'll need to press Ctrl+C and Enter).
make view-env shows the paths and variables used by the Makefile.
CARGO_PROFILE defaults to optimized-dev, which is basically a release build without lto and codegen-units (so it's much faster to compile). Use CARGO_PROFILE=release for final binaries, or when you're measuring perf. Refer the comments in Cargo.toml for more info.
It uses PCRE2 and Hyperscan underneath, and the Tokio framework for async.
Data flows through a pipeline that is fully described by a configuration file:
inputs -> input transformers -> matcher -> outputs
- inputs: regular files, stdin, TCP sockets (plain text, gzip, zstd, Fluent Bit msgpack), Unix domain sockets (server and client)
- input transformers: gzip/zstd decompression, chunking of plain text into lines, buffering of lines into blocks
- matcher:
HyperscanPCREMatcheruses Hyperscan to find which lines match which patterns (of a pattern set), and PCRE2 to extract the named capture groups from the matched lines - outputs:
Faker(discards data),Serializer,SQLite,DynamicProtoFakerandStaticProtoFaker(encode the captured values as protobuf messages)
It also exports metrics and logs (stdout, file, OpenTelemetry).
config/sample_detailed_config.ronlists all the configuration options (with their defaults)config/test_config.ronandconfig/example_run_config.ronare ready to use configsconfig/flb1.confis an example Fluent Bit config to send data to a QQ TCP input
Pattern sets are made of pattern files in RON (preferred, as it is more human friendly) or JSON format, see config/sample_patterns_file.ron and config/sample_patterns_file.json:
[
(
type: re,
search: r#"^(?P<timestamp>[A-Z][a-z]{2} [ 0-9]\d \d{2}:\d{2}:\d{2}) (?P<hostname>\S+) (?P<program>[\w./-]+)\[(?P<pid>\d+)\]: (?P<message>.*)$"#,
example: Some("May 11 15:17:02 host-a CRON[10973]: (root) CMD (run-parts /etc/cron.hourly)"),
key: "syslog_line",
var_schema: {
"timestamp": timestamp_syslog,
"hostname": string,
"program": string,
"pid": int,
"message": string,
},
),
][
{
"key": "syslog_line",
"search": "^(?P<timestamp>[A-Z][a-z]{2} [ 0-9]\\d \\d{2}:\\d{2}:\\d{2}) (?P<hostname>\\S+) (?P<program>[\\w./-]+)\\[(?P<pid>\\d+)\\]: (?P<message>.*)$",
"type": "re",
"example": "May 11 15:17:02 host-a CRON[10973]: (root) CMD (run-parts /etc/cron.hourly)",
"var_schema": "{\"timestamp\": \"timestamp_syslog\", \"hostname\": \"str\", \"program\": \"str\", \"pid\": \"int\", \"message\": \"str\"}"
}
]keymust be unique, and a valid protobuf message / SQLite table name ([a-z0-9_])- the regex MUST be supported by both Hyperscan and PCRE2 (so, no lookarounds or backreferences). Patterns that fail to compile with Hyperscan are dropped from the pattern set
var_schemadatatypes:string,int,uint,double,boolean, and the timestampstimestamp_iso(2023-10-10 13:55:36.123, also thetimestampalias),timestamp_syslog(May 11 15:17:02, the current year and UTC are assumed) andtimestamp_clf(10/Oct/2023:13:55:36 +0000)- you can convert JSON pattern files to RON with
tasks/qq_patterns_json_to_ron.rs
tests/test_patterns/grok/contains more than 800 signatures derived from logstash-patterns-core, seetests/test_patterns/grok/README.mdfor how to regenerate them (make -C tasks import-grok-patterns).
make check # type-checks all targets
make test # runs the test suite (with cargo-nextest)
make fmt # checks formatting
make clippySnapshot tests use insta; review changed snapshots with make test-insta-review.
make -C tasks generate-test-logs GENERATED_LOG_SIZE=10000000
make run-fixed-cores # pins QQ to a fixed set of cores with numactl- use the
ser_dev_nullSerializer output inconfig/test_config.ronto measure matching throughput without writing any output - profiling:
make profile-flamegraph(CPU),make profile-heaptrack(heap),make profile-bytehound(heap + stack). Run the correspondingmake setup-*target first, and refer the comments in theMakefilefor known issues
Quick Query is licensed under the Apache License 2.0. See THIRD_PARTY_NOTICES for third-party attributions.