Package metricsql implements MetricsQL and PromQL parser in Go.
expr, err := metricsql.Parse(`sum(rate(foo{bar="baz"}[5m])) by (job)`)
if err != nil {
// parse error
}
// Now expr contains parsed MetricsQL as `*Expr` structs.
// See Parse examples for more details.
See docs for more details.