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.
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.
@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",
]
}
/api/v1/labels
is fine for Prometheus users, but there are some inconsistent behaviors with Thanos, so just be careful when using this API
© 2022 - 2024 — McMap. All rights reserved.