QubitProducts / exporter_exporter

A reverse proxy designed for Prometheus exporters
Apache License 2.0
332 stars 55 forks source link

Return multiple module data in one call #93

Closed zsalab closed 1 year ago

zsalab commented 1 year ago

I am not sure is that the proper way or I am doing something wrong but when I configured my prometheus (v2.33.5) as

  - job_name: 'myjob'
    scheme: 'https'
    metrics_path: '/proxy'
    params:
      module:
      - 'node'
      - 'nginx'
      - 'mysqld'
      - 'php-fpm'
      - 'postgres'
    static_configs:
      - targets:
        - 'targethost:9998'
        labels:
          environment: 'staging'

I see on the target:

May 11 07:09:05 targethost prometheus-exporter-exporter[1422569]: time="2023-05-11T07:09:05+02:00" level=info msg="10.28.1.1 - GET \"/proxy?module=node&module=process&module=nginx&module=mysqld&module=php-fpm&module=postgres\" 200 OK (took 108.894097ms)"

But only the node metric shown up in the Prometheus, so I executed the following on the node runs the prometheus

wget -O - 'https://treebeard.login.hu:9998/proxy?module=node&module=nginx&module=mysqld&module=php-fpm&module=postgres' 

and looks like only the first module (eg. in this case the node) is included in the response

wget -q -O - 'https://treebeard.login.hu:9998/proxy?module=node&module=nginx&module=mysqld&module=php-fpm&module=postgres' | grep -E '^(node_load1|nginx_connections_writing) '
node_load1 0.71

if i start switch the order, I get only the nginx data

wget -q -O - 'https://treebeard.login.hu:9998/proxy?module=nginx&module=node&module=mysqld&module=php-fpm&module=postgres' | grep -E '^(node_load1|nginx_connections_writing) '
nginx_connections_writing 1

Is this the expected behaviour? So Am I have to configure like the following?

  - job_name: 'myjob-node'
    scheme: 'https'
    metrics_path: '/proxy'
    params:
      module: [ 'node' ]
    static_configs:
      - targets:
        - 'targethost:9998'
        labels:
          module: 'node'
          environment: 'staging'

  - job_name: 'myjob-nginx'
    scheme: 'https'
    metrics_path: '/proxy'
    params:
      module: [ 'nginx' ]
    static_configs:
      - targets:
        - 'targethost:9998'
        labels:
          module: 'nginx'
          environment: 'staging'
...
  - job_name: 'myjob-{module}'
    scheme: 'https'
    metrics_path: '/proxy'
    params:
      module: [ '{module}' ]
    static_configs:
      - targets:
        - 'targethost:9998'
        labels:
          module: '{module}'
          environment: 'staging'
zsalab commented 1 year ago
prometheus-exporter-exporter --version
Version: 0.4.0-0.4.0-1+b7 (from debian/sid, built by team+pkg-go@tracker.debian.org on 20210718-11:25:11)
prometheus --version
prometheus, version 2.33.5+ds1 (branch: debian/sid, revision: 2.33.5+ds1-2~bpo11+1)
  build user:       team+pkg-go@tracker.debian.org
  build date:       20220820-12:29:59
  go version:       go1.18.5
  platform:         linux/amd64
zsalab commented 1 year ago

Same is true with the latest version:

prometheus-exporter-exporter --version
Version: 0.5.0-0.5.0-1 (from debian/sid, built by team+pkg-go@tracker.debian.org on 20230511-06:49:43)
zsalab commented 1 year ago

I guess the answer is here:

https://github.com/QubitProducts/exporter_exporter#blackbox-exporter

so there is no way to query multiple modules in one go

tcolgate commented 1 year ago

Not at present. To do this safely you'd need to add a label to all the metrics exported, since it will be very common for two modules to output the same metrics. There are quite a few cases where expexp can't actually parse the metrics (verify has to be disabled), and in this case, adding a label would not be possible. In normal usage you set prometheus to scrape expexp multiple times, with different module values. It is an interesting idea though, and not one I had considered. It may become necessary to drop the prometheus metrics parser anyway, and replace it with something else, but that is a big job, and not something I have time for at the moment.