@Greptime: 我们刚刚发布了 promql-parser v0.9.0,这是一个用 Rust 编写的 PromQL 解析器。亮点:• 函数的声明式重构 • fill*…
摘要
Greptime 发布了 promql-parser 0.9.0 版本,这是一款基于 Rust 的 PromQL 解析器,具有声明式函数重构功能,并支持 limit 函数。
查看缓存全文
缓存时间: 2026/05/12 08:48
我们刚刚发布了 promql-parser v0.9.0,这是一个用 Rust 编写的 PromQL 解析器。亮点包括:• 函数的声明式重构 • fill*() 二元操作符修饰符 • 用于 AST 遍历的可变访问者 trait • 支持 limitk 和 limit_ratio 详情:https://github.com/GreptimeTeam/promql-parser/releases/tag/v0.9.0… #PromQL #Rust
GreptimeTeam/promql-parser
Source: https://github.com/GreptimeTeam/promql-parser
License (https://github.com/GreptimeTeam/promql-parser/blob/main/LICENSE) Build Status (https://github.com/GreptimeTeam/promql-parser/blob/main/.github/workflows/ci.yml) Version (https://crates.io/crates/promql-parser) codecov (https://app.codecov.io/gh/GreptimeTeam/promql-parser/tree/main)
PromQL 词法分析器和解析器
本项目的目标是构建一个 PromQL 词法分析器和解析器,能够解析符合 Prometheus 查询 规范的 PromQL。
示例
解析一个简单的瞬时向量选择器表达式:
`` rust use promql_parser::parser;
let promql = r#“ http_requests_total{ environment=~“staging|testing|development”, method!=“GET” } offset 5m “#;
match parser::parse(promql) { Ok(expr) => { println!(“Prettify:\n{}\n”, expr.prettify()); println!(“AST:\n{expr:?}”); } Err(info) => println!(“Err: {info:?}”), } ``
或者你可以直接运行本仓库下的示例:
shell cargo run --example parser
输出如下:
``rust Prettify: http_requests_total{environment=~“staging|testing|development”,method!=“GET”} offset 5m
AST: VectorSelector(VectorSelector { name: Some(“http_requests_total”), matchers: Matchers { matchers: [Matcher { op: Re(staging|testing|development), name: “environment”, value: “staging|testing|development” }, Matcher { op: NotEqual, name: “method”, value: “GET” }] }, offset: Some(Pos(300s)), at: None }) ``
PromQL 兼容性
本 crate 声明与 prometheus v3.8 兼容,该版本发布于 2025-11-28。此后对 PromQL 的任何修订均不保证兼容。
社区扩展
有许多社区项目扩展了 promql-parser 或提供了与其他系统的集成。
语言绑定
- py-promql-parser (https://github.com/messense/py-promql-parser) Python。
- lua-promql-parser (https://github.com/mtrbpr/lua-promql-parser) Lua。
已知使用情况
以下是一些已知使用 promql-parser 的项目:
- GreptimeDB (https://github.com/GreptimeTeam/greptimedb) 开源云原生分布式时序数据库
- OpenObserve (https://github.com/openobserve/openobserve) 高性能、PB 级 Elasticsearch/Splunk/Datadog 替代品,支持(日志、指标、链路追踪、RUM、错误追踪、会话回放)
如果你的项目正在使用 promql-parser,欢迎提交 PR 将其添加到列表中。
贡献
我们非常鼓励贡献!
针对 PromQL 功能增加支持或修复 bug 的 Pull Request 在审核后将很可能被接受。
许可
本仓库中的所有代码均遵循 Apache License 2.0。
除非你明确声明其他内容,否则任何有意提交以包含在本作品中的贡献(如 Apache-2.0 许可中定义),均以上述许可提供,无任何附加条款或条件。
相似文章
@Greptime: GreptimeDB v1.1.0 发布,PromQL rate/increase 查询速度提升高达97%,整体查询时间降低20-40%,TS… 上速度提升高达4.5倍
GreptimeDB v1.1.0 已发布,提供高达97%的PromQL查询加速,整体查询时间降低20-40%,在TSBS扫描密集型查询上性能提升高达4.5倍,并支持对现有表进行在线重分区。
@jerryjliu0: LiteParse,我们的开源/基于Rust的文档解析器,运行速度之快,连Claude Fable 5都难以置信 🔥
LiteParse 是一款快速的开源文档解析器,采用 Rust 编写,提供带边界框的高质量空间文本提取功能,支持多种语言和平台,适用于 AI 文档工作负载。
@Greptime: 关于Prometheus远程写入,瓶颈并非网络或memtable——而是Region Worker在dec…时持有&mut
GreptimeDB v1.0引入了Pending Rows Batcher,这是一个三阶段流水线,将CPU密集型工作从Datanode的关键路径上移开,使Prometheus远程写入吞吐量从120万提升到217万points/sec,并将Datanode的CPU使用率降低20%。
@thomasp85:我激动万分,终于可以揭开我们2026年所做工作的神秘面纱:请认识 ggsql!一个全新的扩展……
Posit 宣布推出 ggsql 的 alpha 版本。ggsql 是一种新的 SQL 语言扩展,将图形语法风格的数据可视化引入 SQL,兼容 Quarto、Jupyter notebooks、Positron 和 VS Code。用户可以使用受 ggplot2 启发的熟悉 SQL 语法,创建分层、结构化的可视化图表。
@Greptime: GreptimeDB 的扁平格式查询现在可以在任何列上预过滤——标签、字段、时间戳——而不仅仅是主键。而…
GreptimeDB 的扁平格式查询现在支持在任何列(标签、字段、时间戳)上预过滤,而不仅仅是主键,性能提升高达 4.5 倍。此外,mito2 存储引擎移除了其遗留扫描路径,清理了约 1800 行代码。