You can use regular expression matching or not-equals matching.
some_metric_name{some_label!=""}
This will match any metric where the label is present.
On Thu, Dec 3, 2020 at 10:06 AM lizhihua0925 <[email protected]> wrote:
> Hi,
>
>
> It is not same.
>
>
> What I want to do is limit the rule to eval metrics which have the
> spcified label.
>
>
> Kind regards,
> Allenzh li
>
>
> 在 2020年12月3日 16:53,Christian Hoffmann<[email protected]> 写道:
>
> Hi,
>
> On 12/3/20 9:48 AM, Allenzh li wrote:
> > Exactly, I develop a API which accept prometheus rule from web.
> > When user create a new rule, I want to add a fixed matcher(xxId="xxx"),
> > which label name is fixed and label value is various.
> >
> > eg.
> > cpu_usage / avg_over_time(cpu_usage[5m] offset 24h) > 2 ->
> > cpu_usage{xxId="xxx"} / avg_over_time(cpu_usage{xxId="xxx"}[5m] offset
> > 24h) > 2
> So it seems like your web application will only handle the
> alert-specific PromQL expression which ends up in the alert's "expr" field.
>
> It seems like it would be straight forward to add the static label with
> the dynamic value directly into the Prometheus alert using the labels:
> field?
> https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/
> (Ctrl+F "severity: page")
>
> Kind regards,
> 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/tencent_C7312B3EC100B4BCD59505CC%40qq.com
> <https://groups.google.com/d/msgid/prometheus-users/tencent_C7312B3EC100B4BCD59505CC%40qq.com?utm_medium=email&utm_source=footer>
> .
>
--
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/CABbyFmqFqY-Z30vc5Xa1LPq2xMnvduPW9iBM9iujpn3EQwCKpQ%40mail.gmail.com.