Repository navigation
feat(metrics): publish module metric files - #1365
Merged
Merged
Conversation
gsanchietti
marked this pull request as ready for review
October 16, 2026 12:10
gsanchietti
force-pushed
the
simple_metrics
branch
5 times, most recently
from
October 16, 2026 15:34
62ba54a to
136ab07
Compare
DavidePrincipi
approved these changes
Oct 20, 2026
DavidePrincipi
left a comment
Member
There was a problem hiding this comment.
LGTM, please just add a missing information in the docs.
Modules can publish their own Prometheus metrics with an export-metrics command, with no exporter and no open port. Every 5 minutes refresh-module-metrics.timer runs "runagent -m <id> export-metrics" for each module that ships the command, like module-dump-state for backups. The output gets a module="<id>" label and is written to node_exporter/module-<id>.prom, so Prometheus scrapes it with the node series. - A failed or timed out run (30 seconds) keeps the last output - Output that sets the module or module_id label is rejected - node_exporter skips invalid output of one module only - prometheus-client joins the agent Python environment Assisted-by: Claude Code:claude-opus-5-5
agent.SD_ERROR does not exist: the two subuid error paths raised AttributeError instead of logging the problem. Assisted-by: Claude Code:claude-opus-5-5
gsanchietti
force-pushed
the
simple_metrics
branch
from
October 20, 2026 07:23
90b0b07 to
90eb7e6
Compare
This was referenced Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Applications need to publish small metrics of their own, like the result of the last backup, without running an extra exporter and opening a port for it. Related to NethServer/dev#8093.
A module ships an
export-metricscommand that prints its metrics in the Prometheus text format. Every 5 minutes a core timer on each node runs it for every module that has it, likemodule-dump-statefor backups, and serves the output through the node exporter, which Prometheus already scrapes. No new port and no new scrape target are needed. The node adds amodule="<id>"label to every sample. It does not check the format: module metrics are reviewed with the module code, and the node exporter skips invalid output of one module without affecting the others.Changes
Added:
refresh-module-metricsnode command, with its systemd service and a timer that runs it every 5 minutes. It runsrunagent -m <id> export-metricsfor each module that ships the command and writesnode_exporter/module-<id>.prommoduleormodule_idlabel set by the module. A failed run keeps the last output and is logged. A run started while another one is in progress fails at onceprometheus-client0.26.0 in the agent Python environment, so Pythonexport-metricscommands can build valid output with the official librarydocs/modules/metrics.mdChanged:
node_exporter.servicewants the new timer;uninstall.shstops itFixed:
generate-promtail-configused the missingagent.SD_ERRORconstant, so its error paths crashed instead of loggingHow to test
runagent -m traefik1 sh -c 'printf "#!/bin/sh\necho demo_value 42\n" > ../bin/export-metrics && chmod +x ../bin/export-metrics'runagent -m node refresh-module-metrics, or wait up to 5 minutes:curl -s localhost:9100/metricsshowsdemo_value{module="traefik1"} 42exit 1): the value stays, andjournalctl -u refresh-module-metricslogs the failureSee also
moduletomodule_id, so module alert rules (feat(alerts): allow module-provided rules ns8-metrics#91) match these seriesGenerated by Claude Code:claude-opus-5-5 with nethserver-pr