Prometheus promql: Difference between revisions
From wikinotes
No edit summary |
|||
Line 30: | Line 30: | ||
== Strings == | == Strings == | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="yaml"> | ||
// string | // string | ||
"foo" | "foo" |
Revision as of 00:46, 18 February 2022
PromQL is prometheus's query language.
It's syntax is inspired by golang.
You can query prometheus from
- HTTP API
- in the UI's graph?
Documentation
official docs https://prometheus.io/docs/prometheus/latest/querying/basics/ official examples https://prometheus.io/docs/prometheus/latest/querying/examples/ re2 (regex engine) https://github.com/google/re2/wiki/Syntax
Comments
# a comment
Datatypes
Strings
// string "foo" `foo` // string-literal 'foo\nbar'Floats
23 -2.43 3.4e-9 0x8f -Inf NaN
Queries
Metric-Selector
The most basic query you can use is
your_metric_name
which queries all samples for that metric.
These metric selectors can be composed and filtered.{__name__="your_metric_name"} // query all (you can match multiple metrics this way) your_metric_name // query all your_metric_name[5min] // lump data into 5min clumps your_metric_name{job="foo",group="bar"} // filter by metric-labelsOperators
label metrics support various matchers/operators
= // equal != // not-equal =~ // regex match !~ // not regex matchClustering Metrics
TODO:
are these aggregates averages? sums? greatest-value?
your_metric_name[5min] // lump data into 5min clumpsUnits
ms // milliseconds s // seconds m // minutes h // hours d // days w // weeks y // yearsQuery Time Ranges
your_metric_name offset 5min // query 5min-ago until present your_metric_name @ 1609746000 // query at exactly '2021-01-04T07:40:00+00:00'