martin-helmich / prometheus-nginxlog-exporter

Export metrics from Nginx access log files to Prometheus
Apache License 2.0
934 stars 165 forks source link

not working #364

Open ohot2015 opened 9 months ago

ohot2015 commented 9 months ago

prometheus-nginxlog-exporter | 2023-11-28T13:29:10.670Z info prometheus-nginxlog-exporter/main.go:139 starting listener for namespace nginx prometheus-nginxlog-exporter | 2023-11-28T13:29:10.670Z info prometheus-nginxlog-exporter/main.go:148 running HTTP server on address 0.0.0.0:4040, serving metrics at /metrics prometheus-nginxlog-exporter | 2023-11-28T13:29:10.670Z info tail@v1.4.8/tail.go:212 Waiting for prometheus-nginxlog-exporter -config-file /etc/prometheus-nginxlog-exporter.yml to appear...

`listen: port: 4040 metrics_endpoint: "/metrics"

consul: enable: false

namespaces:

127.0.0.1 - - [28/Nov/2023:16:32:25 +0300] "GET /favicon.ico HTTP/1.1" 404 197 "http://test.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" "0.000" 127.0.0.1 - - [28/Nov/2023:16:32:25 +0300] "GET / HTTP/1.1" 404 197 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" "0.000" 127.0.0.1 - - [28/Nov/2023:16:32:25 +0300] "GET /favicon.ico HTTP/1.1" 404 197 "http://test.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" "0.000" 127.0.0.1 - - [28/Nov/2023:16:32:25 +0300] "GET / HTTP/1.1" 404 197 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" "0.000" 127.0.0.1 - - [28/Nov/2023:16:32:25 +0300] "GET /favicon.ico HTTP/1.1" 404 197 "http://test.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" "0.000" 127.0.0.1 - - [28/Nov/2023:16:32:25 +0300] "GET / HTTP/1.1" 404 197 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" "0.000" 127.0.0.1 - - [28/Nov/2023:16:32:25 +0300] "GET /favicon.ico HTTP/1.1" 404 197 "http://test.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" "0.000" docker-compose

` nginx-exporter: image: quay.io/martinhelmich/prometheus-nginxlog-exporter container_name: prometheus-nginxlog-exporter command:

ecsimsw commented 5 months ago

How about applying an escape char to the quotes in a yaml string format?

In my case, I did like this and it worked.

namespaces:
  - name: app1
    format: "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""

Hope this helps!