QubitProducts / exporter_exporter

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

"path" prevents query strings #17

Closed mozai closed 5 years ago

mozai commented 5 years ago

Goal: I wish to use exporter_exporter to safely export metrics about the local consul daemon. Consul already cooperates with prometheus by provding a prometheus-compatible metrics output if I ask properly.

What I did:

modules:
  consul:
    http: { path: '/v1/agent/metrics?format=prometheus', port:8500 }
    method: http

What I expected:
curl http://localhost:9999/proxy?module=consul would return the same data that I get from curl http://localhost:8500/v1/agent/metrics?format=prometheus

What I got:
An error has occurred during metrics gathering: text format parsing error in line 1: invalid metric name

Extra information:
running a strace on exporter_exporter (I don't have tcpdump on this machine) I can see that exporter_exporter is sending an http request "GET /v1/agent/metrics%3Fformat..."

mozai commented 5 years ago

An unsatisfactory workaround:

  consul:
    exec: { command: wget, args: [ "-q", "-O-", "http://localhost:8500/v1/agent/metrics?format=prometheus" ] }
    method: exec
    timeout: 1s

Using 'wget' instead of the customary 'curl' because wget seems more popular on the Debian boxes I'm looking after.

nvx commented 5 years ago

I came here looking for the same ability to expose consul prometheus metrics too. Disappointing this isn't possible.

Looks like https://github.com/rrreeeyyy/exporter_proxy might be better suited

tcolgate commented 5 years ago

Sorry I missed this, So we are escaping the path, this should be easy to fix. I'll take a look

tcolgate commented 5 years ago

FWIW, the query string passed in from the prom scrap are passed on to the backend, so you if you path to be /v1/agent/metrics, and then have prom add the format=prometheus as a param, that would work (obviously also not ideal)

tcolgate commented 5 years ago

Would this suffice? https://github.com/QubitProducts/exporter_exporter/pull/19