We monitor Jenkins with Prometheus and scrape the metrics produced by the metrics-plugin with the jmx-exporter (https://github.com/prometheus/jmx_exporter).
Furthermore, our slaves are ephemeral resulting in different slaves for different builds.
Exposed as mBeans and visible via JMX, we see metrics for our slaves denoted by e.g.
To make maximal use of this metric, Prometheus needs it so scrape in a form like
Such a rewriting can be done with help of rules in the configuration of the JMX-Exporter: https://github.com/prometheus/jmx_exporter#configuration
To generate rules, we need to apply a regex on the mBean. The prefix "node" would fit perfectly to file for. Unfortunately, the same prefix is used for the following, global node staticstic:
This prohibits a filtering on node-specifics metrics.
The affected Lines are marked over https://github.com/jenkinsci/metrics-plugin/blob/d94a4547b11263c094b2f713b37f7f0610882878/src/main/java/jenkins/metrics/impl/JenkinsMetricProviderImpl.java#L305,L319