From 983ef695d1379b8be3ba773078ab8036062ee542 Mon Sep 17 00:00:00 2001 From: GilbN <24592972+gilbN@users.noreply.github.com> Date: Tue, 29 Dec 2020 20:14:20 +0100 Subject: [PATCH] Update variable Now log_format uses the same variable as geoip2.conf does --- README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0507965..4489b65 100644 --- a/README.md +++ b/README.md @@ -51,23 +51,21 @@ The InfluxDB database will be created automatically with the name you choose. ## Sending Nginx log metrics -1. Add the following to the http block in your `nginx.conf`file: +1. Uncomment the Geoip2 config in `nginx.conf` + +2. Add the following to the http block in your `nginx.conf`file: ```nginx -geoip2 /config/geoip2db/GeoLite2-City.mmdb { -auto_reload 5m; -$geoip2_data_country_code country iso_code; -$geoip2_data_city_name city names en; -} - log_format geoip2influx '$remote_addr - $remote_user [$time_local]' '"$request" $status $body_bytes_sent' '"$http_referer" $host "$http_user_agent"' '"$request_time" "$upstream_connect_time"' - '"$geoip2_data_city_name" "$geoip2_data_country_code"'; + '"$geoip2_data_city_name" "$geoip2_data_country_iso_code"'; ``` - 2. Set the access log use the `geoip2influx` log format. + 3. Set the access log use the `geoip2influx` log format. + + Note: The log_format block must be above the access_log context. ```nginx access_log /config/log/nginx/access.log geoip2influx; ``` @@ -86,4 +84,4 @@ As nginx can have multiple `access log` directives in a block, just add another ``` This will log the same lines to both files. -Then use the `/config/log/nginx/access.log` file in the `NGINX_LOG_PATH` variable. \ No newline at end of file +Then use the `/config/log/nginx/access.log` file in the `NGINX_LOG_PATH` variable.