panic: Put http://localhost:8080/v1/agent/service/register?dc=dc1: dial tcp 127.0.0.1:8080: connect: connection refused

101 Views Asked by At

I am trying to running docker for https://github.com/martin-helmich/prometheus-nginxlog-exporter#docker nginxlog exporter and I am getting`panic: Put http://localhost:8080/v1/agent/service/register?dc=dc1: dial tcp 127.0.0.1:8080: connect: connection refused

goroutine 1 [running]:main.setupConsul(0xc000188000, 0xc00018e000, 0xc000020014)/home/runner/work/prometheus-nginxlog-exporter/prometheus-nginxlog-exporter/main.go:286 +0x125main.main()/home/runner/work/prometheus-nginxlog-exporter/prometheus-nginxlog-exporter/main.go:236 +0x11e2`

and prometheus config`listen {port = 4040address = "127.0.0.1"metrics_endpoint = "/metrics"}

consul {enable = trueaddress = "localhost:8080"datacenter = "dc1"scheme = "http"token = ""service {id = "nginx-exporter"name = "nginx-exporter"address = "127.0.0.1"tags = ["foo", "bar"]}}

namespace "app1" {format = "$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for""source {files = ["/opt/homebrew/var/log/nginx/access.log"]}

log can be printed to std out, e.g. for debugging purposes (disabled by default)

print_log = false

metrics_override = { prefix = "myprefix" }

namespace_label = "vhost"

labels {app = "application-one"environment = "production"foo = "bar"}

histogram_buckets = [.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10]}`

and Using the command docker run --name nginx-exporter -p 4040:4040 -v /path/to/logs:/mnt/nginxlogs -v /path/to/config.hcl:/etc/prometheus-nginxlog-exporter.hcl quay.io/martinhelmich/prometheus-nginxlog-exporter -config-file /etc/prometheus-nginxlog-exporter.hcl

I have look into the port and try to curl and I was getting the response and when I run this command docker run
--name nginx-exporter
-v /path/to/logs:/mnt/nginxlogs
-p 4040:4040
quay.io/martinhelmich/prometheus-nginxlog-exporter
mnt/nginxlogs/access.log

without prometheus config hcl file , it works but I need config hcl file changes

0

There are 0 best solutions below