pq - query textual streams with PromQL
Glossary
- Time Series - a stream of timestamped values, aka samples sharing the same metric name and, optionally, the same set of labels (i.e. a unique combination of key-value pairs).
- Metric name - a human-readable name of a measurement. E.g.
http_requests_total
,content_length
, etc). - Metric type - counter, gauge, histogram, and summary.
- Label - a dimension of the measurement. E.g.
method
,url
, etc. - Sample - aka data point - a (value, timestamp) tuple. Value is always float64 and timestamp is always with millisecond precision.
- Instant vector - a type of expression evaluation - a set of time series (vector) containing a single sample for each time series, all sharing the same timestamp.
- Range vector - a type of expression evaluation - a set of time series containing a range of data points over time for each time series.
- Scalar and string - two other expression evaluation results.
- Vector selector - expression of a form
<metric_name>[{label1=value1[, label2=value2, ...]}][[time_duration]]
.
Run
$ cargo test
$ cat | cargo run -- -d '([^\s]+)\s(\w+)\s(\d+)' -t '0:%Y-%m-%dT%H:%M:%S' -l 1:name -m 2:age -- '-age{name=~"(bob|sarah)", name!~"b.*"}' <<EOF
2021-01-01T05:40:41 bob 42
2021-01-01T23:59:58 sarah 25
2021-01-02T00:00:02 bob 42
2021-01-02T00:00:03 sarah 26
EOF
# Expected output:
InstantVector(InstantVector { instant: 1609545598000, samples: [({"name": "sarah", "__name__": "age"}, -25.0)] })
InstantVector(InstantVector { instant: 1609545599000, samples: [] })
InstantVector(InstantVector { instant: 1609545600000, samples: [] })
InstantVector(InstantVector { instant: 1609545601000, samples: [] })
InstantVector(InstantVector { instant: 1609545602000, samples: [] })
InstantVector(InstantVector { instant: 1609545603000, samples: [({"name": "sarah", "__name__": "age"}, -26.0)] })