Is there a way in promql to get all the available label names using thanos api?
Asked Answered
E

3

6

I have a promql which is giving me the metric result as a whole from the server, but I am interested in filtering and getting results of a specific value, but I am not sure what can be the label name for that value, if I can see all the available names I will be able to at least hit it using trial and error, but without the label names, I am not able to do anything.

Expedite answered 29/6, 2020 at 2:35 Comment(0)
W
13

While PromQL doesn't provide functionality for returning all the available label names, Prometheus querying API provides such functionality via /api/v1/labels handler.

This handler supports optional start and end query args, which may be used for limiting time range for the returned label names. It also supports match[] query args, which may be used for additional filtering on time series. For example, request to /api/v1/labels?match[]=foo{bar="baz"} would return only label names for time series matching foo{bar="baz"} time series selector. See these docs for more details.

Wiper answered 16/7, 2020 at 18:16 Comment(0)
Y
1

@valyala's answer is helpful for label/metric names. But if you want to get all the values of a label, you can call /api/v1/label/{YOUR_LABEL_NAME}/values. See the docs. For example:

$ curl http://localhost:9090/api/v1/label/instance/values
{
   "status" : "success",
   "data" : [
      "node1",
      "node2",
      "node3",
   ]
}
Yellowstone answered 21/4, 2023 at 21:56 Comment(0)
F
1

/api/v1/labels is fine for Prometheus users, but there are some inconsistent behaviors with Thanos, so just be careful when using this API

Fabrikoid answered 16/10, 2023 at 6:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.