Try the following relabeling rules:
- source_labels: [mountpoint]
regex: '(/home|/var/domains)/something.*'
target_label: __keep
replacement: yes
- source_labels: [mountpoint]
regex: ''
target_label: __keep
replacement: yes
- source_labels: [__keep]
regex: yes
action: keep
The first relabeling rule adds {__keep="yes"} label to metrics with
mountpoint matching the given regex. The second relabeling rule adds
{__keep="yes"} label to metrics with empty `mountpoint` label, e.g. metrics
without this label. The last relabeling rule drops all the metrics
without {__keep="yes"} label. See
https://www.robustperception.io/or-in-relabelling .
On Fri, Jun 18, 2021 at 8:24 PM Julian v.d Berkmortel <
[email protected]> wrote:
> Right now I'm scraping metrics from a Node Exporter. Some of the metrics
> which the Node Exporters exports have a `mountpoint` label.
>
> I'd like to drop time series that have this label and **do not** match a
> regular expression. I tried using the `keep` action (as I'd like to keep
> time series that **do** match this regular expression) but this also drops
> all other metrics that do not have the `mountpoint` label.
>
> "metric_relabel_configs:
> - source_labels: ['mountpoint']
> regex: '(\/home|\/var\/domains)\/something.*'
> action: keep"
>
> I tried using the `drop` action too but this requires me to inverse the
> regular expression using a negative-lookahead (which isn't supported
> because Prometheus is written in Go of course).
>
> What are my options in this?
>
> **Important,** I do not have control over the way the Node Exporter is
> configured, thus I can't configure the Node Exporter itself to not export
> metrics for some specific mountpoint (if this is even possible).
>
> --
> 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/e2bf0768-8213-4c35-b0e0-4c03395ffdc6n%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/e2bf0768-8213-4c35-b0e0-4c03395ffdc6n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Best Regards,
Aliaksandr Valialkin, CTO VictoriaMetrics
--
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/CAPbKnmBxStnOXvZODe20RAJEbFaLwMVmV6YP8r2j%2Bf9dwVAKWg%40mail.gmail.com.