Analytics - NGINX / LOKI v2+ Data Source / Promtail v2+ Tool
Nginx access log analytics dashboard using Promtail and Loki v2+. Prometheus datasource is created from Loki service.
Revision - 21st June 2022
- Updated visitor map to support week on week comparison and top country listing
Revision - 20th February 2021
- Changed overall dashboard look and initial display of panels.
Revision - 16th February 2021
- Last 30 day graph of unique visitors to site added
- Removed more browser and crawler bot statistics from unique visitors and other relevant panels
Revision - 12th February 2021
- Changed Last 7 day graph from ’new time series beta graph’ to standard graph display.
- Removed further browser and crawler bot statistics from relevant panel - to add these back in edit the panel and remove below from query on each panel.
| http_user_agent !~ ".*bot.*" | remote_addr !~ "2001:4ca0:108:42::*" | remote_addr !~ "91.134.156.*" | http_user_agent != "worldping-api" | request_uri !~ "/wp-.*" | request_uri !~ "//wp-.*" | request_uri !~ "/*.wordfence.*" | request_uri !~ "/robots.txt" | request_uri !~ "/xmlrpc.php"
Extension of original dashboard
https://grafana.com/grafana/dashboards/12559?pg=dashboards&plcmt=featured-main
Setup of nginx, promtail & loki required
https://www.youtube.com/watch?v=kR5ay4lX0OM
Required nginx json log format configuration described below
Adding log_format to sites-available on Nginx :
server {
....
access_log /var/log/nginx/website_access.log json_analytics;
For IP to country mapping, also enable the Geo_IP module:
geoip_country /etc/nginx/GeoIP.dat;
geoip_city /etc/nginx/GeoIPCity.dat;
Option if you are using Cloudflare IP Geo location you can change the log_format :
'"geoip_country_code": "$http_cf_ipcountry"'
Cloudflare IP Geo location : https://support.cloudflare.com/hc/en-us/articles/200168236-Configuring-Cloudflare-IP-Geolocation
Promtail scrapes the log files best when you mount the log volume in the docker container.
$ sudo mv promtail-config.yaml /mnt/config/
$ docker create --name promtail --restart unless-stopped -v /mnt/config:/mnt/config -v /var/log:/var/log grafana/promtail:2.1.0 -config.file=/mnt/config/promtail-config.yaml
$ docker start promtail
Promtail-config.yml file details.
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://<ip address>:3100/loki/api/v1/push
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
host: nginx01
agent: promtail
__path__: /var/log/*log
- job_name: nginx
static_configs:
- targets:
- localhost
labels:
job: nginx
host: nginx01
agent: promtail
__path__: /var/log/nginx/*log
Data source config
Collector config:
Upload an updated version of an exported dashboard.json file from Grafana
Revision | Description | Created | |
---|---|---|---|
Download |
Adobe Analytics

With the Grafana plugin for Adobe Analytics, you can quickly visualize and query your Adobe Analytics data from within Grafana.
Learn moreGet this dashboard
Import the dashboard template
or