Require a token to scrape /metrics

The metrics endpoint fans out a gather to every connected host, so
anyone who could reach the controller could read cluster statistics and
put load on all hosts at will. Scraping now needs a user token holding
the new core.controller.metrics permission. The token is accepted via
Authorization: Bearer as well as X-Access-Token because Prometheus can
only send the former. Concurrent scrapes share one gather so hosts see
at most one metrics request at a time.

The three connection gauges in controller.ts now no-op before the
controller exists, like the other gauges there, so the endpoint can be
tested against the mock controller.

Closes #1009

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Fable 5.1 committed 2026-09-12 22:28:43 +00:00
1 parent 2b981a5734
commit 87aa7b3b4c
6 files changed
+151 -10

No files matched your search

+5
View File
@@ -144,6 +144,11 @@ export const corePermissions = [
title: "Modify controller config",
description: "Modify the controller config or entries of the controller config.",
},
{
name: "core.controller.metrics",
title: "Scrape metrics",
description: "Fetch the Prometheus metrics for the cluster from the controller's /metrics endpoint.",
},
{
name: "core.system.subscribe",
title: "Subscribe to system updates",