How to query the latest value per timeserie in MetricsQL or PromQL?
For example, query metric_name
returns two timeseries for metric_name{job="foo"}
and metric_name{job="bar"}
for a long range:
{"metric":{"__name__":"metric_name","job":"foo"},"values":[.................. <long list>],
{"metric":{"__name__":"metric_name","job":"bar"},"values":[.................. <long list>]
Is there a way to get the latest value for each label? So that response would contain only two timestamps -- one for job="foo", and another for job="bar":
{"metric":{"__name__":"metric_name","job":"foo"},"values":[1510000000,123],
{"metric":{"__name__":"metric_name","job":"bar"},"values":[1610000000,321]
Have you tried to use
last_over_time
?See more details about MetricsQL here - https://github.com/VictoriaMetrics/VictoriaMetrics/wiki/MetricsQL
You might want to use
/api/v1/query
endpoint to get an instant query result.