lucaslorentz / caddy-docker-proxy

Caddy as a reverse proxy for Docker
MIT License
2.61k stars 163 forks source link

Any way to get metrics on 2019 port? #613

Open andreevgrisha opened 2 months ago

andreevgrisha commented 2 months ago

inside caddy-proxy container config/caddy/autosave.json show {"admin":{"listen":"tcp/localhost:2019"} but with exposed 2019 port on docker-compose file, i can't connect to 2019, responce is: Connection reset by peer

need advice - how change this settings to {"admin":{"listen":":2019"}

or any other way to expose hostip:2019/metrics with lucaslorentz/caddy-docker-proxy and docker-compose ?

francislavoie commented 1 month ago

CDP needs control of the admin endpoint because it does managed config reloads.

You can serve metrics from any port with the metrics directive: https://caddyserver.com/docs/caddyfile/directives/metrics

Just add labels to your Caddy container to produce config like this:

:2020 {
    metrics
}
andreevgrisha commented 1 month ago

thanks for answer! can you help with label example of this? have not idea how do it right way... may be or wrong?

labels:
  caddy.handle_path: /metrics
  caddy.handle_path.0_reverse_proxy: {{upstreams 2020}}
francislavoie commented 1 month ago

No, you need to define a site (like if you used a domain) but with :2020 instead. No reverse_proxy.

andreevgrisha commented 1 month ago

clear!

    labels:
      caddy_0:
      caddy_0.servers:
      caddy_0.servers.metrics:
      caddy_1: ":2020"
      caddy_1.metrics: "/metrics"
      caddy_1.metrics.disable_openmetrics:

thank a lot