Skip to content

Metrics: require authentication for local Prometheus, Alertmanager and Grafana #8390

In progress

Description

@gsanchietti

The metrics application runs three services on the leader node: Prometheus (collects the metrics), Alertmanager (handles the alerts) and Grafana (shows the dashboards). They listen only on the node itself, but they trust any program that connects from there. Any other application installed on the same node could read the metrics or change the alerts. The purpose of this change is to make each service check who is calling, without changing how administrators use them.

Proposed solution

  • Prometheus and Alertmanager ask for a password. The metrics application creates a random password once, keeps it in a file readable only by the application itself, and uses it in all its own components. The cluster alert list, run by the core as the system administrator on the same node, reads the same file.
  • Grafana relies on a signed token issued by the core for logged-in users. There is nothing to set up on install, update or leader change.
  • The Prometheus web interface is no longer published through the web proxy, and the related "Prometheus path" setting is removed from the Metrics settings page. For troubleshooting, administrators can reach it through an SSH tunnel, as described in the module README.
  • Logging in to Grafana from the cluster administration page works as before.

Upgrade notes:

  • The core must be updated before the metrics application: the new metrics release requires it.
  • Alert rules added by hand to Loki no longer reach Alertmanager, because they cannot send the password.

Alternative solutions

  • Leaving Prometheus without a password, as it only allows reading: discarded, because the metrics can still reveal information about the whole cluster.
  • Letting the core ask the metrics application for the alerts through a task: discarded as more complex than needed, since the core runs as administrator on the same node and can read the password directly.

Additional context

The administrator manual explains where to read the password and how to reach Prometheus.

See also

Activity

  1. added this to the NethServer 8.11 milestone on Nov 27, 2026
  2. self-assigned this
    on Nov 27, 2026
  3. moved this from Backlog to ToDo in NethServeron Nov 27, 2026
  4. moved this from ToDo to In Progress in NethServeron Nov 27, 2026
  5. DavidePrincipi commented on Dec 1, 2026

    @DavidePrincipi
    Member
  6. gsanchietti commented on Dec 2, 2026

    @gsanchietti
    MemberAuthor

    Testing versions: ghcr.io/nethserver/core:3.26.0-dev.6, ghcr.io/nethserver/metrics:1.7.2-dev.2

    Fresh install (create the cluster after the core install, then update Metrics):

    curl https://raw.githubusercontent.com/NethServer/ns8-core/main/core/install.sh > install.sh
    bash install.sh ghcr.io/nethserver/core:latest ghcr.io/nethserver/core:3.26.0-dev.6
    update-module ghcr.io/nethserver/metrics:1.7.2-dev.2 metrics1
    

    Update an existing cluster (core first, then Metrics):

    update-core ghcr.io/nethserver/core:3.26.0-dev.6
    update-module ghcr.io/nethserver/metrics:1.7.2-dev.2 metrics1
    

    Test case 1: fresh install

    1. Open the Metrics settings page: there is no "Prometheus path" field.
    2. Set a Grafana path and save, then open Grafana from the link on the same page: it opens without asking for a password and the dashboards show data.
    3. Open the Nodes page: CPU, memory and disk data are shown.
    4. On the leader node run runagent -m metrics1 test-alert: the test alert shows up in the cluster alerts page.

    Test case 2: update from the previous version

    1. Start from a cluster with Grafana and Prometheus paths set, then update core and Metrics.
    2. Open the Metrics settings page: the Grafana path is still set and there is no "Prometheus path" field.
    3. Open Grafana from the link: it opens without asking for a password and the dashboards show data.
    4. Open the old Prometheus address in the browser: it no longer works.
    5. Repeat steps 3 and 4 of test case 1: same result.

    Test case 3: services ask for a password

    1. On the leader node run curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:9091/-/healthy: it prints 401.
    2. Run the same command with port 9093: it prints 401.
  7. added
    testing
    on Dec 2, 2026
  8. removed their assignment
    on Dec 2, 2026
  9. moved this from In Progress to Testing in NethServeron Dec 2, 2026
  10. DavidePrincipi commented on Dec 2, 2026

    @DavidePrincipi
    Member

    VERIFIED

    Tested core:3.26.0-dev.6 + metrics:1.7.2-dev.2 on a fresh cluster (TC1) and on a cluster updated from core 3.25.1 + metrics 1.7.1 with both paths set (TC2).

    • No "Prometheus path" field; the Grafana path is kept after the update
    • Grafana shows data; Nodes page OK
    • The old /prometheus address returns 404 after the update; its route is removed
    • 9091 and 9093 return 401 without credentials and 200 with the ones in basic_auth.json (mode 0600, owned by metrics1)
    • Direct requests to Grafana on 127.0.0.1:3000 return 401, without a token or with a forged one
    • Alerts reach list-alerts, also with the new core and the old metrics

    Notes on the test plan:

    • Grafana still asks for the cluster-admin credentials, through the Traefik forward-auth as before. The test plan should say so instead of "opens without asking for a password".
    • runagent -m metrics1 test-alert never appears in the cluster alerts page, also on 3.25.1: cluster.alerts drops alerts without a module_id or target_type label. An alert with module_id shows up. To test step 4, the test alert needs a module_id label.

    Nit: after the update get-configuration still returns prometheus_path, left in the module/metrics1/settings Redis hash. Harmless: sending it back to configure-module is accepted and does not restore the route.

  11. added
    verified
    on Dec 2, 2026
  12. removed
    testing
    on Dec 2, 2026
  13. moved this from Testing to Verified in NethServeron Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

verified

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions