添加两个指标以及每个串联数量
我有两个自定义指标:
api_success,api_failure
api_success具有“端点”的标签,并且api_failure具有“端点”的标签,一个标签“ errir_code”标签,
我很难编写一个查询,这将为我们提供总数通过将这些指标添加在一起,每个端点提出的请求。
显而易见的答案是这样的:
sum by (endpoint) (rate(api_success[5m])) + sum by (endpoint) (rate(api_failure[5m]))
但是,这实际上无效。在某些情况下,端点可能没有故障,因此Prometheus无法从左侧到右侧的向量匹配,而端点根本根本没有显示为系列。我已经阅读了此页面: https:/ /prometheus/最新/查询/operators/#向量匹配前后,寻找解决方案,以胁迫右侧以使左侧的所有系列都具有所有左侧的系列,并为所有缺失的系列使用零。
这似乎是一个基本的用例,我不敢相信我没有找到答案。
I have two custom metrics:
api_success, api_failure
api_success has a label for "endpoint", and api_failure has a label for "endpoint" and a label for "error_code"
I'm having difficulty writing a query that will give us the total number of requests made per endpoint, by adding these metrics together.
The obvious answer is something like this:
sum by (endpoint) (rate(api_success[5m])) + sum by (endpoint) (rate(api_failure[5m]))
however, this doesn't actually work. In some cases, an endpoint could have no failures, so prometheus is unable to match the vector from the left side to the right side, and the endpoint simply doesn't show up as a series at all. I have read this page: https://prometheus.io/docs/prometheus/latest/querying/operators/#vector-matching front and back looking for a solution to coerce the right side to have all of the series that the left side does, and use zeroes for all missing series.
This seems like such a basic use case, I can't believe I haven't found an answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论