You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't understand why this is enough and when adding other parameters, it breaks. I also had to add the time_gmt parameter here, since it took the +0400 field as a value.
format = "$time_local $time_gmt $http_host $request $status"
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello. Now I'm trying to set up the collection of metrics and according to the examples that exist , it can't be done.
exemples:
nginx(no json format): log_format upstream_time '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
exporter: format = "$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for""
or
format = "$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for""
and I get the error
HELP nginx_parse_errors_total Total number of log file lines that could not be parsed
TYPE nginx_parse_errors_total counter
nginx_parse_errors_total 2
I managed to make it work like this:
nginx_json_format (I have logs in json format.)
log_format nginx_json escape=json
'{'
'"time_local":"$time_local",'
'"http_host":"$http_host",'
'"request":"$request",'
'"status": "$status",'
'"body_bytes_sent":"$body_bytes_sent",'
'"request_time":"$request_time",'
'"upstream_response_time":"$upstream_response_time",'
'"upstream_response_length":"$upstream_response_length",'
'"upstream_connect_time":"$upstream_connect_time",'
'"upstream_status":"$upstream_status",'
'"upstream_addr":"$upstream_addr",'
'"http_referrer":"$http_referer",'
'"http_user_agent":"$http_user_agent",'
'"request_body":"$request_body",'
'"request_length":"$request_length",'
'"remote_ip":"$http_x_forwarded_for",'
'"remote_addr":"$remote_addr"'
'}';
I don't understand why this is enough and when adding other parameters, it breaks. I also had to add the time_gmt parameter here, since it took the +0400 field as a value.
format = "$time_local $time_gmt $http_host $request $status"
nginx_http_response_count_total{app="default",method="other",status=""200","body_bytes_sent":"95","request_time":"0.008","upstream_response_time":"0.008","upstream_response_length":"95","upstream_connect_time":"0.005","upstream_status":"200","upstream_addr":"10.10.12.138:8003","http_referrer":"","http_user_agent":"GuzzleHttp/6.5.3"} 1
nginx_http_response_count_total{app="default",method="other",status=""200","body_bytes_sent":"95","request_time":"0.008","upstream_response_time":"0.009","upstream_response_length":"95","upstream_connect_time":"0.001","upstream_status":"200","upstream_addr":"10.10.12.138:8003","http_referrer":"","http_user_agent":"GuzzleHttp/6.5.3"} 1
nginx_http_response_count_total{app="default",method="other",status=""200","body_bytes_sent":"95","request_time":"0.010","upstream_response_time":"0.009","upstream_response_length":"95","upstream_connect_time":"0.000","upstream_status":"200","upstream_addr":"10.10.12.137:8003","http_referrer":"","http_user_agent":"GuzzleHttp/6.5.3"} 1
nginx_http_response_count_total{app="default",method="other",status=""200","body_bytes_sent":"95","request_time":"0.010","upstream_response_time":"0.010","upstream_response_length":"95","upstream_connect_time":"0.000","upstream_status":"200","upstream_addr":"10.10.12.138:8003","http_referrer":"","http_user_agent":"GuzzleHttp/6.5.3"} 1
nginx_http_response_count_total{app="default",method="other",status=""404","body_bytes_sent":"0","request_time":"0.000","upstream_response_time":"0.001","upstream_response_length":"0","upstream_connect_time":"0.001","upstream_status":"404","upstream_addr":"10.10.12.139:8003","http_referrer":"","http_user_agent":"curl/7.29.0","request_body":"","request_length":"78","remote_ip":"","remote_addr":"127.0.0.1","resp_body":""}"} 1
HELP nginx_parse_errors_total Total number of log file lines that could not be parsed
Beta Was this translation helpful? Give feedback.
All reactions