26

We have a hierachical prometheus setup with some server scraping others. We'd like to have some servers scrape all metrics from others.

Currently we try to use match[]="{__name__=~".*"}" as a metric selector, but this gives the error parse error at char 16: vector selector must contain at least one non-empty matcher.

Is there a way to scrape all metrics from a remote prometheus without listing each (prefix) as a match selector?

tex
  • 2,051
  • 1
  • 23
  • 27

6 Answers6

24

Yes, you can do: match[]="{__name__=~".+"}" (note the + instead of * to not match the empty string).

Prometheus requires at least one matcher in a label matcher set that doesn't match everything.

Julius Volz
  • 688
  • 4
  • 6
  • 3
    I found __name__=~"..*" worked okay on prom 2.0.0. Careful with the unnecessary " outside the {}. – fche Mar 07 '18 at 23:26
15

I have tried multiple example, even the ones from prometheus docs but nothing worked.

Instead this works for me

http://prometheus-ip:9090/federate?match[]={job!=""}
Radu Toader
  • 1,521
  • 16
  • 23
6

Federation is not intended to transfer all metrics, and if you try to do so you'll eventually run into problems.

Instead, aggregate up the metrics you want and then federate only those.

brian-brazil
  • 31,678
  • 6
  • 93
  • 86
  • 5
    Thanks for the warning. I'll keep that in mind when we run into trouble, but for now I'm sure scraping all metrics is going to be fine. We'll come back to pre-aggreation when things settle and we have a better understanding of what we need to look up for and what not. – tex Sep 01 '16 at 07:49
2

Here is mine config file.

With this limits you can filter from which exporters (jobs) to scrape:

  params:
    'match[]':
    - '{job=~"node-exporter|kube-state|fluentbit"}'
    - '{__name__=~"job:.*"}'
SQERISON
  • 21
  • 1
1

Add these in your federation job

    params:
      match[]:
        - '{__name__=~".+"}'
        - '{__name__=~"^job:.*"}'
        - '{job="prometheus"}'
        - '{job="node"}'
        - '{__name__="server_labels"}'
Sachin Arote
  • 907
  • 13
  • 22
1

I was trying to reach the same config, and after trying multiple solutions, the one that actually worked for me was:

params:
  match[]:
    - '{job=~".+"}'

This simple settings collected all the metrics which had job. The same didn't work with {__name__=~"job:.*"}.

Chen A.
  • 10,140
  • 3
  • 42
  • 61