Skip to content

mtrbpr/lua-promql-parser

Repository files navigation

PromQL Lexer and Parser

The goal of this project is to build a PromQL parser.

Example

To parse a simple instant vector selector expression:

local promql = require("promql_parser")

local promql_str = "http_requests_total{environment=~\"staging\", method!=\"GET\"} offset 5m"

local parts, err = promql.parse(promql_str)

Output

{
  matchers = { {
      name = "environment",
      type = "=~",
      value = "staging"
    }, {
      name = "method",
      type = "!=",
      value = "GET"
    } },
  name = "http_requests_total",
  offset = 300000.0,
  type = "vectorSelector"
}

Language Binding

This is a lua language binding to the original promql-parser repo.

Installation

luarocks install lua-promql-parser

About

Lua PromQL parser

Resources

License

Stars

Watchers

Forks

Packages

No packages published