My nix-darwin and NixOS config
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(server): grafana dash!

+305
+292
modules/grafana-dashboard.json
··· 1 + { 2 + "__inputs": [], 3 + "__requires": [], 4 + "annotations": { "list": [] }, 5 + "editable": true, 6 + "fiscalYearStartMonth": 0, 7 + "graphTooltip": 1, 8 + "id": null, 9 + "links": [], 10 + "panels": [ 11 + 12 + { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, 13 + "id": 100, "title": "System", "type": "row" }, 14 + 15 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 16 + "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, 17 + "mappings": [], "max": 100, "min": 0, "thresholds": { "mode": "absolute", 18 + "steps": [{"color":"green","value":null},{"color":"yellow","value":70},{"color":"red","value":90}] }, 19 + "unit": "percent" }, "overrides": [] }, 20 + "gridPos": { "h": 6, "w": 4, "x": 0, "y": 1 }, 21 + "id": 1, "options": { "orientation": "auto", "reduceOptions": { "calcs": ["lastNotNull"] }, "showThresholdLabels": false, "showThresholdMarkers": true }, 22 + "title": "CPU Usage", 23 + "type": "gauge", 24 + "targets": [{ "datasource": { "type": "prometheus", "uid": "prometheus" }, 25 + "expr": "100 - (avg by(instance) (rate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100)", 26 + "legendFormat": "CPU %", "refId": "A" }] }, 27 + 28 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 29 + "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, 30 + "mappings": [], "max": 100, "min": 0, "thresholds": { "mode": "absolute", 31 + "steps": [{"color":"green","value":null},{"color":"yellow","value":75},{"color":"red","value":90}] }, 32 + "unit": "percent" }, "overrides": [] }, 33 + "gridPos": { "h": 6, "w": 4, "x": 4, "y": 1 }, 34 + "id": 2, "options": { "orientation": "auto", "reduceOptions": { "calcs": ["lastNotNull"] }, "showThresholdLabels": false, "showThresholdMarkers": true }, 35 + "title": "Memory Usage", 36 + "type": "gauge", 37 + "targets": [{ "datasource": { "type": "prometheus", "uid": "prometheus" }, 38 + "expr": "100 * (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes))", 39 + "legendFormat": "Memory %", "refId": "A" }] }, 40 + 41 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 42 + "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, 43 + "mappings": [], "max": 100, "min": 0, "thresholds": { "mode": "absolute", 44 + "steps": [{"color":"green","value":null},{"color":"yellow","value":75},{"color":"red","value":90}] }, 45 + "unit": "percent" }, "overrides": [] }, 46 + "gridPos": { "h": 6, "w": 4, "x": 8, "y": 1 }, 47 + "id": 3, "options": { "orientation": "auto", "reduceOptions": { "calcs": ["lastNotNull"] }, "showThresholdLabels": false, "showThresholdMarkers": true }, 48 + "title": "Root Disk Usage", 49 + "type": "gauge", 50 + "targets": [{ "datasource": { "type": "prometheus", "uid": "prometheus" }, 51 + "expr": "100 - (node_filesystem_avail_bytes{mountpoint=\"/\",fstype!~\"tmpfs|overlay\"} / node_filesystem_size_bytes{mountpoint=\"/\",fstype!~\"tmpfs|overlay\"} * 100)", 52 + "legendFormat": "/ disk %", "refId": "A" }] }, 53 + 54 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 55 + "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, 56 + "mappings": [], "max": 100, "min": 0, "thresholds": { "mode": "absolute", 57 + "steps": [{"color":"green","value":null},{"color":"yellow","value":75},{"color":"red","value":90}] }, 58 + "unit": "percent" }, "overrides": [] }, 59 + "gridPos": { "h": 6, "w": 4, "x": 12, "y": 1 }, 60 + "id": 4, "options": { "orientation": "auto", "reduceOptions": { "calcs": ["lastNotNull"] }, "showThresholdLabels": false, "showThresholdMarkers": true }, 61 + "title": "/srv Disk Usage", 62 + "type": "gauge", 63 + "targets": [{ "datasource": { "type": "prometheus", "uid": "prometheus" }, 64 + "expr": "100 - (node_filesystem_avail_bytes{mountpoint=\"/srv\",fstype!~\"tmpfs|overlay\"} / node_filesystem_size_bytes{mountpoint=\"/srv\",fstype!~\"tmpfs|overlay\"} * 100)", 65 + "legendFormat": "/srv disk %", "refId": "A" }] }, 66 + 67 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 68 + "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, 69 + "mappings": [], "thresholds": { "mode": "absolute", "steps": [{"color":"green","value":null}] }, 70 + "unit": "s" }, "overrides": [] }, 71 + "gridPos": { "h": 3, "w": 4, "x": 16, "y": 1 }, 72 + "id": 5, "options": { "colorMode": "value", "graphMode": "none", "reduceOptions": { "calcs": ["lastNotNull"] } }, 73 + "title": "Uptime", 74 + "type": "stat", 75 + "targets": [{ "datasource": { "type": "prometheus", "uid": "prometheus" }, 76 + "expr": "time() - node_boot_time_seconds", 77 + "legendFormat": "Uptime", "refId": "A" }] }, 78 + 79 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 80 + "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, 81 + "mappings": [], "thresholds": { "mode": "absolute", 82 + "steps": [{"color":"green","value":null},{"color":"yellow","value":4},{"color":"red","value":8}] }, 83 + "unit": "short", "decimals": 2 }, "overrides": [] }, 84 + "gridPos": { "h": 3, "w": 4, "x": 16, "y": 4 }, 85 + "id": 6, "options": { "colorMode": "background", "graphMode": "area", "reduceOptions": { "calcs": ["lastNotNull"] } }, 86 + "title": "Load Average (15m)", 87 + "type": "stat", 88 + "targets": [{ "datasource": { "type": "prometheus", "uid": "prometheus" }, 89 + "expr": "node_load15", 90 + "legendFormat": "Load 15m", "refId": "A" }] }, 91 + 92 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 93 + "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, 94 + "mappings": [], "thresholds": { "mode": "absolute", "steps": [{"color":"green","value":null}] }, 95 + "unit": "bytes" }, "overrides": [] }, 96 + "gridPos": { "h": 6, "w": 4, "x": 20, "y": 1 }, 97 + "id": 7, "options": { "colorMode": "value", "graphMode": "none", "reduceOptions": { "calcs": ["lastNotNull"] }, "orientation": "vertical" }, 98 + "title": "Memory", 99 + "type": "stat", 100 + "targets": [ 101 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 102 + "expr": "node_memory_MemTotal_bytes", "legendFormat": "Total", "refId": "A" }, 103 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 104 + "expr": "node_memory_MemAvailable_bytes", "legendFormat": "Available", "refId": "B" } 105 + ] }, 106 + 107 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 108 + "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, 109 + "custom": { "lineWidth": 2, "fillOpacity": 10 }, "unit": "percent", "min": 0, "max": 100 }, "overrides": [] }, 110 + "gridPos": { "h": 8, "w": 12, "x": 0, "y": 7 }, 111 + "id": 10, "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": "list", "placement": "bottom" } }, 112 + "title": "CPU Usage Over Time", 113 + "type": "timeseries", 114 + "targets": [ 115 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 116 + "expr": "100 - (avg by(cpu) (rate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100)", 117 + "legendFormat": "CPU {{cpu}}", "refId": "A" } 118 + ] }, 119 + 120 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 121 + "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, 122 + "custom": { "lineWidth": 2, "fillOpacity": 10 }, "unit": "bytes", "min": 0 }, "overrides": [] }, 123 + "gridPos": { "h": 8, "w": 12, "x": 12, "y": 7 }, 124 + "id": 11, "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": "list", "placement": "bottom" } }, 125 + "title": "Memory Over Time", 126 + "type": "timeseries", 127 + "targets": [ 128 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 129 + "expr": "node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes", 130 + "legendFormat": "Used", "refId": "A" }, 131 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 132 + "expr": "node_memory_MemAvailable_bytes", 133 + "legendFormat": "Available", "refId": "B" }, 134 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 135 + "expr": "node_memory_Cached_bytes", 136 + "legendFormat": "Cached", "refId": "C" } 137 + ] }, 138 + 139 + { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 15 }, 140 + "id": 101, "title": "Network", "type": "row" }, 141 + 142 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 143 + "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, 144 + "custom": { "lineWidth": 2, "fillOpacity": 10 }, "unit": "Bps" }, 145 + "overrides": [{ "matcher": { "id": "byName", "options": "Transmit" }, 146 + "properties": [{ "id": "custom.transform", "value": "negative-Y" }] }] }, 147 + "gridPos": { "h": 8, "w": 12, "x": 0, "y": 16 }, 148 + "id": 20, "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": "list", "placement": "bottom" } }, 149 + "title": "Network Traffic (eth0)", 150 + "type": "timeseries", 151 + "targets": [ 152 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 153 + "expr": "rate(node_network_receive_bytes_total{device=\"eth0\"}[5m])", 154 + "legendFormat": "Receive", "refId": "A" }, 155 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 156 + "expr": "rate(node_network_transmit_bytes_total{device=\"eth0\"}[5m])", 157 + "legendFormat": "Transmit", "refId": "B" } 158 + ] }, 159 + 160 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 161 + "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, 162 + "custom": { "lineWidth": 2, "fillOpacity": 10 }, "unit": "Bps" }, 163 + "overrides": [{ "matcher": { "id": "byName", "options": "Transmit" }, 164 + "properties": [{ "id": "custom.transform", "value": "negative-Y" }] }] }, 165 + "gridPos": { "h": 8, "w": 12, "x": 12, "y": 16 }, 166 + "id": 21, "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": "list", "placement": "bottom" } }, 167 + "title": "Network Traffic (tailscale0)", 168 + "type": "timeseries", 169 + "targets": [ 170 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 171 + "expr": "rate(node_network_receive_bytes_total{device=\"tailscale0\"}[5m])", 172 + "legendFormat": "Receive", "refId": "A" }, 173 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 174 + "expr": "rate(node_network_transmit_bytes_total{device=\"tailscale0\"}[5m])", 175 + "legendFormat": "Transmit", "refId": "B" } 176 + ] }, 177 + 178 + { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 24 }, 179 + "id": 102, "title": "Disk I/O", "type": "row" }, 180 + 181 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 182 + "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, 183 + "custom": { "lineWidth": 2, "fillOpacity": 10 }, "unit": "Bps" }, 184 + "overrides": [{ "matcher": { "id": "byName", "options": "Write" }, 185 + "properties": [{ "id": "custom.transform", "value": "negative-Y" }] }] }, 186 + "gridPos": { "h": 8, "w": 12, "x": 0, "y": 25 }, 187 + "id": 30, "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": "list", "placement": "bottom" } }, 188 + "title": "Disk I/O Throughput", 189 + "type": "timeseries", 190 + "targets": [ 191 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 192 + "expr": "rate(node_disk_read_bytes_total[5m])", 193 + "legendFormat": "Read {{device}}", "refId": "A" }, 194 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 195 + "expr": "rate(node_disk_written_bytes_total[5m])", 196 + "legendFormat": "Write {{device}}", "refId": "B" } 197 + ] }, 198 + 199 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 200 + "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, 201 + "custom": { "lineWidth": 2, "fillOpacity": 10 }, "unit": "ms" } }, 202 + "gridPos": { "h": 8, "w": 12, "x": 12, "y": 25 }, 203 + "id": 31, "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": "list", "placement": "bottom" } }, 204 + "title": "Disk I/O Latency", 205 + "type": "timeseries", 206 + "targets": [ 207 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 208 + "expr": "rate(node_disk_read_time_seconds_total[5m]) / rate(node_disk_reads_completed_total[5m]) * 1000", 209 + "legendFormat": "Read {{device}}", "refId": "A" }, 210 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 211 + "expr": "rate(node_disk_write_time_seconds_total[5m]) / rate(node_disk_writes_completed_total[5m]) * 1000", 212 + "legendFormat": "Write {{device}}", "refId": "B" } 213 + ] }, 214 + 215 + { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 33 }, 216 + "id": 103, "title": "Caddy", "type": "row" }, 217 + 218 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 219 + "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, 220 + "custom": { "lineWidth": 2, "fillOpacity": 10 }, "unit": "reqps" } }, 221 + "gridPos": { "h": 8, "w": 12, "x": 0, "y": 34 }, 222 + "id": 40, "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": "list", "placement": "bottom" } }, 223 + "title": "Request Rate by Status Code", 224 + "type": "timeseries", 225 + "targets": [ 226 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 227 + "expr": "sum by(code) (rate(caddy_http_requests_total[5m]))", 228 + "legendFormat": "{{code}}", "refId": "A" } 229 + ] }, 230 + 231 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 232 + "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, 233 + "custom": { "lineWidth": 2, "fillOpacity": 10 }, "unit": "s" } }, 234 + "gridPos": { "h": 8, "w": 12, "x": 12, "y": 34 }, 235 + "id": 41, "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": "list", "placement": "bottom" } }, 236 + "title": "Request Duration (p50/p95/p99)", 237 + "type": "timeseries", 238 + "targets": [ 239 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 240 + "expr": "histogram_quantile(0.50, sum by(le) (rate(caddy_http_request_duration_seconds_bucket[5m])))", 241 + "legendFormat": "p50", "refId": "A" }, 242 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 243 + "expr": "histogram_quantile(0.95, sum by(le) (rate(caddy_http_request_duration_seconds_bucket[5m])))", 244 + "legendFormat": "p95", "refId": "B" }, 245 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 246 + "expr": "histogram_quantile(0.99, sum by(le) (rate(caddy_http_request_duration_seconds_bucket[5m])))", 247 + "legendFormat": "p99", "refId": "C" } 248 + ] }, 249 + 250 + { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 42 }, 251 + "id": 104, "title": "PostgreSQL", "type": "row" }, 252 + 253 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 254 + "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, 255 + "custom": { "lineWidth": 2, "fillOpacity": 10 }, "unit": "short" } }, 256 + "gridPos": { "h": 8, "w": 12, "x": 0, "y": 43 }, 257 + "id": 50, "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": "list", "placement": "bottom" } }, 258 + "title": "DB Connections", 259 + "type": "timeseries", 260 + "targets": [ 261 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 262 + "expr": "pg_stat_activity_count", 263 + "legendFormat": "{{datname}} – {{state}}", "refId": "A" } 264 + ] }, 265 + 266 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 267 + "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, 268 + "custom": { "lineWidth": 2, "fillOpacity": 10 }, "unit": "ops" } }, 269 + "gridPos": { "h": 8, "w": 12, "x": 12, "y": 43 }, 270 + "id": 51, "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": "list", "placement": "bottom" } }, 271 + "title": "DB Transactions/sec", 272 + "type": "timeseries", 273 + "targets": [ 274 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 275 + "expr": "rate(pg_stat_database_xact_commit[5m])", 276 + "legendFormat": "commit {{datname}}", "refId": "A" }, 277 + { "datasource": { "type": "prometheus", "uid": "prometheus" }, 278 + "expr": "rate(pg_stat_database_xact_rollback[5m])", 279 + "legendFormat": "rollback {{datname}}", "refId": "B" } 280 + ] } 281 + ], 282 + "refresh": "30s", 283 + "schemaVersion": 38, 284 + "tags": ["server"], 285 + "templating": { "list": [] }, 286 + "time": { "from": "now-3h", "to": "now" }, 287 + "timepicker": {}, 288 + "timezone": "browser", 289 + "title": "Server Overview", 290 + "uid": "server-overview", 291 + "version": 1 292 + }
+13
modules/grafana.nix
··· 137 137 { 138 138 name = "Prometheus"; 139 139 type = "prometheus"; 140 + uid = "prometheus"; 140 141 url = "http://127.0.0.1:${toString prometheusPort}"; 141 142 isDefault = true; 143 + } 144 + ]; 145 + dashboards.settings.providers = [ 146 + { 147 + name = "default"; 148 + options.path = "/etc/grafana/dashboards"; 142 149 } 143 150 ]; 144 151 }; 152 + }; 153 + 154 + # ── Dashboard provisioning 155 + environment.etc."grafana/dashboards/server-overview.json" = { 156 + source = ./grafana-dashboard.json; 157 + mode = "0444"; 145 158 }; 146 159 147 160 # ── Caddy vhosts ─────────────────────────────────────────────────────────