RELABEL_CONFIGS: drop namespace

28 views
Skip to first unread message

Nabil LAABID

unread,
Mar 24, 2020, 6:14:29 AM3/24/20
to Prometheus Users
Hi All,


I am currently facing with a relabel config issue.
I would like to drop all namespaces which not contain the word NAMESPACE1, 
For this aim I try with the following regex expression :


        relabel_configs:
        - source_labels: [__meta_kubernetes_namespace]
          regex: '^((?!NAMESPACE1).)*$'
          action: drop


But I am facing with a syntax error (invalid orunsupported Perl syntax: `(?!` )

level=error ts=2020-03-24T10:07:01.722Z caller=main.go:740 err="error loading config from \"/etc/prometheus/prometheus.yml\": couldn't load configuration (--config.file=\"/etc/prometheus/prometheus.yml\"): parsing YAML file /etc/prometheus/prometheus.yml: error parsing regexp: invalid or unsupported Perl syntax: `(?!`"


Any idea?

Thanks 

Nabil L.

Julien Pivotto

unread,
Mar 24, 2020, 6:16:48 AM3/24/20
to Nabil LAABID, Prometheus Users
On 24 Mar 03:14, Nabil LAABID wrote:
> Hi All,
>
>
> I am currently facing with a relabel config issue.
> I would like to drop all namespaces which not contain the word NAMESPACE1,
> For this aim I try with the following regex expression :
>

This is sufficient:


relabel_configs:
- source_labels: [__meta_kubernetes_namespace]
regex: '.*NAMESPACE1.*'
action: drop

>
>
> But I am facing with a syntax error (invalid orunsupported Perl syntax:
> `(?!` )
>
> level=error ts=2020-03-24T10:07:01.722Z caller=main.go:740 err="error
> loading config from \"/etc/prometheus/prometheus.yml\": couldn't load
> configuration (--config.file=\"/etc/prometheus/prometheus.yml\"): parsing
> YAML file /etc/prometheus/prometheus.yml: error parsing regexp: invalid or
> unsupported Perl syntax: `(?!`"
>
>
> Any idea?
>
> Thanks
>
> Nabil L.
>
> --
> 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 prometheus-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/7c58a3ec-cebc-4208-8bf4-5413f1e86146%40googlegroups.com.


--
(o- Julien Pivotto
//\ Open-Source Consultant
V_/_ Inuits - https://www.inuits.eu
signature.asc

Nabil L.

unread,
Mar 24, 2020, 6:32:02 AM3/24/20
to Prometheus Users
Thanks a lot Julien, I will try the expression based on your feedback.

In the same time I just realize the "keep" actions drops everything that doesn't match an expression ^^


Thanks again

Julien Pivotto

unread,
Mar 24, 2020, 6:33:52 AM3/24/20
to Nabil L., Prometheus Users
On 24 Mar 03:32, Nabil L. wrote:
> Thanks a lot Julien, I will try the expression based on your feedback.
>
> In the same time I just realize the "keep" actions drops everything that
> doesn't match an expression ^^
>
>
> Thanks again

Oh yes indeed you need keep.

:)


>
>
>
> Le mardi 24 mars 2020 11:14:29 UTC+1, Nabil L. a écrit :
> >
> > Hi All,
> >
> >
> > I am currently facing with a relabel config issue.
> > I would like to drop all namespaces which not contain the word NAMESPACE1,
> > For this aim I try with the following regex expression :
> >
> >
> > relabel_configs:
> > - source_labels: [__meta_kubernetes_namespace]
> > regex: '^((?!NAMESPACE1).)*$'
> > action: drop
> >
> >
> > But I am facing with a syntax error (invalid orunsupported Perl syntax:
> > `(?!` )
> >
> > level=error ts=2020-03-24T10:07:01.722Z caller=main.go:740 err="error
> > loading config from \"/etc/prometheus/prometheus.yml\": couldn't load
> > configuration (--config.file=\"/etc/prometheus/prometheus.yml\"): parsing
> > YAML file /etc/prometheus/prometheus.yml: error parsing regexp: invalid or
> > unsupported Perl syntax: `(?!`"
> >
> >
> > Any idea?
> >
> > Thanks
> >
> > Nabil L.
> >
>
> --
> 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 prometheus-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/3176fa9e-e7a7-4b37-b520-39ae8b0f618c%40googlegroups.com.
signature.asc
Reply all
Reply to author
Forward
0 new messages