@qxip/promql-parser-js
v0.2.2
Published
promql parser binding for node
Downloads
176
Readme
⚙️ promql-parser-js
PromQL parsing wasm module based on Rust crate promql-rs
Status
- Experiemental, don't use it!
Install
npm install @qxip/promql-parser-js
Functions
promql_parse
Usage
const { promql_parse } = require("@qxip/promql-parser-js"); // parse PromQL to JSON
const query = 'sum(rate(foo{bar="baz"}[5m])) by (x,y)';
try {
const parsed = promql_parse(query);
console.log(parsed);
} catch(e) { console.log(e) }
node js/index.js 'rate(foo{bar="baz"}[5m])'
{
"name": "rate",
"args": [
{
"name": "foo",
"label_matchers": [
{
"op": "Equal",
"name": "bar",
"value": "baz"
}
],
"offset": false,
"range": "300s"
}
],
"aggregation": false
}
Build
Rebuild wasm package release. Not needed for regular module usage.
npm install
npm run build
npm test
TODO
- [x] WASM binding + NODE module
- [ ] Convert
Expr
to json w/o Debug print - [ ] Implement test cases
- [ ] Document