{"id":33918727,"url":"https://github.com/sintef/rusty-promql-parser","last_synced_at":"2026-01-13T22:55:05.087Z","repository":{"id":327646646,"uuid":"1110196552","full_name":"SINTEF/rusty-promql-parser","owner":"SINTEF","description":"Rust port of the Prometheus PromQL parser.","archived":false,"fork":false,"pushed_at":"2025-12-05T09:08:05.000Z","size":145,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-08T05:51:57.126Z","etag":null,"topics":["parser","prometheus","promql"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SINTEF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-12-04T21:08:22.000Z","updated_at":"2025-12-05T14:30:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/SINTEF/rusty-promql-parser","commit_stats":null,"previous_names":["sintef/rusty-promql-parser"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/SINTEF/rusty-promql-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SINTEF%2Frusty-promql-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SINTEF%2Frusty-promql-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SINTEF%2Frusty-promql-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SINTEF%2Frusty-promql-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SINTEF","download_url":"https://codeload.github.com/SINTEF/rusty-promql-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SINTEF%2Frusty-promql-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28400398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parser","prometheus","promql"],"created_at":"2025-12-12T08:30:58.886Z","updated_at":"2026-01-13T22:55:05.079Z","avatar_url":"https://github.com/SINTEF.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rusty PromQL Parser\n\n[![Crates.io](https://img.shields.io/crates/v/rusty-promql-parser.svg)](https://crates.io/crates/rusty-promql-parser)\n[![Documentation](https://docs.rs/rusty-promql-parser/badge.svg)](https://docs.rs/rusty-promql-parser)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)\n\nRust port of the Prometheus [PromQL parser](https://github.com/prometheus/prometheus/tree/main/promql/parser) using the [nom](https://github.com/rust-bakery/nom) parser combinator library.\n\n## Examples\n\n### A metric with label filtering\n\n```rust\nuse rusty_promql_parser::expr;\n\nlet input = r#\"go_gc_duration_seconds{instance=\"localhost:9090\", job=\"alertmanager\"}\"#;\nlet (rest, ast) = expr(input).expect(\"failed to parse\");\nassert!(rest.is_empty());\nprintln!(\"{:#?}\", ast);\n```\n\n```text\nVectorSelector {\n    name: Some(\"go_gc_duration_seconds\"),\n    matchers: [\n        LabelMatcher { name: \"instance\", op: Equal, value: \"localhost:9090\" },\n        LabelMatcher { name: \"job\", op: Equal, value: \"alertmanager\" }\n    ],\n}\n```\n\n### Aggregation operators\n\n```rust\nuse rusty_promql_parser::expr;\n\nlet input = r#\"sum by (app, proc) (\n  instance_memory_limit_bytes - instance_memory_usage_bytes\n) / 1024 / 1024\"#;\nlet (rest, ast) = expr(input).expect(\"failed to parse\");\nassert!(rest.is_empty());\nprintln!(\"{:#?}\", ast);\n```\n\n```text\nBinaryExpr {\n    op: Div,\n    lhs: BinaryExpr {\n        op: Div,\n        lhs: Aggregation {\n            op: \"sum\",\n            expr: BinaryExpr {\n                op: Sub,\n                lhs: VectorSelector { name: Some(\"instance_memory_limit_bytes\"), ... },\n                rhs: VectorSelector { name: Some(\"instance_memory_usage_bytes\"), ... },\n            },\n            grouping: Some(Grouping { action: By, labels: [\"app\", \"proc\"] })\n        },\n        rhs: Number(1024.0),\n    },\n    rhs: Number(1024.0),\n}\n```\n\n## ⚠️ Vibecoded ⚠️\n\nThis project is mostly vibecoded, using the official [Prometheus PromQL parser](https://github.com/prometheus/prometheus/tree/main/promql) (Apache 2.0) and a [Rust port by HewlettPackard](https://github.com/HewlettPackard/prometheus-parser-rs) (MIT) as reference. You are welcome.\n\n## Why?\n\nThe main goal was to experiment whether vibecoding technology of December 2025 could allow one to port a non-trivial piece of software from Golang to Rust, in a reasonable time frame. Apparently, yes. It took a few hours.\n\n## Testing\n\nThe advanced stochastic parrots were requested to import the test cases from the original Prometheus parser to ensure some compatibility.\n\nIn addition to the unit tests, we run some AFL fuzzing to ensure robustness against malformed inputs. One crash was found and fixed during development: a number overflow panic when dealing with long durations and unit conversions.\n\nThis is not perfect, but unit tests, fuzzing, nom combinators, and Rust, should make this parser reasonably robust.\n\n## You may not want to use this in production\n\nAs stated in the license, this is provided as-is, without warranty of any kind. It is also vibecoded.\n\nBut it's also relatively well tested and based on solid foundations with nom and rust, and of course the original Prometheus parser and its exhaustive test suite.\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgements\n\nThis project is ported from Prometheus' [`promql/parser`](https://pkg.go.dev/github.com/prometheus/prometheus/promql/parser).\n\nThe project supports the [Smart Building Hub](https://smartbuildinghub.no/) research infrastructure project, which is funded by the [Norwegian Research Council](https://www.forskningsradet.no/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsintef%2Frusty-promql-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsintef%2Frusty-promql-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsintef%2Frusty-promql-parser/lists"}