Hi I want to use the haproxy exporter provided here https://github.com/prometheus/haproxy_exporter in a docker container.
I am using docker-compose
for managing containers and want to recreate this command:
$ docker run -p 9101:9101 prom/haproxy-exporter -haproxy.scrape-uri="http://user:pass@haproxy.example.com/haproxy?stats;csv"
in my docker-compose.yml.
I am not sure how to pass the argument, after viewing the docker-compose documentation I tried it like this:
haproxy-exporter:
image: prom/haproxy-exporter
ports:
- 9101:9101
network_mode: "host"
build:
args:
- haproxy.scrape-uri="http://user:pass@haproxy.example.com/haproxy?stats;csv"
But this gives me an file is invalid
message because it requires a context with a build.
Thanks for any help in advance
The image is already built and pulled from the hub (unless you have your own Dockerfile) so you don't need the build option. Instead, pass your arguments as the command since the image appears to use an entrypoint (if their Dockerfile only had a cmd option, then you'd need to also pass /bin/haproxy-exporter in your command):
haproxy-exporter:
image: prom/haproxy-exporter
ports:
- 9101:9101
network_mode: "host"
command: -haproxy.scrape-uri="http://user:pass@haproxy.example.com/haproxy?stats;csv"
I m trying to make work this exporter, but I m having the same issue:
monitoring_haproxy-exporter.1.93xpdn67l4e6@worker1-xxx.com | time="2019-11-11T16:22:01Z" level=error msg="Can't scrape HAProxy: Get http://localhost:1936/?stats: dial tcp 127.0.0.1:1936: connect: connection refused" source="haproxy_exporter.go:305"
This is how I wrote the service on the compose file:
haproxy-exporter:
image: prom/haproxy-exporter
ports:
- 9101:9101
command: --haproxy.scrape-uri=http://localhost:1936/?stats;csv
networks:
- backend
Any answer will be appreciated, thanks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.