Yes.
That’s exactly what I was looking for. Thank you very mach. Kind regards, Allenzh li 在 2020年12月3日 17:17,Christian Hoffmann<[email protected]> 写道: Hi, On 12/3/20 10:06 AM, lizhihua0925 wrote: > What I want to do is limit the rule to eval metrics which have the > spcified label. Ah, I understood that you wanted to add labels, but you already said that you wanted to add matchers. So, just to confirm that I understand correctly: If the user enters the expression 'foo > 1' it should automatically be modified to read 'foo{some_static_label="some_dynamic_value"} > 1', right? So, basically you are looking for a way to programatically modify PromQL expressions. This is possible, prefereable by using Go as that's where the reference PromQL parser happens to be. That sounds like what I'm doing in the prometheus-filter-proxy except that I'm modifying in-flight requests while you want to modify PromQL expressions in alerts. You could still use the same pattern: * Parse the expression * Traverse all relevant selectors * Add the matcher you want * Convert to string representation again For reference: https://github.com/hoffie/prometheus-filter-proxy/blob/master/filter.go#L57 There are other projects which do similar things, e.g. in the Kubernetes/OpenShift ecosystem. This may provide further inspiration. :) 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_B2435D294A2494E47401C847%40qq.com.

