diff options
| author | bndw <ben@bdw.to> | 2026-02-15 10:39:05 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-15 10:39:05 -0800 |
| commit | 84dc5995f28e6d63d3cbb1af44daba7f10cbca66 (patch) | |
| tree | 0be357fd5759cb536e011c6bdc41fff8c4aaa905 /internal/metrics | |
| parent | f658ef072394ff9fd28244ad475859c210e8ec16 (diff) | |
feat: separate Auth Writes and Auth Reads on dashboard
- Added getMetricByLabels() helper for multi-label metric queries
- Split 'Authorized' metric into:
- Auth Writes: requests_total{method=EVENT, status=authorized}
- Auth Reads: requests_total{method=REQ, status=authorized}
- Provides clearer visibility into authenticated read vs write operations
Diffstat (limited to 'internal/metrics')
| -rw-r--r-- | internal/metrics/dashboard.html | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/internal/metrics/dashboard.html b/internal/metrics/dashboard.html index b7be1d7..5324c1e 100644 --- a/internal/metrics/dashboard.html +++ b/internal/metrics/dashboard.html | |||
| @@ -172,8 +172,12 @@ | |||
| 172 | <span class="metric-value" id="auth_success">0</span> | 172 | <span class="metric-value" id="auth_success">0</span> |
| 173 | </div> | 173 | </div> |
| 174 | <div class="metric"> | 174 | <div class="metric"> |
| 175 | <span class="metric-label">Authorized</span> | 175 | <span class="metric-label">Auth Writes</span> |
| 176 | <span class="metric-value" id="auth_authorized">0</span> | 176 | <span class="metric-value" id="auth_writes">0</span> |
| 177 | </div> | ||
| 178 | <div class="metric"> | ||
| 179 | <span class="metric-label">Auth Reads</span> | ||
| 180 | <span class="metric-value" id="auth_reads">0</span> | ||
| 177 | </div> | 181 | </div> |
| 178 | <div class="metric"> | 182 | <div class="metric"> |
| 179 | <span class="metric-label">Unauthorized</span> | 183 | <span class="metric-label">Unauthorized</span> |
| @@ -263,6 +267,17 @@ | |||
| 263 | return metric ? metric.value : 0; | 267 | return metric ? metric.value : 0; |
| 264 | } | 268 | } |
| 265 | 269 | ||
| 270 | function getMetricByLabels(metrics, name, labels) { | ||
| 271 | if (!metrics[name]) return 0; | ||
| 272 | const metric = metrics[name].find(m => { | ||
| 273 | for (const [key, value] of Object.entries(labels)) { | ||
| 274 | if (m.labels[key] !== value) return false; | ||
| 275 | } | ||
| 276 | return true; | ||
| 277 | }); | ||
| 278 | return metric ? metric.value : 0; | ||
| 279 | } | ||
| 280 | |||
| 266 | function formatUptime(ms) { | 281 | function formatUptime(ms) { |
| 267 | const seconds = Math.floor(ms / 1000); | 282 | const seconds = Math.floor(ms / 1000); |
| 268 | const minutes = Math.floor(seconds / 60); | 283 | const minutes = Math.floor(seconds / 60); |
| @@ -313,8 +328,11 @@ | |||
| 313 | document.getElementById('auth_success').textContent = | 328 | document.getElementById('auth_success').textContent = |
| 314 | getMetricByLabel(metrics, `${prefix}_relay_auth_attempts_total`, 'result', 'success'); | 329 | getMetricByLabel(metrics, `${prefix}_relay_auth_attempts_total`, 'result', 'success'); |
| 315 | 330 | ||
| 316 | document.getElementById('auth_authorized').textContent = | 331 | document.getElementById('auth_writes').textContent = |
| 317 | getMetricByLabel(metrics, `${prefix}_relay_requests_total`, 'status', 'authorized'); | 332 | getMetricByLabels(metrics, `${prefix}_relay_requests_total`, {method: 'EVENT', status: 'authorized'}); |
| 333 | |||
| 334 | document.getElementById('auth_reads').textContent = | ||
| 335 | getMetricByLabels(metrics, `${prefix}_relay_requests_total`, {method: 'REQ', status: 'authorized'}); | ||
| 318 | 336 | ||
| 319 | document.getElementById('auth_unauthorized').textContent = | 337 | document.getElementById('auth_unauthorized').textContent = |
| 320 | getMetricByLabel(metrics, `${prefix}_relay_requests_total`, 'status', 'unauthorized'); | 338 | getMetricByLabel(metrics, `${prefix}_relay_requests_total`, 'status', 'unauthorized'); |
