diff --git a/5-3-loki-dashboards-nginx/docker-compose.yml b/5-3-loki-dashboards-nginx/docker-compose.yml new file mode 100644 index 0000000..cd5b4c8 --- /dev/null +++ b/5-3-loki-dashboards-nginx/docker-compose.yml @@ -0,0 +1,32 @@ +version: "3.9" + +services: + grafana: + image: "grafana/grafana:8.4.2" + ports: + - "3000:3000" + volumes: + - ./provisioning:/etc/grafana/provisioning + environment: + - GF_PLUGINS_PLUGIN_ADMIN_ENABLED=true + + loki: + image: "grafana/loki:2.4.2" + ports: + - "3100:3100" + + promtail: + image: "grafana/promtail:2.4.2" + volumes: + - logs_dir:/tmp/log + - ./promtail.yml:/etc/promtail/config.yaml + command: -config.file=/etc/promtail/config.yaml + + flog: + image: "mingrammer/flog:0.4.3" + command: -f json -t log -o /tmp/log/json.log -d 200ms -w -l + volumes: + - logs_dir:/tmp/log + +volumes: + logs_dir: \ No newline at end of file diff --git a/5-3-loki-dashboards-nginx/promtail.yml b/5-3-loki-dashboards-nginx/promtail.yml new file mode 100644 index 0000000..b237340 --- /dev/null +++ b/5-3-loki-dashboards-nginx/promtail.yml @@ -0,0 +1,11 @@ +clients: + - url: http://loki:3100/loki/api/v1/push + +scrape_configs: + - job_name: flog + static_configs: + - targets: + - localhost + labels: + job: flogs + __path__: /tmp/log/*.log \ No newline at end of file diff --git a/5-3-loki-dashboards-nginx/provisioning/dashboards/loki.yaml b/5-3-loki-dashboards-nginx/provisioning/dashboards/loki.yaml new file mode 100644 index 0000000..e48c93c --- /dev/null +++ b/5-3-loki-dashboards-nginx/provisioning/dashboards/loki.yaml @@ -0,0 +1,9 @@ +apiVersion: 1 + +providers: + - name: 'Loki dashboards' + type: file + allowUiUpdates: true + options: + path: /etc/grafana/provisioning/dashboards/loki + foldersFromFilesStructure: false \ No newline at end of file diff --git a/5-3-loki-dashboards-nginx/provisioning/dashboards/loki/nginx.json b/5-3-loki-dashboards-nginx/provisioning/dashboards/loki/nginx.json new file mode 100644 index 0000000..e623348 --- /dev/null +++ b/5-3-loki-dashboards-nginx/provisioning/dashboards/loki/nginx.json @@ -0,0 +1,1926 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "description": "Loki v2+ showcase using JSON NGINX access logs.", + "editable": true, + "fiscalYearStartMonth": 0, + "gnetId": 12559, + "graphTooltip": 1, + "id": 2, + "links": [], + "liveNow": false, + "panels": [ + { + "collapsed": false, + "datasource": { + "uid": "$datasource" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 24, + "panels": [], + "title": "KPI's", + "type": "row" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "purple", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 5, + "x": 0, + "y": 1 + }, + "hideTimeOverride": false, + "id": 4, + "maxDataPoints": 300, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "value" + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "sum(count_over_time({job=\"flogs\"}[$__interval]))", + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": "24h", + "title": "Total requests ", + "transformations": [], + "type": "stat" + }, + { + "datasource": {}, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "rgba(110, 157, 228, 0.76)", + "value": null + }, + { + "color": "rgba(73, 124, 202, 1)", + "value": 20 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 7, + "x": 5, + "y": 1 + }, + "id": 5, + "maxDataPoints": 20, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "sum by (status) (count_over_time({job=\"flogs\"} | json | __error__=\"\" [$__interval]))", + "instant": false, + "legendFormat": "HTTP Status: {{status}}", + "range": true, + "refId": "A" + } + ], + "title": "Requests per status code", + "transformations": [], + "type": "stat" + }, + { + "datasource": {}, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 0, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "semi-dark-orange", + "value": null + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 12, + "y": 1 + }, + "id": 30, + "maxDataPoints": 1, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "bytes_over_time({job=\"flogs\"}[$__interval])", + "instant": true, + "legendFormat": "$label_value", + "range": false, + "refId": "A" + } + ], + "title": "NGINX logs in bytes", + "type": "stat" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "purple", + "value": null + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 15, + "y": 1 + }, + "id": 8, + "maxDataPoints": 1, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "value" + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "sum (sum_over_time({job=\"flogs\"} | json | unwrap bytes | __error__=\"\" [$__interval]))", + "instant": true, + "legendFormat": "Bytes sent", + "range": false, + "refId": "A" + } + ], + "title": "Total Bytes Sent", + "transformations": [], + "type": "stat" + }, + { + "description": "", + "gridPos": { + "h": 4, + "w": 6, + "x": 18, + "y": 1 + }, + "id": 34, + "options": { + "content": "📊 Dashboard created by Ward Bekker (hope you like it!)\n\n🐦 Follow me on [Twitter](https://twitter.com/wardbekker) & [LinkedIn](https://www.linkedin.com/in/wardbekker/) for Grafana Loki updates \n\n🎥 Check out my [Grafana Loki video's](https://www.youtube.com/playlist?list=PLDGkOdUX1UjqEzcxQrbROMy8DN7MZv_h4) on Youtube", + "mode": "markdown" + }, + "pluginVersion": "8.4.2", + "transparent": true, + "type": "text" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "purple", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 5, + "x": 0, + "y": 5 + }, + "id": 22, + "interval": "5m", + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "value" + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "count(sum by (host) (count_over_time({job=\"flogs\"} | json | __error__=\"\" [$__interval])))", + "instant": true, + "legendFormat": "", + "range": false, + "refId": "A" + } + ], + "timeFrom": "5m", + "title": "Realtime visitors ", + "transformations": [], + "type": "stat" + }, + { + "datasource": {}, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 0, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "semi-dark-orange", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 12, + "y": 5 + }, + "id": 31, + "maxDataPoints": 1, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "count_over_time({job=\"flogs\"}[$__interval])", + "instant": true, + "range": false, + "refId": "A" + } + ], + "title": "# NGINX log lines", + "type": "stat" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "mappings": [], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "purple", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 15, + "y": 5 + }, + "hideTimeOverride": true, + "id": 19, + "links": [], + "maxDataPoints": 1, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "max" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "value" + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "sum(count_over_time({job=\"flogs\"} | json | status >= 500 |__error__=\"\"[$__interval])) / (sum(count_over_time({job=\"flogs\"} | json | __error__=\"\"[$__interval]))/ 100)", + "instant": false, + "legendFormat": "", + "range": true, + "refId": "A" + } + ], + "timeFrom": "1h", + "title": "% of 5xx requests ", + "type": "stat" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 100, + "min": 0, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "purple", + "value": null + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 18, + "y": 5 + }, + "hideTimeOverride": true, + "id": 18, + "interval": "10m", + "links": [], + "maxDataPoints": 1, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "value" + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "sum(count_over_time(({job=\"flogs\"} |= \"Googlebot\")[$__interval])) / (sum(count_over_time(({job=\"flogs\"} != \"Googlebot\")[$__interval])) / 100)", + "instant": true, + "legendFormat": "", + "range": false, + "refId": "A" + } + ], + "timeFrom": "1h", + "title": "% of requests by Googlebot", + "type": "stat" + }, + { + "datasource": { + "type": "marcusolsson-static-datasource", + "uid": "sptufMsnz" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "#96D98D", + "value": null + }, + { + "color": "#73BF69", + "value": 5 + }, + { + "color": "#56A64B", + "value": 10 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 12, + "x": 0, + "y": 9 + }, + "id": 14, + "maxDataPoints": 1, + "options": { + "basemap": { + "config": { + "server": "streets" + }, + "name": "Layer 0", + "type": "esri-xyz" + }, + "controls": { + "mouseWheelZoom": false, + "showAttribution": true, + "showDebug": false, + "showScale": false, + "showZoom": true + }, + "layers": [ + { + "config": { + "color": { + "fixed": "semi-dark-blue" + }, + "fillOpacity": 0.3, + "shape": "circle", + "showLegend": false, + "size": { + "field": "Value", + "fixed": 5, + "max": 50, + "min": 10 + }, + "style": { + "size": { + "fixed": 30, + "max": 15, + "min": 2 + }, + "symbol": { + "fixed": "img/icons/marker/circle.svg", + "mode": "fixed" + }, + "text": { + "field": "geo", + "fixed": "", + "mode": "field" + } + } + }, + "location": { + "gazetteer": "public/gazetteer/countries.json", + "lookup": "geo", + "mode": "lookup" + }, + "name": "Layer 1", + "type": "markers" + } + ], + "view": { + "id": "coords", + "lat": 44.212359, + "lon": 12.627564, + "zoom": 3 + } + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "marcusolsson-static-datasource", + "uid": "sptufMsnz" + }, + "frame": { + "fields": [ + { + "config": {}, + "name": "geo", + "type": "string", + "values": [ + "ES" + ] + } + ], + "meta": { + "preferredVisualisationType": "nodeGraph" + } + }, + "refId": "A" + } + ], + "title": "Requests per Country", + "transformations": [ + { + "id": "seriesToRows", + "options": {} + } + ], + "type": "geomap" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-BlPu" + }, + "custom": { + "align": "center", + "displayMode": "auto", + "filterable": false + }, + "mappings": [ + { + "options": { + "CN": { + "color": "transparent", + "index": 4, + "text": "🇨🇳CN" + }, + "DE": { + "color": "transparent", + "index": 2, + "text": "🇩🇪DE" + }, + "FR": { + "color": "transparent", + "index": 3, + "text": "🇫🇷FR" + }, + "GB": { + "color": "transparent", + "index": 7, + "text": "🇬🇧GB" + }, + "IN": { + "color": "transparent", + "index": 5, + "text": "🇮🇳IN" + }, + "IT": { + "color": "transparent", + "index": 6, + "text": "🇮🇹IT" + }, + "NL": { + "color": "transparent", + "index": 1, + "text": "🇳🇱NL" + }, + "US": { + "color": "transparent", + "index": 0, + "text": "🇺🇸 US" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "transparent", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 3, + "x": 12, + "y": 9 + }, + "hideTimeOverride": true, + "id": 32, + "maxDataPoints": 1, + "options": { + "footer": { + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": false, + "sortBy": [ + { + "desc": true, + "displayName": "Requests" + } + ] + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "topk(10, sum by (geoip_country_code) (count_over_time({job=\"flogs\"} | label_format geoip_country_code=\"ES\" [$__interval])))", + "instant": true, + "legendFormat": "{{remote_addr}}", + "range": false, + "refId": "A" + } + ], + "timeFrom": "15m", + "title": "Top Countries", + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Field": false, + "Time": true, + "Value #A": true + }, + "indexByName": { + "Time": 0, + "Value #A": 3, + "geoip_country_code": 2, + "remote_addr": 1 + }, + "renameByName": { + "Field": "IP Address", + "Total": "Requests", + "Value #A": "Requests", + "geoip_country_code": "Country", + "remote_addr": "IP Address " + } + } + } + ], + "type": "table" + }, + { + "description": "", + "gridPos": { + "h": 11, + "w": 9, + "x": 15, + "y": 9 + }, + "id": 11, + "options": { + "dedupStrategy": "signature", + "enableLogDetails": false, + "prettifyLogMessage": false, + "showCommonLabels": false, + "showLabels": false, + "showTime": false, + "sortOrder": "Descending", + "wrapLogMessage": false + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "{job=\"flogs\"} | json | line_format \"➡️ {{.method}} {{.request}} with HTTP status: {{.status}} \"", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Recent requests", + "type": "logs" + }, + { + "collapsed": false, + "datasource": { + "uid": "$datasource" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 26, + "panels": [], + "title": "Request statistics over time", + "type": "row" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "hue", + "hideFrom": { + "graph": false, + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 2, + "type": "log" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 0.2 + }, + { + "color": "red", + "value": 0.3 + } + ] + }, + "unit": "decbytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "95th percentile" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "max latency" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "super-light-blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "max latency" + }, + "properties": [ + { + "id": "custom.fillOpacity", + "value": 30 + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 0, + "y": 21 + }, + "id": 16, + "maxDataPoints": 50, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.0.0-beta3", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "sum(quantile_over_time(0.95,{job=\"flogs\"} | json | unwrap bytes | __error__=\"\" [$__interval]))", + "legendFormat": "95th percentile", + "refId": "C" + }, + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "sum(max_over_time({job=\"flogs\"} | json | unwrap bytes | __error__=\"\" [$__interval]))", + "legendFormat": "max latency", + "refId": "D" + } + ], + "title": "95th percentile of Request Size", + "type": "timeseries" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 39, + "gradientMode": "hue", + "hideFrom": { + "graph": false, + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 2, + "type": "log" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "HTTP Status 500" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "{statuscode=\"200\"} 200" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "{statuscode=\"404\"} 404" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "semi-dark-purple", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "{statuscode=\"500\"} 500" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "HTTP Status 404" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "HTTP Status 301" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "HTTP Status 200" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "semi-dark-blue", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 8, + "y": 21 + }, + "id": 2, + "maxDataPoints": 50, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.0.0-beta3", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "sum by (status) (count_over_time({job=\"flogs\"} | json | __error__=\"\" [$__interval]))", + "legendFormat": "HTTP Status {{status}}", + "refId": "A" + } + ], + "title": "HTTP status codes over time", + "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": "timeseries" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "hue", + "hideFrom": { + "graph": false, + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decbytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Bytes sent" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "appfelstrudel" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 16, + "y": 21 + }, + "id": 9, + "maxDataPoints": 50, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.0.0-beta3", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "sum(sum_over_time({job=\"flogs\"} | json | status=200 | unwrap bytes | __error__=\"\" [$__interval]))", + "legendFormat": "Bytes sent", + "refId": "A" + } + ], + "title": "Bytes Sent", + "transformations": [], + "type": "timeseries" + }, + { + "collapsed": false, + "datasource": { + "uid": "$datasource" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 30 + }, + "id": 28, + "panels": [], + "title": "Acquisition and Behaviour", + "type": "row" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "displayMode": "auto", + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Requests" + }, + "properties": [ + { + "id": "custom.displayMode", + "value": "gradient-gauge" + }, + { + "id": "color", + "value": { + "mode": "continuous-BlPu" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Requests" + }, + "properties": [ + { + "id": "custom.width", + "value": 300 + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 9, + "x": 0, + "y": 31 + }, + "id": 6, + "interval": "1m", + "maxDataPoints": 1, + "options": { + "footer": { + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "Requests" + } + ] + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "topk(10, sum by (referer) (count_over_time({job=\"flogs\"} | json | referer != \"\" and referer !~ \".*?$host.*?\" and referer !~ \".*?\\\\*\\\\*\\\\*.*?\" | __error__=\"\" [$__interval])))", + "instant": true, + "legendFormat": "{{http_referer}}", + "range": false, + "refId": "A" + } + ], + "timeFrom": "1m", + "title": "Top 10 HTTP Referers", + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true + }, + "indexByName": {}, + "renameByName": { + "Field": "Referer", + "Total": "Requests", + "Value #A": "Requests", + "http_referer": "HTTP Referrer" + } + } + } + ], + "type": "table" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "displayMode": "auto", + "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": 300 + }, + { + "id": "custom.displayMode", + "value": "gradient-gauge" + }, + { + "id": "color", + "value": { + "mode": "continuous-BlPu" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 15, + "x": 9, + "y": 31 + }, + "id": 7, + "maxDataPoints": 1, + "options": { + "footer": { + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "Requests" + } + ] + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "topk(10, sum by (user_identifier) (count_over_time({job=\"flogs\"} | json | status = 200 and request != \"/\" and user_identifier != \"-\" | __error__=\"\" [$__interval])))", + "instant": true, + "legendFormat": "{{user_identifier}}", + "range": false, + "refId": "A" + } + ], + "timeFrom": "15m", + "title": "Top 10 User Agents", + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Field": false, + "Time": true + }, + "indexByName": {}, + "renameByName": { + "Field": "Agent", + "Total": "Requests", + "Value #A": "Requests", + "http_user_agent": "User agent" + } + } + } + ], + "type": "table" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "displayMode": "auto", + "filterable": false + }, + "mappings": [ + { + "options": { + "NL": { + "index": 1, + "text": "🇳🇱" + }, + "US": { + "index": 0, + "text": "🇺🇸" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Requests" + }, + "properties": [ + { + "id": "custom.width", + "value": 300 + }, + { + "id": "custom.displayMode", + "value": "gradient-gauge" + }, + { + "id": "color", + "value": { + "mode": "continuous-BlPu" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Country" + }, + "properties": [ + { + "id": "custom.width", + "value": 74 + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 0, + "y": 37 + }, + "id": 3, + "interval": "1m", + "maxDataPoints": 1, + "options": { + "footer": { + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "Requests" + } + ] + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "topk(10, sum by (host, geoip_country_code) (count_over_time({job=\"flogs\"} | json | label_format geoip_country_code=\"ES\"| __error__=\"\" [$__interval])))", + "instant": true, + "legendFormat": "{{host}}", + "range": false, + "refId": "A" + } + ], + "timeFrom": "1m", + "title": "Top 10 visitor IPs", + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Field": false, + "Time": true + }, + "indexByName": { + "Time": 0, + "Value #A": 3, + "geoip_country_code": 2, + "remote_addr": 1 + }, + "renameByName": { + "Field": "IP Address", + "Total": "Requests", + "Value #A": "Requests", + "geoip_country_code": "Country", + "remote_addr": "IP Address " + } + } + } + ], + "type": "table" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "displayMode": "auto", + "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": 300 + }, + { + "id": "custom.displayMode", + "value": "gradient-gauge" + }, + { + "id": "color", + "value": { + "mode": "continuous-BlPu" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 15, + "x": 9, + "y": 37 + }, + "id": 12, + "maxDataPoints": 1, + "options": { + "footer": { + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "Requests" + } + ] + }, + "pluginVersion": "8.4.2", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "topk(10, sum by (request) (count_over_time({job=\"flogs\"} !~ `\\.ico|\\.svg|\\.css|\\.png|\\.txt|\\.js|\\.xml` | json | status = 200 and request != \"/\" | __error__=\"\" [$__interval])))", + "instant": true, + "legendFormat": "{{request_uri}}", + "range": false, + "refId": "A" + } + ], + "timeFrom": "15m", + "title": "Top 10 Requested Pages", + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true + }, + "indexByName": {}, + "renameByName": { + "Field": "Page", + "Time": "", + "Total": "", + "Value #A": "Requests", + "request_uri": "Path" + } + } + } + ], + "type": "table" + } + ], + "refresh": false, + "schemaVersion": 35, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Grafana Loki Dashboard for NGINX Service Mesh", + "uid": "Nz6kKgtGj", + "version": 6, + "weekStart": "" +} \ No newline at end of file diff --git a/5-3-loki-dashboards-nginx/provisioning/datasources/loki.yml b/5-3-loki-dashboards-nginx/provisioning/datasources/loki.yml new file mode 100644 index 0000000..fd2fc24 --- /dev/null +++ b/5-3-loki-dashboards-nginx/provisioning/datasources/loki.yml @@ -0,0 +1,8 @@ +apiVersion: 1 + +datasources: + - name: Loki + type: loki + url: http://loki:3100 + isDefault: true + editable: true