Repository navigation
Conversation
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
DavidePrincipi
left a comment
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
The guide now states that Metrics runs on the cluster leader and tells the reader to run the checks there.
| 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' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
The examples now read PROMETHEUS_PATH in the Metrics module context and reuse the resulting base URL for each query. I tested both the root URL and a configured prefix with local Prometheus and promtool, using synthetic metrics for multiple nodes and modules. The real multi-node NS8 test is still pending.
| ```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]))' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
The disk query now selects the affected node and device. In the local test it returned the intended disk’s 50% busy time even with busier disks on the same node and on another node.
| 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' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
The container query now filters by node, module, container, device, and operation. The local test selected the intended container even when other modules on the same node and on another node also had a mariadb container.
| diagnostics. Through Gate, submit each command separately and honor its | ||
| approval result. |
There was a problem hiding this comment.
"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.
There was a problem hiding this comment.
Removed the Gate instruction.
| An empty port listing can mean the listener is available only inside the | ||
| container. Use the loopback address and port confirmed by |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Removed podman port and documented host networking and the fixed listener at 127.0.0.1:9091 on the leader.
| ```bash | ||
| runagent -m metrics1 podman ps -a | ||
| runagent -m metrics1 podman port prometheus | ||
| runagent -m metrics1 podman inspect prometheus --format '{{json .Args}}' |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Removed podman inspect. The guide reads only PROMETHEUS_PATH and tells the reader to omit the path and full URL from the incident report.
| 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 |
There was a problem hiding this comment.
"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.
There was a problem hiding this comment.
The guide now checks prometheus_tsdb_lowest_timestamp_seconds and explains how default retention and leader changes can limit the available history. Missing samples leave that part of the window unverified.
Use the Metrics leader and configured path for local queries. Scope disk and container results to the affected series and check how much of the incident window the server still has. Assisted-by: Codex:gpt-6.2-sol
Use the Metrics instance credentials for local history queries and keep the configured path usable on older installations. Distinguish access failures from a successful query with no samples. Assisted-by: Codex:gpt-6.2-astra
A live health check can miss short spikes that ended before a support investigation started. The NS8 admin skill now shows how to compare an incident with a baseline using the Metrics module’s Prometheus history. It covers the local authentication change in NethServer/dev#8390.
Run the read-only queries on the cluster leader in the Metrics module shell. The guide reads credentials from the module state for authenticated installations and uses the configured path on older installations. It shows how to check retention, find disk and container labels, and tell an empty result from an access failure.
How to test
http://127.0.0.1:9091/-/healthyshould return HTTP 401. Run the same guide commands with the module credentials and compare the results for the saved window.list-nodesandlist-alertssucceed.Verified on a single-node cluster upgraded from Core 3.25.1 and Metrics 1.7.1 to Core 3.26.0-dev.6 and Metrics 1.7.2-dev.2. Prometheus returned HTTP 401 anonymously and 200 with credentials. Both range queries returned all 16 samples for the same 15-minute window, with identical timestamps and values before and after the upgrade. The retention and instant queries, service checks, and both Core actions passed. A local fixture also covered a configured legacy prefix and a stale prefix with authenticated Metrics.
Generated by Codex:gpt-6.2-astra with nethserver-pr