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 prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/21fc61ed-daba-5983-b4f8-fad2cd67ce19%40hoffmann-christian.info.

Reply via email to