diff --git a/dashboard/.gitignore b/dashboard/.gitignore new file mode 100644 index 0000000..4d333ef --- /dev/null +++ b/dashboard/.gitignore @@ -0,0 +1,2 @@ +node_modules +bun.lockb diff --git a/dashboard/package.json b/dashboard/package.json new file mode 100644 index 0000000..6035535 --- /dev/null +++ b/dashboard/package.json @@ -0,0 +1,18 @@ +{ + "scripts": { + "dev": "bun --watch router-monitor-dashboard.ts" + }, + "dependencies": { + "grafana-dashboard-helpers": "file:../../grafana-dashboards" + }, + "devDependencies": { + "@types/node": "^20.6.3" + }, + "prettier": { + "trailingComma": "es5", + "tabWidth": 2, + "semi": false, + "singleQuote": true, + "printWidth": 240 + } +} diff --git a/dashboard/router-monitor-dashboard.json b/dashboard/router-monitor-dashboard.json new file mode 100644 index 0000000..6a8df45 --- /dev/null +++ b/dashboard/router-monitor-dashboard.json @@ -0,0 +1,1760 @@ +{ + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 1, + "links": [], + "panels": [ + { + "type": "row", + "title": "Overview", + "panels": [], + "collapsed": false, + "gridPos": { + "x": 0, + "y": 0, + "w": 24, + "h": 1 + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "router_monitor_internet_connection_is_up{instance=~\"$instance\"}", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "stat", + "title": "Internet", + "gridPos": { + "x": 0, + "y": 1, + "w": 4, + "h": 3 + }, + "fieldConfig": { + "defaults": { + "mappings": [ + { + "options": { + "0": { + "text": "Down" + }, + "1": { + "text": "Up" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "orientation": "auto", + "textMode": "auto", + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "text": {} + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "(1 - avg_over_time(router_monitor_internet_connection_is_up{instance=~\"$instance\"}[$__range])) * $__range_s", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "stat", + "title": "Internet Downtime", + "gridPos": { + "x": 4, + "y": 1, + "w": 4, + "h": 3 + }, + "fieldConfig": { + "defaults": { + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "orientation": "auto", + "textMode": "auto", + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "text": {} + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "rate(router_monitor_internet_connection_duration_seconds_sum{instance=~\"$instance\"}[$__rate_interval]) / rate(router_monitor_internet_connection_duration_seconds_count{instance=~\"$instance\"}[$__rate_interval])", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "stat", + "title": "Average Connection Latency", + "gridPos": { + "x": 8, + "y": 1, + "w": 4, + "h": 3 + }, + "fieldConfig": { + "defaults": { + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 0.1 + }, + { + "color": "red", + "value": 0.2 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "mean" + ], + "fields": "" + }, + "orientation": "auto", + "textMode": "auto", + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "text": {} + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "histogram_quantile(0.99, sum by (le) (rate(router_monitor_internet_connection_duration_seconds_bucket{instance=~\"$instance\"}[$__rate_interval])))", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "stat", + "title": "Max Connection Latency", + "gridPos": { + "x": 12, + "y": 1, + "w": 4, + "h": 3 + }, + "fieldConfig": { + "defaults": { + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 0.5 + }, + { + "color": "red", + "value": 1 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "max" + ], + "fields": "" + }, + "orientation": "auto", + "textMode": "auto", + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "text": {} + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "router_monitor_dnsmasq_leases{instance=~\"$instance\"}", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "stat", + "title": "DHCP Leases", + "description": "Number of DHCP leases handed out", + "gridPos": { + "x": 16, + "y": 1, + "w": 4, + "h": 3 + }, + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "orientation": "auto", + "textMode": "auto", + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "text": {} + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "sum by(src) (increase(router_monitor_bytes_total{dst=~\"$localips\",src=~\"internet\",instance=~\"$instance\"}[$__range]))", + "legendFormat": "Download", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + }, + { + "editorMode": "code", + "expr": "sum by(dst) (increase(router_monitor_bytes_total{src=~\"$localips\",dst=~\"internet\",instance=~\"$instance\"}[$__range]))", + "legendFormat": "Upload", + "range": true, + "instant": false, + "format": "time_series", + "refId": "B" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "bargauge", + "title": "Bandwidth Usage", + "gridPos": { + "x": 20, + "y": 1, + "w": 4, + "h": 3 + }, + "fieldConfig": { + "defaults": { + "unit": "decbytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Upload" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "blue" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Download" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "green" + } + } + ] + } + ] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "orientation": "horizontal", + "displayMode": "basic", + "valueMode": "color", + "showUnfilled": true, + "minVizWidth": 0, + "minVizHeight": 15, + "text": {} + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "rate(router_monitor_internet_connection_duration_seconds_sum{instance=~\"$instance\"}[$__rate_interval])/\nrate(router_monitor_internet_connection_duration_seconds_count{instance=~\"$instance\"}[$__rate_interval])", + "legendFormat": "average", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + }, + { + "editorMode": "code", + "expr": "1 - router_monitor_internet_connection_is_up{instance=~\"$instance\"}", + "legendFormat": "down", + "range": true, + "instant": false, + "format": "time_series", + "refId": "B" + }, + { + "editorMode": "code", + "expr": "histogram_quantile(0.95, sum by (le) (rate(router_monitor_internet_connection_duration_seconds_bucket{instance=~\"$instance\"}[$__rate_interval])))", + "legendFormat": "95p", + "range": true, + "instant": false, + "format": "time_series", + "refId": "C" + }, + { + "editorMode": "code", + "expr": "histogram_quantile(0.50, sum by (le) (rate(router_monitor_internet_connection_duration_seconds_bucket{instance=~\"$instance\"}[$__rate_interval])))", + "legendFormat": "50p", + "range": true, + "instant": false, + "format": "time_series", + "refId": "D" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "timeseries", + "title": "Connection Latency", + "gridPos": { + "x": 0, + "y": 4, + "w": 24, + "h": 6 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "unit": "s" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "down" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + }, + { + "id": "custom.drawStyle", + "value": "bars" + }, + { + "id": "custom.fillOpacity", + "value": 100 + }, + { + "id": "custom.lineWidth", + "value": 0 + }, + { + "id": "max", + "value": 1 + }, + { + "id": "unit", + "value": "short" + } + ] + } + ] + }, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "maxDataPoints": 100 + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "max(router_monitor_dnsmasq_lease_info{instance=~\"$instance\"}) by (devicename, ip, mac) * 1000", + "range": true, + "instant": false, + "format": "table", + "refId": "A" + } + ], + "transformations": [ + { + "id": "groupBy", + "options": { + "fields": { + "Time": { + "aggregations": [], + "operation": null + }, + "devicename": { + "aggregations": [], + "operation": "groupby" + }, + "ip": { + "aggregations": [], + "operation": "groupby" + }, + "mac": { + "aggregations": [], + "operation": "groupby" + }, + "Value": { + "aggregations": [ + "lastNotNull" + ], + "operation": "aggregate" + } + } + } + }, + { + "id": "organize", + "options": { + "indexByName": { + "devicename": 0, + "mac": 1, + "ip": 2, + "Value (lastNotNull)": 3 + }, + "renameByName": { + "devicename": "Device Name", + "mac": "Mac Address", + "ip": "IP Address", + "Value (lastNotNull)": "Expires At" + } + } + }, + { + "id": "calculateField", + "options": { + "mode": "binary", + "reduce": { + "reducer": "lastNotNull", + "include": [ + "Expires At" + ] + }, + "binary": { + "left": "Expires At", + "reducer": "sum", + "right": "0" + }, + "alias": "Expires" + } + } + ], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "table", + "title": "DHCP Leases", + "gridPos": { + "x": 0, + "y": 10, + "w": 24, + "h": 12 + }, + "fieldConfig": { + "defaults": {}, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Expires At" + }, + "properties": [ + { + "id": "unit", + "value": "dateTimeAsLocalNoDateIfToday" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Expires" + }, + "properties": [ + { + "id": "unit", + "value": "dateTimeFromNow" + } + ] + } + ] + }, + "options": { + "cellHeight": "sm", + "frameIndex": -1, + "showHeader": true + } + }, + { + "type": "row", + "title": "Network Traffic", + "panels": [], + "collapsed": false, + "gridPos": { + "x": 0, + "y": 22, + "w": 24, + "h": 1 + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "\nlabel_replace(\n sum by(dst) (\n increase(\n router_monitor_bytes_total{dst=~\"$localips\",src=~\"internet\",instance=~\"$instance\"}[$__range]\n ) > 0\n ),\n \"ip\", \"$1\", \"dst\", \"(.*)\"\n)\n\n+ on(ip) group_left(devicename)\n\n(0 * max(router_monitor_dnsmasq_lease_info) by (devicename, ip, mac))\n", + "legendFormat": "{{ devicename }} ({{ ip }})", + "range": false, + "instant": true, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "piechart", + "title": "Total Bytes Downloaded - by local IP (pie chart)", + "gridPos": { + "x": 0, + "y": 23, + "w": 12, + "h": 12 + }, + "fieldConfig": { + "defaults": { + "unit": "decbytes" + }, + "overrides": [] + }, + "options": { + "displayLabels": [], + "legend": { + "showLegend": true, + "displayMode": "table", + "placement": "right", + "values": [ + "percent", + "value" + ], + "calcs": [] + }, + "orientation": "auto", + "pieType": "pie", + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "\nlabel_replace(\n sum by(src) (\n increase(\n router_monitor_bytes_total{src=~\"$localips\",dst=~\"internet\",instance=~\"$instance\"}[$__range]\n ) > 0\n ),\n \"ip\", \"$1\", \"src\", \"(.*)\"\n)\n\n+ on(ip) group_left(devicename)\n\n(0 * max(router_monitor_dnsmasq_lease_info) by (devicename, ip, mac))\n", + "legendFormat": "{{ devicename }} ({{ ip }})", + "range": false, + "instant": true, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "piechart", + "title": "Total Bytes Uploaded - by local IP (pie chart)", + "gridPos": { + "x": 12, + "y": 23, + "w": 12, + "h": 12 + }, + "fieldConfig": { + "defaults": { + "unit": "decbytes" + }, + "overrides": [] + }, + "options": { + "displayLabels": [], + "legend": { + "showLegend": true, + "displayMode": "table", + "placement": "right", + "values": [ + "percent", + "value" + ], + "calcs": [] + }, + "orientation": "auto", + "pieType": "pie", + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "\nlabel_replace(\n sum by(dst) (\n increase(\n router_monitor_bytes_total{dst=~\"$localips\",src=~\"internet\",instance=~\"$instance\"}[$__range]\n ) > 0\n ),\n \"ip\", \"$1\", \"dst\", \"(.*)\"\n)\n\n+ on(ip) group_left(devicename)\n\n(0 * max(router_monitor_dnsmasq_lease_info) by (devicename, ip, mac))\n", + "legendFormat": "{{ devicename }} ({{ ip }})", + "range": false, + "instant": true, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "bargauge", + "title": "Total Bytes Downloaded - by local IP (bar gauge)", + "gridPos": { + "x": 0, + "y": 35, + "w": 12, + "h": 12 + }, + "fieldConfig": { + "defaults": { + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "orientation": "horizontal", + "displayMode": "basic", + "valueMode": "color", + "showUnfilled": true, + "minVizWidth": 0, + "minVizHeight": 15, + "text": {} + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "\nlabel_replace(\n sum by(src) (\n increase(\n router_monitor_bytes_total{src=~\"$localips\",dst=~\"internet\",instance=~\"$instance\"}[$__range]\n ) > 0\n ),\n \"ip\", \"$1\", \"src\", \"(.*)\"\n)\n\n+ on(ip) group_left(devicename)\n\n(0 * max(router_monitor_dnsmasq_lease_info) by (devicename, ip, mac))\n", + "legendFormat": "{{ devicename }} ({{ ip }})", + "range": false, + "instant": true, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "bargauge", + "title": "Total Bytes Uploaded - by local IP (bar gauge)", + "gridPos": { + "x": 12, + "y": 35, + "w": 12, + "h": 12 + }, + "fieldConfig": { + "defaults": { + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "orientation": "horizontal", + "displayMode": "basic", + "valueMode": "color", + "showUnfilled": true, + "minVizWidth": 0, + "minVizHeight": 15, + "text": {} + } + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "sum by(dst) (increase(router_monitor_bytes_total{dst=~\"$localips\",src=~\"internet\",instance=~\"$instance\"}[$__interval] > 0))", + "legendFormat": "{{ dst }}", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "timeseries", + "title": "Total bytes downloaded - by local IP", + "gridPos": { + "x": 0, + "y": 47, + "w": 6, + "h": 12 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "bars", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "stepAfter", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "options": { + "legend": { + "calcs": [ + "sum" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "maxDataPoints": 100 + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "sum by(src) (increase(router_monitor_bytes_total{src=~\"$localips\",dst=~\"internet\",instance=~\"$instance\"}[$__interval] > 0))", + "legendFormat": "{{ src }}", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "timeseries", + "title": "Total bytes uploaded - by local IP", + "gridPos": { + "x": 6, + "y": 47, + "w": 6, + "h": 12 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "bars", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "stepAfter", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "options": { + "legend": { + "calcs": [ + "sum" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "maxDataPoints": 100 + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "sum by(dst) (rate(router_monitor_bytes_total{dst=~\"$localips\",src=~\"internet\",instance=~\"$instance\"}[$__rate_interval] > 0))", + "legendFormat": "{{ dst }}", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "timeseries", + "title": "Download Data Rate - by local IP", + "gridPos": { + "x": 12, + "y": 47, + "w": 6, + "h": 12 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "Bps" + }, + "overrides": [] + }, + "options": { + "legend": { + "calcs": [ + "sum" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "maxDataPoints": 100 + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "sum by(src) (rate(router_monitor_bytes_total{src=~\"$localips\",dst=~\"internet\",instance=~\"$instance\"}[$__rate_interval] > 0))", + "legendFormat": "{{ src }}", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "timeseries", + "title": "Upload Data Rate - by local IP", + "gridPos": { + "x": 18, + "y": 47, + "w": 6, + "h": 12 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "Bps" + }, + "overrides": [] + }, + "options": { + "legend": { + "calcs": [ + "sum" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "maxDataPoints": 100 + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "sum by(src) (increase(router_monitor_bytes_total{dst=~\"$localips\",src=~\"internet\",instance=~\"$instance\"}[$__interval] > 0))", + "legendFormat": "{{ src }}", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "timeseries", + "title": "Total bytes downloaded", + "gridPos": { + "x": 0, + "y": 59, + "w": 6, + "h": 10 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "bars", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "stepAfter", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "options": { + "legend": { + "calcs": [ + "sum" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "maxDataPoints": 100 + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "sum by(dst) (increase(router_monitor_bytes_total{src=~\"$localips\",dst=~\"internet\",instance=~\"$instance\"}[$__interval] > 0))", + "legendFormat": "{{ dst }}", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "timeseries", + "title": "Total bytes uploaded", + "gridPos": { + "x": 6, + "y": 59, + "w": 6, + "h": 10 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "bars", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "stepAfter", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "options": { + "legend": { + "calcs": [ + "sum" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "maxDataPoints": 100 + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "sum by(src) (rate(router_monitor_bytes_total{dst=~\"$localips\",src=~\"internet\",instance=~\"$instance\"}[$__rate_interval] > 0))", + "legendFormat": "{{ src }}", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "timeseries", + "title": "Download Data Rate", + "gridPos": { + "x": 12, + "y": 59, + "w": 6, + "h": 10 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "Bps" + }, + "overrides": [] + }, + "options": { + "legend": { + "calcs": [ + "sum" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "maxDataPoints": 100 + }, + { + "links": [], + "repeatDirection": "h", + "tags": [], + "targets": [ + { + "editorMode": "code", + "expr": "sum by(dst) (rate(router_monitor_bytes_total{src=~\"$localips\",dst=~\"internet\",instance=~\"$instance\"}[$__rate_interval] > 0))", + "legendFormat": "{{ dst }}", + "range": true, + "instant": false, + "format": "time_series", + "refId": "A" + } + ], + "transformations": [], + "transparent": false, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "timeseries", + "title": "Upload Data Rate", + "gridPos": { + "x": 18, + "y": 59, + "w": 6, + "h": 10 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "Bps" + }, + "overrides": [] + }, + "options": { + "legend": { + "calcs": [ + "sum" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "maxDataPoints": 100 + } + ], + "schemaVersion": 36, + "style": "dark", + "tags": [ + "router-monitor" + ], + "timezone": "browser", + "description": "Dashboard for Router Monitor", + "time": { + "from": "now-6h", + "to": "now" + }, + "title": "Router Monitor", + "uid": "router-monitor", + "version": 1, + "templating": { + "list": [ + { + "multi": false, + "options": [], + "skipUrlSync": false, + "description": null, + "hide": 0, + "datasource": null, + "type": "datasource", + "label": "Prometheus", + "name": "DS_PROMETHEUS", + "query": "prometheus" + }, + { + "multi": true, + "options": [], + "skipUrlSync": false, + "description": null, + "hide": 0, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "query", + "label": "Local IPs", + "name": "localips", + "query": "label_values(router_monitor_packets_total, dst)", + "includeAll": true, + "refresh": 2 + }, + { + "options": [], + "skipUrlSync": false, + "description": null, + "hide": 0, + "datasource": { + "uid": "${DS_PROMETHEUS}" + }, + "type": "query", + "label": "Instance", + "name": "instance", + "query": "label_values(router_monitor_internet_connection_is_up, instance)", + "refresh": 2 + } + ] + } +} \ No newline at end of file diff --git a/dashboard/router-monitor-dashboard.ts b/dashboard/router-monitor-dashboard.ts new file mode 100644 index 0000000..dbb050c --- /dev/null +++ b/dashboard/router-monitor-dashboard.ts @@ -0,0 +1,313 @@ +import { Dashboard, DashboardCursorSync, DataSourceRef, LegendDisplayMode, MappingType, TableCellHeight, ThresholdsMode, VizOrientation, defaultDashboard } from '@grafana/schema' +import { + NewBarGaugePanel, + NewPanelGroup, + NewPanelRow, + NewPieChartPanel, + NewPrometheusDatasource as NewPrometheusDatasourceVariable, + NewQueryVariable, + NewStatPanel, + NewTablePanel, + NewTimeSeriesPanel, + PanelRow, + PanelRowAndGroups, + Unit, + autoLayout, + writeDashboardAndPostToGrafana, +} from 'grafana-dashboard-helpers' + +const datasource: DataSourceRef = { + uid: '${DS_PROMETHEUS}', +} + +const totalBytesByLocalIPQuery = (labels: string, ipLabel: string) => ` +label_replace( + sum by(${ipLabel}) ( + increase( + router_monitor_bytes_total{${labels},instance=~"$instance"}[$__range] + ) > 0 + ), + "ip", "$1", "${ipLabel}", "(.*)" +) + ++ on(ip) group_left(devicename) + +(0 * max(router_monitor_dnsmasq_lease_info) by (devicename, ip, mac)) +` + +const totalBytesByLocalIPPieChartPanel = (uploadOrDownload: string, labels: string, ipLabel: string) => + NewPieChartPanel({ + title: `Total Bytes ${uploadOrDownload}ed - by local IP (pie chart)`, + targets: [{ expr: totalBytesByLocalIPQuery(labels, ipLabel), legendFormat: '{{ devicename }} ({{ ip }})', type: 'instant' }], + defaultUnit: Unit.BYTES_SI, + }) + +const totalBytesByLocalIPBarGaugePanel = (uploadOrDownload: string, labels: string, ipLabel: string) => + NewBarGaugePanel({ + title: `Total Bytes ${uploadOrDownload}ed - by local IP (bar gauge)`, + targets: [{ expr: totalBytesByLocalIPQuery(labels, ipLabel), legendFormat: '{{ devicename }} ({{ ip }})', type: 'instant' }], + defaultUnit: Unit.BYTES_SI, + thresholds: { mode: ThresholdsMode.Absolute, steps: [{ color: 'green', value: null }] }, + options: { orientation: VizOrientation.Horizontal }, + }) + +const totalBytesTimeSeriesPanel = (title: string, labels: string, ipLabel: string) => + NewTimeSeriesPanel({ + title: title, + targets: [{ expr: `sum by(${ipLabel}) (increase(router_monitor_bytes_total{${labels},instance=~"$instance"}[$__interval] > 0))`, legendFormat: `{{ ${ipLabel} }}` }], + defaultUnit: Unit.BYTES_SI, + thresholds: { mode: ThresholdsMode.Absolute, steps: [{ color: 'green', value: null }] }, + type: 'bar', + options: { legend: { calcs: ['sum'], placement: 'bottom' } }, + }) + +const dataRateTimeSeriesPanel = (title: string, labels: string, ipLabel: string) => + NewTimeSeriesPanel({ + title, + targets: [{ expr: `sum by(${ipLabel}) (rate(router_monitor_bytes_total{${labels},instance=~"$instance"}[$__rate_interval] > 0))`, legendFormat: `{{ ${ipLabel} }}` }], + defaultUnit: Unit.BYTES_PER_SEC_SI, + thresholds: { mode: ThresholdsMode.Absolute, steps: [{ color: 'green', value: null }] }, + options: { legend: { calcs: ['sum'], placement: 'bottom' } }, + }) + +const networkTrafficPanels: PanelRow[] = [ + NewPanelRow({ datasource, height: 12 }, [ + // prettier hack + totalBytesByLocalIPPieChartPanel('Download', 'dst=~"$localips",src=~"internet"', 'dst'), + totalBytesByLocalIPPieChartPanel('Upload', 'src=~"$localips",dst=~"internet"', 'src'), + ]), + NewPanelRow({ datasource, height: 12 }, [ + // prettier hack + totalBytesByLocalIPBarGaugePanel('Download', 'dst=~"$localips",src=~"internet"', 'dst'), + totalBytesByLocalIPBarGaugePanel('Upload', 'src=~"$localips",dst=~"internet"', 'src'), + ]), + NewPanelRow({ datasource, height: 12 }, [ + // prettier hack + totalBytesTimeSeriesPanel('Total bytes downloaded - by local IP', 'dst=~"$localips",src=~"internet"', 'dst'), + totalBytesTimeSeriesPanel('Total bytes uploaded - by local IP', 'src=~"$localips",dst=~"internet"', 'src'), + dataRateTimeSeriesPanel('Download Data Rate - by local IP', 'dst=~"$localips",src=~"internet"', 'dst'), + dataRateTimeSeriesPanel('Upload Data Rate - by local IP', 'src=~"$localips",dst=~"internet"', 'src'), + ]), + NewPanelRow({ datasource, height: 10 }, [ + // prettier hack + totalBytesTimeSeriesPanel('Total bytes downloaded', 'dst=~"$localips",src=~"internet"', 'src'), + totalBytesTimeSeriesPanel('Total bytes uploaded', 'src=~"$localips",dst=~"internet"', 'dst'), + dataRateTimeSeriesPanel('Download Data Rate', 'dst=~"$localips",src=~"internet"', 'src'), + dataRateTimeSeriesPanel('Upload Data Rate', 'src=~"$localips",dst=~"internet"', 'dst'), + ]), +] + +const panels: PanelRowAndGroups = [ + NewPanelGroup({ title: 'Overview' }, [ + NewPanelRow({ datasource, height: 3 }, [ + NewStatPanel({ + title: 'Internet', + targets: [{ expr: 'router_monitor_internet_connection_is_up{instance=~"$instance"}' }], + defaultUnit: Unit.SHORT, + mappings: [{ options: { '0': { text: 'Down' }, '1': { text: 'Up' } }, type: MappingType.ValueToText }], + thresholds: { + mode: ThresholdsMode.Absolute, + steps: [ + { color: 'red', value: null }, + { color: 'green', value: 1 }, + ], + }, + }), + NewStatPanel({ + title: 'Internet Downtime', + targets: [{ expr: '(1 - avg_over_time(router_monitor_internet_connection_is_up{instance=~"$instance"}[$__range])) * $__range_s' }], + thresholds: { + mode: ThresholdsMode.Absolute, + steps: [ + { color: 'green', value: null }, + { color: 'red', value: 1 }, + ], + }, + defaultUnit: Unit.SECONDS, + }), + NewStatPanel({ + title: 'Average Connection Latency', + targets: [ + { + expr: 'rate(router_monitor_internet_connection_duration_seconds_sum{instance=~"$instance"}[$__rate_interval]) / rate(router_monitor_internet_connection_duration_seconds_count{instance=~"$instance"}[$__rate_interval])', + }, + ], + reduceCalc: 'mean', + thresholds: { + mode: ThresholdsMode.Absolute, + steps: [ + { color: 'green', value: null }, + { color: '#EAB839', value: 0.1 }, + { color: 'red', value: 0.2 }, + ], + }, + defaultUnit: Unit.SECONDS, + }), + NewStatPanel({ + title: 'Max Connection Latency', + targets: [{ expr: 'histogram_quantile(0.99, sum by (le) (rate(router_monitor_internet_connection_duration_seconds_bucket{instance=~"$instance"}[$__rate_interval])))' }], + defaultUnit: Unit.SECONDS, + reduceCalc: 'max', + thresholds: { + mode: ThresholdsMode.Absolute, + steps: [ + { color: 'green', value: null }, + { color: '#EAB839', value: 0.5 }, + { color: 'red', value: 1 }, + ], + }, + }), + NewStatPanel({ + title: 'DHCP Leases', + description: 'Number of DHCP leases handed out', + targets: [{ expr: 'router_monitor_dnsmasq_leases{instance=~"$instance"}' }], + defaultUnit: Unit.SHORT, + }), + NewBarGaugePanel({ + title: 'Bandwidth Usage', + targets: [ + { expr: 'sum by(src) (increase(router_monitor_bytes_total{dst=~"$localips",src=~"internet",instance=~"$instance"}[$__range]))', legendFormat: 'Download' }, + { expr: 'sum by(dst) (increase(router_monitor_bytes_total{src=~"$localips",dst=~"internet",instance=~"$instance"}[$__range]))', legendFormat: 'Upload' }, + ], + defaultUnit: Unit.BYTES_SI, + overrides: [ + { + matcher: { id: 'byName', options: 'Upload' }, + properties: [{ id: 'color', value: { mode: 'fixed', fixedColor: 'blue' } }], + }, + { + matcher: { id: 'byName', options: 'Download' }, + properties: [{ id: 'color', value: { mode: 'fixed', fixedColor: 'green' } }], + }, + ], + options: { orientation: VizOrientation.Horizontal }, + }), + ]), + ]), + NewPanelRow({ datasource, height: 6 }, [ + NewTimeSeriesPanel({ + title: 'Connection Latency', + targets: [ + { + expr: 'rate(router_monitor_internet_connection_duration_seconds_sum{instance=~"$instance"}[$__rate_interval])/\nrate(router_monitor_internet_connection_duration_seconds_count{instance=~"$instance"}[$__rate_interval])', + legendFormat: 'average', + }, + { + expr: '1 - router_monitor_internet_connection_is_up{instance=~"$instance"}', + legendFormat: 'down', + }, + // { + // expr: 'histogram_quantile(0.99, sum by (le) (rate(router_monitor_internet_connection_duration_seconds_bucket{instance=~"$instance"}[$__rate_interval])))', + // legendFormat: '99p', + // }, + { + expr: 'histogram_quantile(0.95, sum by (le) (rate(router_monitor_internet_connection_duration_seconds_bucket{instance=~"$instance"}[$__rate_interval])))', + legendFormat: '95p', + }, + { + expr: 'histogram_quantile(0.50, sum by (le) (rate(router_monitor_internet_connection_duration_seconds_bucket{instance=~"$instance"}[$__rate_interval])))', + legendFormat: '50p', + }, + ], + options: { + legend: { calcs: [], displayMode: LegendDisplayMode.List }, + }, + defaultUnit: Unit.SECONDS, + overrides: [ + { + matcher: { id: 'byName', options: 'down' }, + properties: [ + { id: 'color', value: { mode: 'fixed', fixedColor: 'red' } }, + { id: 'custom.drawStyle', value: 'bars' }, + { id: 'custom.fillOpacity', value: 100 }, + { id: 'custom.lineWidth', value: 0 }, + { id: 'max', value: 1 }, + { id: 'unit', value: 'short' }, + ], + }, + ], + }), + ]), + NewPanelRow({ datasource, height: 12 }, [ + NewTablePanel({ + title: 'DHCP Leases', + targets: [{ expr: 'max(router_monitor_dnsmasq_lease_info{instance=~"$instance"}) by (devicename, ip, mac) * 1000', format: 'table' }], + options: { cellHeight: TableCellHeight.Sm }, + overrides: [ + { + matcher: { id: 'byName', options: 'Expires At' }, + properties: [{ id: 'unit', value: 'dateTimeAsLocalNoDateIfToday' }], + }, + { + matcher: { id: 'byName', options: 'Expires' }, + properties: [{ id: 'unit', value: 'dateTimeFromNow' }], + }, + ], + transformations: [ + { + id: 'groupBy', + options: { + fields: { + Time: { aggregations: [], operation: null }, + devicename: { aggregations: [], operation: 'groupby' }, + ip: { aggregations: [], operation: 'groupby' }, + mac: { aggregations: [], operation: 'groupby' }, + Value: { aggregations: ['lastNotNull'], operation: 'aggregate' }, + }, + }, + }, + { + id: 'organize', + options: { + indexByName: { devicename: 0, mac: 1, ip: 2, 'Value (lastNotNull)': 3 }, + renameByName: { + devicename: 'Device Name', + mac: 'Mac Address', + ip: 'IP Address', + 'Value (lastNotNull)': 'Expires At', + }, + }, + }, + { + id: 'calculateField', + options: { + mode: 'binary', + reduce: { reducer: 'lastNotNull', include: ['Expires At'] }, + binary: { left: 'Expires At', reducer: 'sum', right: '0' }, + alias: 'Expires', + }, + }, + ], + }), + ]), + NewPanelGroup({ title: 'Network Traffic' }, networkTrafficPanels), +] + +const dashboard: Dashboard = { + ...defaultDashboard, + description: 'Dashboard for Router Monitor', + graphTooltip: DashboardCursorSync.Crosshair, + style: 'dark', + tags: ['router-monitor'], + time: { + from: 'now-6h', + to: 'now', + }, + title: 'Router Monitor', + uid: 'router-monitor', + version: 1, + panels: autoLayout(panels), + templating: { + list: [ + NewPrometheusDatasourceVariable({ name: 'DS_PROMETHEUS', label: 'Prometheus' }), + NewQueryVariable({ datasource, name: 'localips', label: 'Local IPs', query: 'label_values(router_monitor_packets_total, dst)', multi: true, includeAll: true }), + NewQueryVariable({ datasource, name: 'instance', label: 'Instance', query: 'label_values(router_monitor_internet_connection_is_up, instance)' }), + ], + }, +} + +writeDashboardAndPostToGrafana({ + grafanaURL: process.env.GRAFANA_URL, + dashboard, + filename: 'router-monitor-dashboard.json', +}) diff --git a/dashboard/tsconfig.json b/dashboard/tsconfig.json new file mode 100644 index 0000000..eeac1ee --- /dev/null +++ b/dashboard/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compileOptions": { + "types": [ + "node" + ] + } +} \ No newline at end of file