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/87861f5c-56eb-4d6f-89ea-497732a0af6fn%40googlegroups.com.