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. |
| 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.
| ```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.
| 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.
| 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.
| 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.
| ```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).
| 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.
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
Generated by Codex:gpt-6.2-sol with nethserver-pr