martin-helmich / prometheus-nginxlog-exporter

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

support export $request_path #392

Closed micln closed 3 months ago

micln commented 3 months ago

Describe the bug I use the default log format $request is "GET /xxx HTTP/1.1" but the metric result got only "GET" but not "/xxx" is it has some options to suport it ?

image

Configuration file (remove section, if not applicable):

    format: "$_ $host nginx: $http_x_forwarded_for - $remote_user [$time_local] \"$request\" \"$request_body\" $status $request_time $upstream_response_time $body_bytes_sent \"$http_referer\" \"$http_user_agent\""

Example log file (remove section, if not applicable):

2024-01-01 host_name_XXX nginx: - - - [time] "GET /metrics HTTP/1.1" "-" 200 0.545 0.545 70 "-" "xxx"

Metrics output (remove section, if not applicable):

nginx_test_http_upstream_time_seconds_hist_bucket{app="nginx_test",environment="testing",method="GET",status="200",le="0.1"} 
micln commented 3 months ago

I got it, thanks

alonwillmakeit commented 2 months ago

@micln hey , would you mind sharing how did you solve it ?