{ "__inputs": [ { "name": "DS_LOKI", "label": "Loki V2 data source", "description": "", "type": "datasource", "pluginId": "loki", "pluginName": "Loki" }, { "name": "NGINX_LOGFILE", "label": "Nginx access log file", "description": "", "type": "constant", "value": "/var/log/nginx/appname-json-access.log" } ], "__requires": [ { "type": "datasource", "id": "loki", "name": "Loki", "version": "2.0.0" } ], "annotations": { "list": [ { "builtIn": 1, "datasource": "-- Grafana --", "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "description": "Loki version 2 showcase using JSON NGINX access logs.", "editable": true, "gnetId": 12559, "graphTooltip": 0, "id": 4, "links": [], "panels": [ { "collapsed": false, "datasource": "${DS_LOKI}", "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "id": 24, "panels": [], "title": "KPI's", "type": "row" }, { "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": { "align": null }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "purple", "value": null } ] }, "unit": "short" }, "overrides": [] }, "gridPos": { "h": 4, "w": 6, "x": 0, "y": 1 }, "id": 4, "interval": "30s", "options": { "colorMode": "background", "graphMode": "area", "justifyMode": "center", "orientation": "auto", "reduceOptions": { "calcs": ["sum"], "fields": "", "values": false }, "textMode": "value" }, "pluginVersion": "7.3.6", "targets": [ { "expr": "count_over_time({filename=\"${NGINX_LOGFILE}\"}[$__interval])", "legendFormat": "", "refId": "A" } ], "timeFrom": "24h", "timeShift": null, "title": "Total requests ", "transformations": [], "type": "stat" }, { "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": { "align": null }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "light-blue", "value": null } ] }, "unit": "short" }, "overrides": [] }, "gridPos": { "h": 8, "w": 9, "x": 6, "y": 1 }, "id": 5, "interval": "30s", "options": { "colorMode": "background", "graphMode": "area", "justifyMode": "auto", "orientation": "auto", "reduceOptions": { "calcs": ["sum"], "fields": "", "values": false }, "textMode": "auto" }, "pluginVersion": "7.3.6", "targets": [ { "expr": "sum by (status) (count_over_time({filename=\"${NGINX_LOGFILE}\"} | json | __error__=\"\" [$__interval]))", "legendFormat": "HTTP Status: {{status}}", "refId": "A" } ], "timeFrom": null, "timeShift": null, "title": "Requests per status code", "transformations": [], "type": "stat" }, { "cacheTimeout": null, "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": { "align": null }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "purple", "value": null }, { "color": "red", "value": 80 } ] }, "unit": "percent" }, "overrides": [] }, "gridPos": { "h": 4, "w": 5, "x": 15, "y": 1 }, "id": 19, "interval": null, "links": [], "maxDataPoints": 1, "options": { "colorMode": "background", "graphMode": "none", "justifyMode": "center", "orientation": "auto", "reduceOptions": { "calcs": ["mean"], "fields": "", "values": false }, "textMode": "value" }, "pluginVersion": "7.3.6", "targets": [ { "expr": " sum(rate({filename=\"${NGINX_LOGFILE}\"} | json | status >= 500 |__error__=\"\"[$__interval])) / (sum(rate({filename=\"${NGINX_LOGFILE}\"} | json | __error__=\"\"[$__interval])) / 100)", "legendFormat": "", "refId": "A" } ], "timeFrom": null, "timeShift": null, "title": "% of 5xx requests ", "type": "stat" }, { "cacheTimeout": null, "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": { "align": null }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "purple", "value": null } ] }, "unit": "percent" }, "overrides": [] }, "gridPos": { "h": 4, "w": 4, "x": 20, "y": 1 }, "id": 18, "interval": "10m", "links": [], "maxDataPoints": 1, "options": { "colorMode": "background", "graphMode": "none", "justifyMode": "auto", "orientation": "auto", "reduceOptions": { "calcs": ["last"], "fields": "", "values": false }, "textMode": "value" }, "pluginVersion": "7.3.6", "targets": [ { "expr": " sum(rate(({job=\"nginx_access_log\"} |= \"Googlebot\")[$__interval])) / (sum(rate(({job=\"nginx_access_log\"} |= \"Mozilla\")[10m])) / 100)", "legendFormat": "", "refId": "A" } ], "timeFrom": null, "timeShift": null, "title": "% of requests by Googlebot", "type": "stat" }, { "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": { "align": null }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "purple", "value": null } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "Requests" }, "properties": [ { "id": "custom.width", "value": 100 } ] } ] }, "gridPos": { "h": 4, "w": 6, "x": 0, "y": 5 }, "id": 22, "interval": "5m", "options": { "colorMode": "background", "graphMode": "none", "justifyMode": "auto", "orientation": "auto", "reduceOptions": { "calcs": ["mean"], "fields": "", "values": false }, "textMode": "value" }, "pluginVersion": "7.3.6", "targets": [ { "expr": "count(sum by (remote_addr) (count_over_time({filename=\"${NGINX_LOGFILE}\"} | json | __error__=\"\" [5m])))", "legendFormat": "", "refId": "A" } ], "timeFrom": "5m", "timeShift": null, "title": "Users right now", "transformations": [], "type": "stat" }, { "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": { "align": null }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "purple", "value": null } ] }, "unit": "decbytes" }, "overrides": [ { "matcher": { "id": "byName", "options": "IP Address" }, "properties": [ { "id": "custom.width", "value": 410 } ] } ] }, "gridPos": { "h": 4, "w": 9, "x": 15, "y": 5 }, "id": 8, "interval": "10m", "options": { "colorMode": "background", "graphMode": "none", "justifyMode": "center", "orientation": "auto", "reduceOptions": { "calcs": ["sum"], "fields": "", "values": false }, "textMode": "value" }, "pluginVersion": "7.3.6", "targets": [ { "expr": "sum_over_time({filename=\"${NGINX_LOGFILE}\"} | json | status=200 | unwrap body_bytes_sent | __error__=\"\" [$__interval])", "legendFormat": "Bytes sent", "refId": "A" } ], "timeFrom": null, "timeShift": null, "title": "Total Bytes Sent", "transformations": [ { "id": "reduce", "options": { "reducers": ["sum"] } }, { "id": "organize", "options": { "excludeByName": {}, "indexByName": {}, "renameByName": { "Total": "Bytes Sent" } } } ], "type": "stat" }, { "circleMaxSize": "50", "circleMinSize": "15", "colors": ["#96D98D", "#37872D", "#19730E"], "datasource": "${DS_LOKI}", "decimals": null, "description": "", "esMetric": "Count", "fieldConfig": { "defaults": { "custom": { "align": null }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "Requests" }, "properties": [ { "id": "custom.width", "value": 100 } ] } ] }, "gridPos": { "h": 10, "w": 15, "x": 0, "y": 9 }, "hideEmpty": false, "hideZero": false, "id": 14, "initialZoom": "2", "interval": "30s", "locationData": "countries", "mapCenter": "(0°, 0°)", "mapCenterLatitude": 0, "mapCenterLongitude": 0, "maxDataPoints": 1, "mouseWheelZoom": false, "pluginVersion": "7.0.3", "showLegend": true, "stickyLabels": true, "tableQueryOptions": { "geohashField": "geohash", "latitudeField": "latitude", "longitudeField": "longitude", "metricField": "metric", "queryType": "geohash" }, "targets": [ { "expr": "sum by (geoip_country_code) (count_over_time({filename=\"${NGINX_LOGFILE}\"} | json | __error__=\"\" [1m]))", "legendFormat": "{{geoip_country_code}}", "refId": "A" } ], "thresholds": "5,10", "timeFrom": "15m", "timeShift": null, "title": "Countries right now", "transformations": [], "type": "grafana-worldmap-panel", "unitPlural": "", "unitSingle": "", "valueName": "total" }, { "datasource": "${DS_LOKI}", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "gridPos": { "h": 10, "w": 9, "x": 15, "y": 9 }, "id": 11, "options": { "showLabels": false, "showTime": false, "sortOrder": "Descending", "wrapLogMessage": false }, "targets": [ { "expr": "{filename=\"${NGINX_LOGFILE}\"} | json | line_format \"request for {{.request_uri}} with HTTP status: {{.status}} \"", "legendFormat": "", "refId": "A" } ], "timeFrom": null, "timeShift": null, "title": "Logs", "type": "logs" }, { "collapsed": false, "datasource": "${DS_LOKI}", "gridPos": { "h": 1, "w": 24, "x": 0, "y": 19 }, "id": 26, "panels": [], "title": "Request statistics over time", "type": "row" }, { "aliasColors": { "95th percentile": "blue", "max latency": "super-light-blue" }, "bars": false, "dashLength": 10, "dashes": false, "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": {}, "unit": "s" }, "overrides": [] }, "fill": 5, "fillGradient": 9, "gridPos": { "h": 9, "w": 7, "x": 0, "y": 20 }, "hiddenSeries": false, "id": 16, "interval": "30s", "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 1, "nullPointMode": "null", "options": { "alertThreshold": true }, "percentage": false, "pluginVersion": "7.3.6", "pointradius": 2, "points": false, "renderer": "flot", "seriesOverrides": [ { "alias": "max latency", "dashes": true, "fillGradient": 3 } ], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "expr": "quantile_over_time(0.95,{filename=\"${NGINX_LOGFILE}\"} | json | unwrap request_time | __error__=\"\" [$__interval]) by (host)", "legendFormat": "95th percentile", "refId": "C" }, { "expr": "max by (host) (max_over_time({filename=\"${NGINX_LOGFILE}\"} | json | unwrap request_time | __error__=\"\" [$__interval]))", "legendFormat": "max latency", "refId": "D" } ], "thresholds": [ { "colorMode": "critical", "fill": true, "line": true, "op": "gt", "value": 0.3, "yaxis": "left" } ], "timeFrom": null, "timeRegions": [], "timeShift": null, "title": "95th percentile of Request Time", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "s", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": false } ], "yaxis": { "align": false, "alignLevel": null } }, { "aliasColors": { "{statuscode=\"200\"} 200": "green", "{statuscode=\"404\"} 404": "semi-dark-purple", "{statuscode=\"500\"} 500": "dark-red" }, "bars": false, "dashLength": 10, "dashes": false, "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fill": 1, "fillGradient": 10, "gridPos": { "h": 9, "w": 9, "x": 7, "y": 20 }, "hiddenSeries": false, "id": 2, "interval": "30s", "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 1, "nullPointMode": "connected", "options": { "alertThreshold": true }, "percentage": true, "pluginVersion": "7.3.6", "pointradius": 2, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": true, "steppedLine": false, "targets": [ { "expr": "sum by (status) (count_over_time({filename=\"${NGINX_LOGFILE}\"} | json | __error__=\"\" [$__interval]))", "legendFormat": "HTTP Status {{status}}", "refId": "A" } ], "thresholds": [], "timeFrom": null, "timeRegions": [], "timeShift": null, "title": "HTTP requests", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "transformations": [ { "id": "filterFieldsByName", "options": { "include": { "names": [ "Time", "HTTP Status 200", "HTTP Status 301", "HTTP Status 304", "HTTP Status 404", "HTTP Status 406", "HTTP Status 500" ] } } } ], "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "decimals": 0, "format": "short", "label": null, "logBase": 1, "max": "100", "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "aliasColors": { "Bytes sent": "light-blue", "appfelstrudel": "yellow" }, "bars": false, "dashLength": 10, "dashes": false, "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fill": 10, "fillGradient": 10, "gridPos": { "h": 9, "w": 8, "x": 16, "y": 20 }, "hiddenSeries": false, "id": 9, "interval": "30s", "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 1, "nullPointMode": "null", "options": { "alertThreshold": true }, "percentage": false, "pluginVersion": "7.3.6", "pointradius": 2, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "expr": "sum by (host) (sum_over_time({filename=\"${NGINX_LOGFILE}\"} | json | status=200 | unwrap body_bytes_sent | __error__=\"\" [$__interval]))", "legendFormat": "Bytes sent", "refId": "A" } ], "thresholds": [], "timeFrom": null, "timeRegions": [], "timeShift": null, "title": "Bytes Sent", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "transformations": [], "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "decbytes", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "collapsed": false, "datasource": "${DS_LOKI}", "gridPos": { "h": 1, "w": 24, "x": 0, "y": 29 }, "id": 28, "panels": [], "title": "Acquisition and Behaviour", "type": "row" }, { "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": { "align": null, "filterable": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "Requests" }, "properties": [ { "id": "custom.width", "value": 100 } ] } ] }, "gridPos": { "h": 6, "w": 9, "x": 0, "y": 30 }, "id": 7, "interval": "30s", "options": { "showHeader": true, "sortBy": [ { "desc": true, "displayName": "Requests" } ] }, "pluginVersion": "7.3.6", "targets": [ { "expr": "topk(10, sum by (http_user_agent) (count_over_time({filename=\"${NGINX_LOGFILE}\"} | json | __error__=\"\" [$__interval])))", "legendFormat": "{{http_user_agent}}", "refId": "A" } ], "timeFrom": null, "timeShift": null, "title": "Top User Agents", "transformations": [ { "id": "reduce", "options": { "reducers": ["sum"] } }, { "id": "organize", "options": { "excludeByName": { "Field": false }, "indexByName": {}, "renameByName": { "Field": "Agent", "Total": "Requests" } } } ], "type": "table" }, { "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": { "align": null, "filterable": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "Requests" }, "properties": [ { "id": "custom.width", "value": 100 } ] } ] }, "gridPos": { "h": 6, "w": 15, "x": 9, "y": 30 }, "id": 6, "interval": "30ms", "options": { "showHeader": true, "sortBy": [ { "desc": true, "displayName": "Requests" } ] }, "pluginVersion": "7.3.6", "targets": [ { "expr": "topk(20, sum by (http_referer) (count_over_time({filename=\"${NGINX_LOGFILE}\"} | json | http_referer != \"\" | http_referer !~ \"appfelstrudel\" | http_referer !~ \"54.39.50.183\" | __error__=\"\" [$__interval])))", "legendFormat": "{{http_referer}}", "refId": "A" } ], "timeFrom": null, "timeShift": null, "title": "Top HTTP Referers", "transformations": [ { "id": "reduce", "options": { "reducers": ["sum"] } }, { "id": "organize", "options": { "excludeByName": {}, "indexByName": {}, "renameByName": { "Field": "IP Address", "Total": "Requests" } } } ], "type": "table" }, { "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": { "align": null, "filterable": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "Requests" }, "properties": [ { "id": "custom.width", "value": 100 } ] } ] }, "gridPos": { "h": 8, "w": 9, "x": 0, "y": 36 }, "id": 3, "interval": "30m", "options": { "showHeader": true, "sortBy": [ { "desc": true, "displayName": "Requests" } ] }, "pluginVersion": "7.3.6", "targets": [ { "expr": "topk(10, sum by (remote_addr) (count_over_time({filename=\"${NGINX_LOGFILE}\"} | json | __error__=\"\" [$__interval])))", "legendFormat": "{{remote_addr}}", "refId": "A" } ], "timeFrom": null, "timeShift": null, "title": "Top IPs", "transformations": [ { "id": "reduce", "options": { "reducers": ["sum"] } }, { "id": "organize", "options": { "excludeByName": { "Field": false }, "indexByName": {}, "renameByName": { "Field": "IP Address", "Total": "Requests" } } } ], "type": "table" }, { "datasource": "${DS_LOKI}", "description": "", "fieldConfig": { "defaults": { "custom": { "align": null, "filterable": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [] }, "gridPos": { "h": 8, "w": 15, "x": 9, "y": 36 }, "id": 12, "interval": "30m", "options": { "showHeader": true, "sortBy": [ { "desc": true, "displayName": "Requests" } ] }, "pluginVersion": "7.3.6", "targets": [ { "expr": "topk(5,sum by (request_uri) (count_over_time({filename=\"${NGINX_LOGFILE}\"} | json | __error__=\"\" [$__interval])))", "legendFormat": "{{request_uri}}", "refId": "A" } ], "timeFrom": null, "timeShift": null, "title": "Top Requested Pages", "transformations": [ { "id": "reduce", "options": { "reducers": ["sum"] } } ], "type": "table" } ], "refresh": false, "schemaVersion": 26, "style": "dark", "tags": [], "templating": { "list": [] }, "time": { "from": "now-30m", "to": "now" }, "timepicker": { "refresh_intervals": [ "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d" ] }, "timezone": "", "title": "Web Analytics Dashboard", "uid": "Nz6kKgtGk", "version": 1 }