I changed the query to count_over_time of the metric for 1m and that worked. Even though the particular labels are available only for 15s or less, the count_over_time made it available long enough to trigger the alert. Thanks for pointer. I was not checking the value earlier.
Thanks, Bose On Tuesday, October 20, 2020 at 3:40:55 AM UTC-4 Stuart Clark wrote: > On 19/10/2020 22:02, Arnav Bose wrote: > > Hi, > > > > I have a metric which sends data only in case of a specific event. In > > other words, it will not have regular continuous telemetry every 15 > > seconds, but it will be there for a single data point. Now, I > > configured an alert to check if the metric exists (did not include any > > 'for' condition in the rule as there is no need to wait), an alert > > should trigger. What is happening is that when the metric becomes > > available in Prometheus, the rule gets activated to yellow, but > > instead of firing, it automatically goes away within 15 seconds. Is > > there some additional setting I have to do to alert on event based > > metric which lasts for only 1 single datapoint or 15s ? > > > > As Brian mentions the metric should continue to exist, rather than > regularly disappearing. Normally you would use a counter which is > incremented every time an event happens. Are you using one of the > Prometheus client libraries, as these should make it very easy to setup? > > -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/8ac6fa37-0b24-4b32-b817-b7ef5976ff93n%40googlegroups.com.

