Skip to content

docs(ns8): add Prometheus troubleshooting - #44

Open
Stell0 wants to merge 1 commit into
NethServer:mainfrom
Stell0:docs/ns8-prometheus
Open

Stell0 wants to merge 1 commit into
NethServer:mainfrom
Stell0:docs/ns8-prometheus

Conversation

@Stell0

@Stell0 Stell0 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

A live health check can miss short spikes that ended before a support investigation started. When the NS8 Metrics module is installed, the admin skill now explains how to use its Prometheus history to compare an incident with a baseline.

The guide uses read-only commands to find the local Prometheus listener, check which metrics are available, and compare disk activity with container reads. It also explains how to avoid counting the same disk operations at multiple device layers and how to proceed when historical samples are unavailable.

How to test

  1. On an NS8 test node with Metrics installed, find the module and confirm the Prometheus listener from the container startup arguments.
  2. Run the instant queries, then use a UTC time range within the available retention for the disk and container queries. Use container and device labels from the test node.
  3. Verify that the reported units are percent and MiB/s, then compare the results with service logs from the same interval.

Generated by Codex:gpt-6.2-sol with nethserver-pr

Show how to use historical Metrics data to investigate an NS8 incident
after it ends. Include read-only examples for comparing disk activity
with container I/O and correlating the results with logs.

Assisted-by: Codex:gpt-6.2-sol
@Stell0 Stell0 self-assigned this Nov 24, 2026

@DavidePrincipi DavidePrincipi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed skill is not accurate: the promtool queries fail when a Prometheus path is configured, the disk and container queries mix series from different nodes and modules, and some steps rely on wrong assumptions about how the Metrics module runs Prometheus. See the inline comments.

Please test the skill in a real multi-node cluster before submitting it again.

its Prometheus history to compare the affected window with a baseline before
and after it. Resolve the module ID and node from `api-cli run
list-installed-modules`, then confirm the running Prometheus container in that
module's Podman context. The commands below use `metrics1` as an example.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
module's Podman context. The commands below use `metrics1` as an example.
module's Podman context. The commands below use `metrics1` as an example.
Note that a Metrics instance always run on the leader node.

Comment on lines +47 to +50
runagent -m metrics1 podman exec prometheus promtool query instant http://127.0.0.1:9091 'count by (job) (up)'
runagent -m metrics1 podman exec prometheus promtool query instant http://127.0.0.1:9091 'count by (__name__) ({__name__=~"ns8_container_.*|node_disk_.*_total"})'
runagent -m metrics1 podman exec prometheus promtool query range --start=2026-01-01T10:00:00Z --end=2026-01-01T11:00:00Z --step=60s http://127.0.0.1:9091 '100 * max(rate(node_disk_io_time_seconds_total[3m]))'
runagent -m metrics1 podman exec prometheus promtool query range --start=2026-01-01T10:00:00Z --end=2026-01-01T11:00:00Z --step=60s http://127.0.0.1:9091 'max(rate(ns8_container_blkio_bytes_total{container="mariadb",device="sda",op="read"}[3m]))/1048576'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These queries return 404 when the Metrics module has a Prometheus path configured (prometheus_path). prometheus.service hardcodes --web.external-url=/${PROMETHEUS_PATH}/ --web.listen-address=127.0.0.1:9091, so the HTTP API is always at http://127.0.0.1:9091/${PROMETHEUS_PATH}, not at the bare address. The agent would then wrongly conclude that the history is unavailable.

Suggestion: read the path with runagent -m metrics1 printenv PROMETHEUS_PATH (empty when Prometheus is not exposed through Traefik) and use http://127.0.0.1:9091/<path> as the base URL, as provision-grafana and reload-prometheus-rules do.

```bash
runagent -m metrics1 podman exec prometheus promtool query instant http://127.0.0.1:9091 'count by (job) (up)'
runagent -m metrics1 podman exec prometheus promtool query instant http://127.0.0.1:9091 'count by (__name__) ({__name__=~"ns8_container_.*|node_disk_.*_total"})'
runagent -m metrics1 podman exec prometheus promtool query range --start=2026-01-01T10:00:00Z --end=2026-01-01T11:00:00Z --step=60s http://127.0.0.1:9091 '100 * max(rate(node_disk_io_time_seconds_total[3m]))'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max(rate(node_disk_io_time_seconds_total[3m])) has no node or device filter, so it takes the peak across all cluster nodes and all block devices (sda, dm-*, loop, sr...). A busy disk on a worker would be blamed on the node where the incident happened, and with LVM the max hides which layer was busy, against the "choose one device layer" advice below.

Suggestion: filter with {node="<node>",device="<dev>"}, or use max by (node, device) so the result names the busy node and device.

runagent -m metrics1 podman exec prometheus promtool query instant http://127.0.0.1:9091 'count by (job) (up)'
runagent -m metrics1 podman exec prometheus promtool query instant http://127.0.0.1:9091 'count by (__name__) ({__name__=~"ns8_container_.*|node_disk_.*_total"})'
runagent -m metrics1 podman exec prometheus promtool query range --start=2026-01-01T10:00:00Z --end=2026-01-01T11:00:00Z --step=60s http://127.0.0.1:9091 '100 * max(rate(node_disk_io_time_seconds_total[3m]))'
runagent -m metrics1 podman exec prometheus promtool query range --start=2026-01-01T10:00:00Z --end=2026-01-01T11:00:00Z --step=60s http://127.0.0.1:9091 'max(rate(ns8_container_blkio_bytes_total{container="mariadb",device="sda",op="read"}[3m]))/1048576'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The container label is only the container name and is not unique: several modules can run a container named mariadb, possibly on different nodes. max() drops the module and node labels, so the result can come from another module without saying so.

Suggestion: also filter on module="<module_id>" (and node), or use max by (node, module), as the ns8-metrics containers dashboard does.

Comment on lines +60 to +61
diagnostics. Through Gate, submit each command separately and honor its
approval result.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Gate" is not defined anywhere in this skill or repo: it looks carried over from a specific agent setup. An agent following this sentence cannot know what Gate is or how to honor its approval result. Please remove it, or reference where it is defined.

Comment on lines +41 to +42
An empty port listing can mean the listener is available only inside the
container. Use the loopback address and port confirmed by

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prometheus.service runs Prometheus with --network=host and hardcodes --web.listen-address=127.0.0.1:9091, so podman port prometheus is always empty and the listener is always the host loopback, not "only inside the container". There is nothing to discover here: drop the podman port step (line 36) and state the fixed address directly.

```bash
runagent -m metrics1 podman ps -a
runagent -m metrics1 podman port prometheus
runagent -m metrics1 podman inspect prometheus --format '{{json .Args}}'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step is unnecessary: prometheus.service hardcodes both --web.listen-address=127.0.0.1:9091 and --web.external-url=/${PROMETHEUS_PATH}/, so the args carry nothing the agent cannot know already. Dumping them also exposes the Traefik path, which is meant to be hard to guess, and it could end up in the incident report. Suggestion: remove the podman inspect line and the "Inspect only the needed startup argument" sentence; get the path from PROMETHEUS_PATH instead (see the comment on the promtool queries).

runagent -m metrics1 podman exec prometheus promtool query range --start=2026-01-01T10:00:00Z --end=2026-01-01T11:00:00Z --step=60s http://127.0.0.1:9091 'max(rate(ns8_container_blkio_bytes_total{container="mariadb",device="sda",op="read"}[3m]))/1048576'
```

Replace the example interval with the incident timestamps in UTC, and use

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Within the available retention" is not actionable as written: the agent has no way to tell expired or missing history from "no activity". Retention is 15 days by default, and the ns8-metrics README says the module is removed from a leader that becomes a worker, so history can also end at a leader switch.

Suggestion: add a check of the oldest sample, e.g. prometheus_tsdb_lowest_timestamp_seconds, and mention both cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants