英文:
Grafana label_values regex to capture uri without query parameter
问题
label_values(http_client_requests_seconds_count, uri)
英文:
I've created a repeating panel per API that my application calls, showing the http status returned.
The query that I could write for the variable so far is:
label_values(http_client_requests_seconds_count, uri)
And the selector is populated with URIs like:
/user/accounts
/user/contact_info
/account/details?accnr=1234
/account/details?accnr=5678
How should the query look like in order to omit the query parameter and get the result as:
/user/accounts
/user/contact_info
/account/details
答案1
得分: 1
我明白你的请求。以下是翻译好的部分:
你应该使用 Regex: (.*?)(\?.*)?
(位于查询右下方的字段)
它将从你的数值中移除 ?
和后面的所有内容,并在此之后应用不同的方法。
你无法通过查询来实现这一点,主要是因为即使 label_values
严格来说不是 Prometheus 查询的一部分。label_values
是 Grafana 用于从 Prometheus(以及类似的系统)指标中提取标签的函数。
英文:
You should use Regex: (.*?)(\?.*)?
(field located right under Query)
It will remove ?
and everything what follows it from your values. And also applies distinct after it.
You can't do this through query, mostly because even label_values
is not part of query to Prometheus strictly speaking. label_values
is Grafana's function for extraction of labels from Prometheus' (and alike) metrics.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论