I managed to figure this out. The key is to use the on() function which ignores the labels. The query now looks like this:
up{job="calculator"} == 0 and on() count(hour(vector(time())) >= 1 and hour(vector(time())) < 13) On Monday, February 8, 2021 at 3:33:51 PM UTC-6 Chad Thielen wrote: > Hello, > > I'm having some trouble writing a query for an alerting rule that we only > want to run at certain times of the day. This is what I original had, which > works, but not in the way we now need: > > > count(up{job="calculator"} == 0) and count(hour(vector(time())) >= 1 and > hour(vector(time())) < 13) > > Now our problem is that we need the instance label from the up metric to > persist to the alert so we can include it in the pager duty incident, > otherwise our engineers don't know what instance is down without checking > prometheus first. This is where I'm having problems, using count strips all > those labels and just basically gives a true or false of if the alert is > firing. > > Any suggestions? > -- 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 prometheus-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/b582828e-8828-468c-9d69-0f0cb70d29b2n%40googlegroups.com.