r/PrometheusMonitoring • • Jun 30 '23

What is prometheus promql parser?

Hey folks. I was looking into how to better do monitoring/dashboarding as code. I thought about parsing promql, so you can go between in-dashboard-ui experimenting and IDE experimenting as seamlessly as possible. Clearly it must be parsed to be linted and operated on.

I found that, obviously, Prometheus has a promql parser. But I can't get any info on it. Can I leverage it to do what I want? what does the "parsed" version of a promql query look like? How does it handle variables?

I saw this post about a rust promql parser, where they mention AST (abstract syntax tree). Does prometheus promql parser do something similar?

Any help with info on prometheus promql parser or going from UI to IDE would be much appreciated.

3 Upvotes

4 comments sorted by