Thank you for that. Now you mention it, I do vaguely remember having been 
bitten by that before.

It might be worth a note in the documentation at
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs
where it says "It has the same configuration format and actions as target 
relabeling"

At
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
it then says:
Labels starting with __ will be removed from the label set after target 
relabeling is completed.

which is true, but on first reading I hadn't twigged that this applies only 
to *target* relabeling.

On Monday, 19 June 2023 at 12:50:45 UTC Julien Pivotto wrote:

> On 13 Jun 06:38, Brian Candler wrote:
> > Or use "__tmp_keep" as the temporary label, then you shouldn't need the 
> > labeldrop step.
>
> I think labeldrop is still needed. It would not be needed in regular
> relabel_configs, but for metric_relabel_config it's needed.
>
>
> > 
> > On Tuesday, 13 June 2023 at 14:01:16 UTC+1 Ben Kochie wrote:
> > 
> > > Negative lookahead regexp syntax is not supported.
> > >
> > > https://github.com/google/re2/wiki/Syntax
> > >
> > > What you can do is use use a temporary relabel to mark metrics as 
> "keep".
> > >
> > > Something like this:
> > > 
> > > metric_relabel_configs:
> > > # Drop the specific metric from all instances except primary
> > > - source_labels: [instance_name, __name__]
> > > regex: 'primary-00;mysql_info_schema_table_size'
> > > replacement: 'true'
> > > target_label: keep
> > > - source_labels: [__name__,keep]
> > > regex: 'mysql_info_schema_table_size;'
> > > action: drop
> > > - regex: keep
> > > action: labeldrop
> > >
> > > On Tue, Jun 13, 2023 at 2:51 PM pandrian <[email protected]> 
>
> > > wrote:
> > >
> > >> Hey guys im trying to basically drop a specific metric from a job 
> that 
> > >> has a couple of instances but keep it only for one instance is this 
> > >> possible? 
> > >>
> > >> i tried something like this but its not working. 
> > >>
> > >> metric_relabel_configs:
> > >> # Drop the specific metric from all instances except primary
> > >> - source_labels: [instance_name, __name__]
> > >> regex: '!^primary-00,mysql_info_schema_table_size'
> > >> action: drop
> > >>
> > >>
> > >> -- 
> > >> 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/46d8e23e-17b0-4f63-96cc-b8c5be3a2251n%40googlegroups.com
>  
> > >> <
> https://groups.google.com/d/msgid/prometheus-users/46d8e23e-17b0-4f63-96cc-b8c5be3a2251n%40googlegroups.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/de5be87e-54fc-4e00-a492-34b7bedb9fb9n%40googlegroups.com
> .
>
>
> -- 
> Julien Pivotto
> @roidelapluie
>

-- 
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/e3fe1c93-8d9b-4a14-ad17-d40916f8f77an%40googlegroups.com.

Reply via email to