QubitProducts / exporter_exporter

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

Proxyed 'path' are URL encoded, which is lead to different from config request on backend #53

Closed alezkv closed 4 years ago

alezkv commented 4 years ago

Example config

modules:
  consul:
    method: http
    http:
      port: 8500
      path: "/v1/agent/metrics?format=prometheus"

Expected behaviour: proxy request /proxy?module=consul must return metrics from consul agent

Actual behaviour: proxy request /proxy?module=consul returns 404

Actual request to consul are URL encoded by exporter_exporter which is lead to the following /v1/agent/metrics%3Fformat=prometheus On that request consul returns 404

But if try to get metrics directly from consul it works well.

$ curl -v '0:8500/v1/agent/metrics%3Fformat=prometheus'
*   Trying 0.0.0.0...
* TCP_NODELAY set
* Connected to 0 (127.0.0.1) port 8500 (#0)
> GET /v1/agent/metrics%3Fformat=prometheus HTTP/1.1
> Host: 0:8500
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Date: Tue, 31 Mar 2020 14:34:19 GMT
< Content-Length: 0
<
* Connection #0 to host 0 left intact
$ curl -v '0:8500/v1/agent/metrics?format=prometheus'
*   Trying 0.0.0.0...
* TCP_NODELAY set
* Connected to 0 (127.0.0.1) port 8500 (#0)
> GET /v1/agent/metrics?format=prometheus HTTP/1.1
> Host: 0:8500
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; version=0.0.4; charset=utf-8
< Vary: Accept-Encoding
< Date: Tue, 31 Mar 2020 14:34:33 GMT
< Transfer-Encoding: chunked
<
# HELP consul_client_api_catalog_datacenters consul_client_api_catalog_datacenters
# TYPE consul_client_api_catalog_datacenters counter
...
tcolgate commented 4 years ago

I've confirmed the bug as reported. I think we fixed this once, but may have put it back when re refactored the reverse proxy. I'll attempt a proper fix.

tcolgate commented 4 years ago

Fixed this on master, it might be a while before I get round to doing a release.

tcolgate commented 4 years ago

This should be resolved in 0.4.0