Sorry, "target" probably should be "targetLabel" in your k8s setup (it's "target_label" in regular prometheus)
On Wednesday, 14 June 2023 at 11:24:45 UTC+1 Brian Candler wrote: > The solution should be the same as this recent thread: > https://groups.google.com/g/prometheus-users/c/gy510HjV-Sw > > 1. Set a label like __tmp_keep to any string, for those metrics you want > to keep > > *- sourceLabels: [__name__] ** regex: **kube_namespace_created** > replacement: 'true'** target: __tmp_keep* > > > 2. Then only drop those for which __tmp_keep is empty (unset) > > *- sourceLabels: [namespace,__tmp_keep] ** regex: 'z{3,6};'** action: > drop* > > On Wednesday, 14 June 2023 at 11:00:40 UTC+1 Edoardo Beltramo wrote: > >> Hello, >> >> I’m facing an issue where I can’t properly save a metric; >> Inside a k8s cluster I have a rule inside a *servicemonitor.yaml* file >> that drops any metric coming from namespaces that match a specific regex, >> something like: >> * - sourceLabels: [namespace] ** regex: z{3,6} ** action: drop* >> >> this works, but now I have to implement a way to save a single metric, >> specifically *kube_namespace_created* before dropping all the others, >> only for those namespace that match the regex. >> >> Can someone give me an heads up? Thanks >> > -- 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/8703ea63-fe98-451b-b925-8b4ecb36ad84n%40googlegroups.com.

