Thanks, Christian.
It semms your answer would solve our current issue.

The reason to repeat it is, as we are using metrics from pushgateway, if we 
write template as follows, It's not returning the jobs or instances values

       expr: avg without (cpu) (sum without (mode) (1 - 
rate(node_cpu_seconds_total{mode="idle"}))) > 0.90

I will test it mentioned format and write back

On Monday, 10 August 2020 at 11:25:07 UTC+5:30 Christian Hoffmann wrote:

> Hi,
>
> On 8/10/20 7:06 AM, Aravind Poojari wrote:
> > We are facing an issue while writing alert rules for the above jobs &
> > instances.
> > We are unable to use a template so we have to write the alert rules for
> > each and every job and their respective instances. It's kind of hard as
> > instances keep on increasing every day. Following is an example of alert
> > rule how we are using configuration
> > 
> > ##Alert rule config
> > ---
> >     - alert: HighCPU-Critical
> >       expr:
> > instance:node_cpu_utilization:ratio{job="node-exporter-test",
> > instance="instance-two",  mode="idle"} > 0.90
> >       for: 1m
> >       labels:
> >         severity: critical
> >       annotations:
> >         title: CPU use percent is extremely high on {{ $labels.instance
> > }} for the past 10 minutes.
> > 
> >     - alert: HighCPU-Critical
> >       expr:
> > instance:node_cpu_utilization:ratio{job="node-exporter-test",
> > instance="instance-two",  mode="idle"} > 0.90
> >       for: 1m
> >       labels:
> >         severity: critical
> >       annotations:
> >         title: CPU use percent is extremely high on {{ $labels.instance
> > }} for the past 10 minutes.
> > ------
> > We have to repeat the same for every job and their instances. Let us
> > know if we can use variables for all jobs & instance values may be
> > something like this [I ain't sure].
>
> What's your reason for repeating the rules for each server?
>
> Prometheus does not have any concept of objects or servers (in contrast
> to other monitoring systems). This means that you can design your
> queries rather freely.
>
> To be more specific: If you want to monitor all configured targets, just
> drop the instance= label. If you want to continue explicitly listing
> your targets there, you can still simplify by using regular expressions
> (instance=~"instance1|instance2|instance3"}). The same is true for
> recording rules.
>
> Hope this helps.
>
> Christian
>

-- 
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/bb02c788-1113-436b-9c30-03a1fcb40aa0n%40googlegroups.com.

Reply via email to