node-metricsql

Native MetricsQL and PromQL parser binding

Usage no npm install needed!

<script type="module">
  import nodeMetricsql from 'https://cdn.skypack.dev/node-metricsql';
</script>

README

node-metricsql

Native node binding for MetricsQL Parser

Build Module

make

Usage

const metricsql = require('node-metricsql');
const parsed = metricsql.parse(promql);

Test Module

node example.js 'sum(rate(foo{bar="baz"}[5m]))'
{
   "Name":"sum",
   "Args":[
      {
         "Name":"rate",
         "Args":[
            {
               "Expr":{
                  "LabelFilters":[
                     {
                        "IsNegative":false,
                        "IsRegexp":false,
                        "Label":"__name__",
                        "Value":"foo"
                     },
                     {
                        "IsNegative":false,
                        "IsRegexp":false,
                        "Label":"bar",
                        "Value":"baz"
                     }
                  ]
               },
               "Window":"5m",
               "Offset":"",
               "Step":"",
               "InheritStep":false
            }
         ]
      }
   ],
   "Modifier":{
      "Args":[
         "x",
         "y"
      ],
      "Op":"by"
   }
}

Todo

  • go binding
  • function mapping
  • format conversion