martin-helmich / prometheus-nginxlog-exporter

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

could not be parsed into float #375

Open df911 opened 10 months ago

df911 commented 10 months ago

Describe the bug I get this error : "error prometheus-nginxlog-exporter/main.go:356 error while parsing $upstream_response_time: value 'rt=0' could not be parsed into float"

To Reproduce use the configuration files below

Expected behavior Don't have errors into logs

Configuration file (remove section, if not applicable): nginx.conf

log_format custom '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' 'rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"';

config.hcl

format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" $upstream_response_time"

log file : /home/runner/work/prometheus-nginxlog-exporter/prometheus-nginxlog-exporter/main.go:268 2024-01-16T14:30:19.486Z error prometheus-nginxlog-exporter/main.go:356 error while parsing $upstream_response_time: value 'rt=0' could not be parsed into float main.observeMetrics /home/runner/work/prometheus-nginxlog-exporter/prometheus-nginxlog-exporter/main.go:356 main.processSource /home/runner/work/prometheus-nginxlog-exporter/prometheus-nginxlog-exporter/main.go:333 main.processNamespace.func4 /home/runner/work/prometheus-nginxlog-exporter/prometheus-nginxlog-exporter/main.go:268 2024-01-16T14:30:19.486Z error prometheus-nginxlog-exporter/main.go:356 error while parsing $upstream_response_time: value 'rt=0' could not be parsed into float

Environment:

yatesliang commented 7 months ago

I guess that's because your log format in nginx is urt="$upstream_response_time" but the format in exporter config is $upstream_response_time Then the exporter took urt=0 as $upstream_response_time, and urt=0 is obviously not a float