Skip to main content

logql/
lib.rs

1//! # LogQL Front-End
2//!
3//! Lexing (and, in later phases, parsing and SQL transpilation) for
4//! Loki's LogQL query language. LogQL queries start from a stream
5//! selector (`{service_name="api"}`), optionally followed by a pipeline
6//! of line filters and parser stages, or wrapped in range/vector
7//! aggregations for metric queries.
8//!
9//! ## Modules
10//!
11//! - [`token`]: token type produced by the lexer
12//! - [`lexer`]: hand-rolled tokenizer with line/column error reporting
13//! - [`ast`]: abstract syntax tree for log queries
14//! - [`metric`]: abstract syntax tree for metric queries
15//! - [`parser`]: recursive-descent parser over the token stream
16
17pub mod ast;
18pub mod lexer;
19pub mod metric;
20pub mod parser;
21pub mod token;
22
23pub use ast::{
24    FilterOp, FilterValue, Grouping, LabelExtraction, LabelFilterExpr, LabelFilterPred,
25    LabelFormat, LabelFormatValue, LabelMatcher, LabelPredicate, LineFilter, LineFilterOp,
26    LogQuery, LogfmtStage, MatchOp, PipelineStage, StreamSelector, Unwrap,
27};
28pub use lexer::{LexError, tokenize};
29pub use metric::{
30    AggregationFunction, BinOp, BinaryExpr, LabelReplace, MetricQuery, RangeAggregation,
31    RangeFunction, VectorAggregation, VectorMatch,
32};
33pub use parser::{Expr, ParseError, parse, parse_query, parse_selector};
34pub use token::{SpannedToken, Token};