Pino HTTP Logs Dashboard
This Grafana dashboard utilizes the Loki data source to visualize and analyze logs generated by the Pino logging library. Logs from HTTP requests are captured using the Pino-HTTP plugin and are sent to a Loki instance via the Pino-Loki plugin, enabling real-time monitoring and historical analysis. The dashboard includes graph and table panels to display key metrics such as request status codes, response times, and error rates, making it easy to track application behavior and identify performance issues.
Flow Overview:
- Pino: Captures structured logs in a JSON format.
- Pino-HTTP: Specifically designed to handle HTTP request/response logging, capturing details such as request method, URL, and status code.
- Pino-Loki: Transmits the structured logs to a Loki instance, which acts as the centralized log storage and query engine.
To explore and use the published dashboard, visit:
https://grafana.com/grafana/dashboards/21900-pino-http-logs/
Sure, here is the json
{ "__inputs": [ { "name": "DS_LOKI", "label": "loki", "description": "", "type": "datasource", "pluginId": "loki", "pluginName": "Loki" } ], "__elements": {}, "__requires": [ { "type": "grafana", "id": "grafana", "name": "Grafana", "version": "11.5.1" }, { "type": "panel", "id": "logs", "name": "Logs", "version": "" }, { "type": "datasource", "id": "loki", "name": "Loki", "version": "1.0.0" }, { "type": "datasource", "id": "prometheus", "name": "Prometheus", "version": "1.0.0" }, { "type": "panel", "id": "stat", "name": "Stat", "version": "" }, { "type": "panel", "id": "timeseries", "name": "Time series", "version": "" } ], "annotations": { "list": [ { "builtIn": 1, "datasource": { "type": "grafana", "uid": "-- Grafana --" }, "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, "id": null, "links": [], "panels": [ { "datasource": { "type": "loki", "uid": "${datasource}" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "fieldMinMax": false, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "blue", "value": null } ] }, "unit": "none" }, "overrides": [] }, "gridPos": { "h": 5, "w": 6, "x": 0, "y": 0 }, "id": 3, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showPercentChange": true, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.1", "targets": [ { "datasource": { "type": "loki", "uid": "${DS_LOKI}" }, "editorMode": "builder", "expr": "sum(\n count_over_time(\n {app=~\"$app\", namespace=~\"$namespace\"} \n |= \"statusCode\"\n | json\n [${__range}]\n )\n)", "legendFormat": "{{res_statusCode}}", "queryType": "range", "refId": "A" } ], "title": "Total Requests", "type": "stat" }, { "datasource": { "type": "loki", "uid": "${datasource}" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "fieldMinMax": false, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] }, "unit": "none" }, "overrides": [] }, "gridPos": { "h": 5, "w": 6, "x": 6, "y": 0 }, "id": 2, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showPercentChange": true, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.1", "targets": [ { "datasource": { "type": "loki", "uid": "${DS_LOKI}" }, "editorMode": "code", "expr": "sum(\n count_over_time(\n {app=~\"$app\", namespace=~\"$namespace\"} \n |= \"statusCode\"\n | json\n | res_statusCode < 400\n [${__range}]\n )\n)", "legendFormat": "{{res_statusCode}}", "queryType": "range", "refId": "A" } ], "title": "Success Requests 2xx", "type": "stat" }, { "datasource": { "type": "loki", "uid": "${datasource}" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "fieldMinMax": false, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "orange", "value": null } ] }, "unit": "none" }, "overrides": [] }, "gridPos": { "h": 5, "w": 6, "x": 12, "y": 0 }, "id": 4, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showPercentChange": true, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.1", "targets": [ { "datasource": { "type": "loki", "uid": "${DS_LOKI}" }, "editorMode": "code", "expr": "sum(\n count_over_time(\n {app=~\"$app\", namespace=~\"$namespace\"} \n |= \"statusCode\"\n | json\n | res_statusCode >= 400 and res_statusCode < 500\n [${__range}]\n )\n)", "legendFormat": "{{res_statusCode}}", "queryType": "range", "refId": "A" } ], "title": "Bad Requests 4xx", "type": "stat" }, { "datasource": { "type": "loki", "uid": "${datasource}" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "fieldMinMax": false, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null } ] }, "unit": "none" }, "overrides": [] }, "gridPos": { "h": 5, "w": 6, "x": 18, "y": 0 }, "id": 5, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showPercentChange": true, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.1", "targets": [ { "datasource": { "type": "loki", "uid": "${DS_LOKI}" }, "editorMode": "code", "expr": "sum(\n count_over_time(\n {app=~\"$app\", namespace=~\"$namespace\"} \n |= \"statusCode\"\n | json\n | res_statusCode >= 500\n [${__range}]\n )\n)", "legendFormat": "{{res_statusCode}}", "queryType": "range", "refId": "A" } ], "title": "Errored Requests 5xx", "type": "stat" }, { "datasource": { "type": "loki", "uid": "${datasource}" }, "fieldConfig": { "defaults": { "color": { "fixedColor": "green", "mode": "shades" }, "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 1, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 50, "gradientMode": "opacity", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineStyle": { "fill": "solid" }, "lineWidth": 1, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "auto", "spanNulls": true, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } }, "fieldMinMax": false, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "blue", "value": null } ] }, "unit": "none" }, "overrides": [ { "matcher": { "id": "byName", "options": "500" }, "properties": [ { "id": "color", "value": { "fixedColor": "red", "mode": "fixed" } } ] }, { "matcher": { "id": "byName", "options": "404" }, "properties": [ { "id": "color", "value": { "fixedColor": "orange", "mode": "fixed" } } ] }, { "matcher": { "id": "byName", "options": "401" }, "properties": [ { "id": "color", "value": { "fixedColor": "orange", "mode": "fixed" } } ] } ] }, "gridPos": { "h": 6, "w": 24, "x": 0, "y": 5 }, "id": 1, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "hideZeros": false, "mode": "multi", "sort": "none" } }, "pluginVersion": "11.5.1", "targets": [ { "datasource": { "type": "loki", "uid": "${DS_LOKI}" }, "editorMode": "code", "expr": "count_over_time(\n {app=~\"$app\", namespace=~\"$namespace\"} \n |= \"statusCode\"\n | json\n | keep res_statusCode\n [1m]\n)", "legendFormat": "{{res_statusCode}}", "queryType": "range", "refId": "A" } ], "title": "Requests by Status Code", "type": "timeseries" }, { "datasource": { "type": "loki", "uid": "${datasource}" }, "gridPos": { "h": 14, "w": 24, "x": 0, "y": 11 }, "id": 6, "options": { "dedupStrategy": "none", "enableInfiniteScrolling": false, "enableLogDetails": true, "prettifyLogMessage": false, "showCommonLabels": false, "showLabels": false, "showTime": true, "sortOrder": "Descending", "wrapLogMessage": true }, "pluginVersion": "11.5.1", "targets": [ { "datasource": { "type": "loki", "uid": "${DS_LOKI}" }, "editorMode": "code", "expr": "{app=~\"$app\", namespace=~\"$namespace\", level=~\"$level\"}\n| json\n| res_statusCode=~\"$status\"", "queryType": "range", "refId": "A" } ], "title": "App Logs", "type": "logs" } ], "refresh": "1m", "schemaVersion": 40, "tags": [], "templating": { "list": [ { "current": {}, "includeAll": false, "label": "Datasource", "name": "datasource", "options": [], "query": "loki", "refresh": 1, "regex": "", "type": "datasource" }, { "current": {}, "datasource": { "type": "loki", "uid": "${datasource}" }, "definition": "", "includeAll": true, "label": "Aplication", "multi": true, "name": "app", "options": [], "query": { "label": "app", "refId": "LokiVariableQueryEditor-VariableQuery", "stream": "", "type": 1 }, "refresh": 2, "regex": "", "sort": 1, "type": "query" }, { "current": {}, "datasource": { "type": "loki", "uid": "${DS_LOKI}" }, "definition": "", "includeAll": true, "label": "Namespace", "multi": true, "name": "namespace", "options": [], "query": { "label": "namespace", "refId": "LokiVariableQueryEditor-VariableQuery", "stream": "", "type": 1 }, "refresh": 2, "regex": "", "type": "query" }, { "current": { "text": [ "$__all" ], "value": [ "$__all" ] }, "includeAll": true, "label": "Status Code", "multi": true, "name": "status", "options": [ { "selected": false, "text": "200", "value": "200" }, { "selected": false, "text": "201", "value": "201" }, { "selected": false, "text": "401", "value": "401" }, { "selected": false, "text": "404", "value": "404" }, { "selected": false, "text": "500", "value": "500" }, { "selected": false, "text": "", "value": "" } ], "query": "200,201,401,404,500, ", "type": "custom" }, { "current": {}, "datasource": { "type": "loki", "uid": "${datasource}" }, "definition": "", "includeAll": true, "label": "Log Level", "multi": true, "name": "level", "options": [], "query": { "label": "level", "refId": "LokiVariableQueryEditor-VariableQuery", "stream": "", "type": 1 }, "refresh": 1, "regex": "", "type": "query" } ] }, "time": { "from": "now-6h", "to": "now" }, "timepicker": {}, "timezone": "", "title": "Pino HTTP Logs", "uid": "dfx5h5b4k5e5sd", "version": 53, "weekStart": "" }