prometheus-community / PushProx

Proxy to allow Prometheus to scrape through NAT etc.
Apache License 2.0
704 stars 132 forks source link

How to scrape metrics from not /metrics endpoint? #159

Open witold-gren opened 8 months ago

witold-gren commented 8 months ago

Hey,

I implemented prometheus-pve-exporter in my proxmox server. But my entire monitoring is run in external cloud configuration. To provide one endpoint to scrape all metrics from all services run in proxmox in decided to use PushProx. The all configuration works quite well.. but I realised that when I use this this tool then I can not scrape metrics from extra endpoint /pve but i must use only endpoint /metrics.

It is possible to configure more endpoints to scrape metrics?

- job_name: "proxmox"
  proxy_url: <<http://A.B.C.D:XXX>>
  metrics_path: /metrics
  ...
  static_configs:
    - targets: [proxmox.local:9221]

when I tried change metrics_path to use /pve then it not works.. any Idea how I can fix this issue?

paul-dsh-ct commented 1 month ago

Hey,

I had the same issue, I wanted to scrape gotenberg metrics which default endpoint is /prometheus/metrics. I managed to add a new flag in the pushprox client entrypoint by adding the following code in cmd/client/main.go:

In the variables declaration part: endpoint = kingpin.Flag("endpoint", "Override metrics endpoint (default is /metrics)").String()

In the doScrape function:

if *endpoint != "" {
        request.URL.Path = *endpoint
    }

Then you just have to add the following flag to your client entrypoint: --endpoint=/another/metrics/path

Hope it can help you

peekjef72 commented 3 weeks ago

Hey,

I had the same issue, I wanted to scrape gotenberg metrics which default endpoint is /prometheus/metrics. I managed to add a new flag in the pushprox client entrypoint by adding the following code in cmd/client/main.go:

In the variables declaration part: endpoint = kingpin.Flag("endpoint", "Override metrics endpoint (default is /metrics)").String()

In the doScrape function:

if *endpoint != "" {
        request.URL.Path = *endpoint
    }

Then you just have to add the following flag to your client entrypoint: --endpoint=/another/metrics/path

Hope it can help you

Hi, Sorry, but like it was mentionned in #58, the path is not hardcoded: pushproxy is a proxy so it sends the exact query that is set by the client to the final target.

You can test it manually with curl shell cmd:

to reach node_exporter landing page on "client" host

curl -v --proxy http://pushproxy:8080 \
    -H "X-Prometheus-Scrape-Timeout-Seconds: 5" \
    http://client:9100/

to reach node_exporter status page

curl -v --proxy http://pushproxy:8080 \
    -H "X-Prometheus-Scrape-Timeout-Seconds: 5" \
    http://client:9100/status

to reach node_exporter metrics page

curl -v --proxy http://pushproxy:8080 \
    -H "X-Prometheus-Scrape-Timeout-Seconds: 5" \
    http://client:9100/metrics

So if you have trouble to reach the target, it is not the proxy but the config in prometheus !