Thank you Brian. This is exactly what I was looking for. 

On Monday, March 27, 2023 at 12:30:31 PM UTC+5:30 Brian Candler wrote:

> There are actually a a couple of options.
>
> In each alerting rule (in prometheus) you can match on labels in the 
> actual alerting expression: e.g.
>
>         expr: node_boot_time_seconds > (node_boot_time_seconds offset 5m + 
> 5)
> becomes
>         expr: node_boot_time_seconds*{namespace="devsecops"}* > 
> (node_boot_time_seconds offset 5m + 5)
>
> But I'd say it's simpler and more flexible to allow all the alerts to 
> fire, but suppress the notifications in alertmanager routing rules:
>
> route:
>   receiver: noc
>   routes:
>     - receiver: discard
>       matchers:
>         - namespace!="devsecops"
>     # more routing rules if desired go here
>
> receivers:
>   - name: discard
>   - name: noc
>     email_configs:
>       - to: [email protected]
>         send_resolved: false
>
> Then you can *see* alerts firing in other environments in the prometheus 
> web UI (which helps you test and tune the rules), but notifications aren't 
> sent out for anything apart from devsecops.
>
> This does require that all the alerting expressions pass through a 
> namespace label. Pasting each alerting expression into the PromQL browser 
> in the Prometheus web UI will let you see exactly what timeseries values it 
> generates (including the labels), as long as it's generating at least one 
> alert of course.
>
> On Monday, 27 March 2023 at 06:56:58 UTC+1 Himanshu Gude wrote:
>
>> yes, I m new to prometheus env. could you pls give an example for each 
>> case, which will help me to figure out what changes to be made in the 
>> configurations. Your first case is what I am looking for. 
>> Thanks in advance! 
>>
>> On Sunday, March 26, 2023 at 9:20:38 PM UTC+5:30 Brian Candler wrote:
>>
>>> That's two different things you're asking.
>>>
>>> * alerting only from "devsecops" namespace: ensure every metric has a 
>>> label with the namespace, and configure alerting rules to match only where 
>>> namespace=devsecops
>>>
>>> * scraping only from one namespace: if you can't configure the scrape 
>>> URL to fetch only one namespace, then you can use metric_relabel_rules to 
>>> discard all metrics except the ones of interest (again, matching on some 
>>> namespace label to identify which ones to keep or drop)
>>>
>>> On Sunday, 26 March 2023 at 07:28:36 UTC+1 Himanshu Gude wrote:
>>>
>>>> Hello guys,
>>>>
>>>> There is a requirement in my project which states that, the client only 
>>>> wants alerts from "devsecops" namespace and alerts from all other 
>>>> namespaces should be ignored. which means alerts from namespaces other 
>>>> than 
>>>> "devsecops" should not be captured by the alertmanager and should not 
>>>> trigger tickets in ServiceNow.
>>>>
>>>> In short, prometheus should only scrape metrics from only one namespace 
>>>> ie; devsecops
>>>>
>>>> would really appreciate some sort of hel here.
>>>> Thanks in advance....
>>>>
>>>

-- 
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/98a6a9fa-50f4-4144-9877-015e6aae8243n%40googlegroups.com.

Reply via email to