'How to get all labels with count by?
I have a set of metrics:
metric1{test_title="Title 1", state="passed", report_url="https://"}
metric2{test_title="Title 2", state="failed", report_url="https://"}
metric3{test_title="Title 3", state="failed", report_url="https://"}
metric4{test_title="Title 4", state="passed", report_url="https://"}
I want to collect data and send an alert if the particular test fails more than 2 times in a row within 90 minutes and include report_url in the alert message.
I've tried:
count by (test_title, report_url)
(count_over_time(
{__name__=~"metric(.*)", state="failed"}[90m]
)
) > 2
In this case, I receive the following result if test fails more than 2 times within 90m:
{test_title="Title 2", state="failed", report_url="https://"}
{test_title="Title 2", state="failed", report_url="https://"}
{test_title="Title 2", state="failed", report_url="https://"}
The goal is to receive just one record with the latest report_url:
{test_title="Title 2", state="failed", report_url="https://"}
But since the report_url is unique within the vector I haven't received the desired effect. If I remove report_url from the query the timeline builts correctly but in this case, the report_url is not added to labels and I don't know how to pass this URL to alert.
Can somebody advise some solution for this? Thank you in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
