Open ohot2015 opened 9 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!
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:
name: nginx format: "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$request_time\"" source: files:
only_count: true relabel_configs:
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:
localhost:4040
# HELP nginx_parse_errors_total Total number of log file lines that could not be parsedTYPE nginx_parse_errors_total counter
nginx_parse_errors_total 0
HELP prometheus_nginxlog_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which prometheus_nginxlog_exporter was built, and the goos and goarch for the build.
TYPE prometheus_nginxlog_exporter_build_info gauge
prometheus_nginxlog_exporter_build_info{branch="v1.11.0",goarch="amd64",goos="linux",goversion="go1.18.10",revision="76552e7cadc1f76b4e28b5c872412db4a091aca0",tags="unknown",version="1.11.0"`![image](https://github.com/martin-helmich/prometheus-nginxlog-exporter/assets/22836177/d99bf91c-3b9c-4aef-a098-9b714eeb3172)