node-metrics-agent is a lightweight JVM agent from Pletor Co., Ltd. that registers host and
container node metrics as JMX MBeans.
The agent does not open an HTTP metrics endpoint by itself. You can inspect metrics through a JMX connection, and the recommended Prometheus integration is the Prometheus JMX exporter.
The agent is designed to run inside production JVMs with a fail-open posture:
- bounded asynchronous refresh pipeline; filesystem refresh runs on separate threads so a hung mount cannot stall other metrics
- overload modes:
NORMAL,DEGRADED,BYPASS - runtime configuration reload for filesystem metrics
- self-observability MBeans for queue pressure, drops, latency, staleness, and failing metric refreshes
- Prometheus JMX exporter example rules using the
pletor_*metric prefix
Current version: 0.10.0
The agent registers these MBeans:
kr.pletor.node:type=CpuMetricskr.pletor.node:type=MemMetricskr.pletor.cgroup:type=MemMetricskr.pletor.cgroup:type=PidsMetrics(process limit of the JVM's cgroup)kr.pletor.node:type=PressureMetricsandkr.pletor.cgroup:type=PressureMetrics(pressure stall information, seeRUNBOOK.md)kr.pletor.proc:type=FdMetricskr.pletor.proc:type=ProcessMetrics(resident set, threads and I/O of the JVM process)kr.pletor.proc:type=MemoryMapMetrics(memory mappings versusvm.max_map_count)kr.pletor.node:type=DiskIoMetrics(disk operations, latency and utilization counters)kr.pletor.node:type=NetworkMetrics(network errors and drops, TCP retransmits)kr.pletor.node:type=IoRateskr.pletor.node:type=OsInfoMetricskr.pletor.node:type=OsRuntimeMetricskr.pletor.node:type=FsMetrics,path=<configured path>kr.pletor.agent:type=TelemetryModekr.pletor.agent:type=Observability
Build the shaded agent JAR:
./gradlew clean shadowJarAttach it to a JVM:
java \
-javaagent:/path/to/node-metrics-agent-0.10.0-all.jar=/path/to/node-metrics.yml \
-jar your-app.jarIf no config path is provided, the agent resolves config in this order:
- agent argument path
/monitor/node-metrics.yml./config/node-metrics.yml- in-memory defaults
Supported keys:
| Key | Type | Default | Description |
|---|---|---|---|
fsmetrics_max_partitions |
integer | 32 |
Maximum unique filesystem partitions to monitor (upper limit 256; larger values are lowered to it) |
refresh_interval_seconds |
integer (1-60) | 2 |
How often CPU, memory, cgroup memory and I/O rates are refreshed in the background (file descriptors: at most every 30 s) |
fsmetrics_paths |
list | [/] |
Candidate paths for filesystem metrics |
Example:
fsmetrics_max_partitions: 32
refresh_interval_seconds: 2
fsmetrics_paths:
- /data/kafka-logs
- /bootThe JAR can also generate config files:
java -jar node-metrics-agent-0.10.0-all.jar init-config --fs-path /data,/var
java -jar node-metrics-agent-0.10.0-all.jar init-kafka-config \
--server-properties /opt/kafka/config/server.propertiesThe recommended way to scrape this agent with Prometheus is to run the Prometheus JMX exporter alongside your JVM process. For Java agent usage details, see the JMX exporter Java agent documentation.
One common launch shape is:
java \
-javaagent:/opt/jmx-exporter/jmx_prometheus_javaagent.jar=9404:/opt/jmx-exporter/pletor-node-metrics.yml \
-javaagent:/opt/pletor/node-metrics-agent-0.10.0-all.jar=/opt/pletor/node-metrics.yml \
-jar your-app.jarUse src/main/resources/jmx_exporter_rules_example.yml as the exporter config starting point and
src/main/resources/prometheus_alerts_example.yml for example alerting rules.
Exported Prometheus metric names use the pletor_* prefix, for example:
pletor_node_cpumetrics_systemcpuloadpletor_node_memmetrics_availablememorybytespletor_cgroup_memmetrics_memoryusagebytespletor_cgroup_memmetrics_memoryworkingsetbytespletor_node_iorates_diskreadbytestotal_total(cumulative counters: userate())pletor_node_cpumetrics_systemcpuiowaitticks_total(cumulative counter)pletor_node_pressuremetrics_memoryfulltotalmicros_total(cumulative counter: stalled microseconds)pletor_node_memmetrics_swapoutpagestotal_total(cumulative counter: pages swapped out)pletor_node_networkmetrics_tcpretranssegstotal_total(cumulative counter)pletor_node_diskiometrics_diskiotimemillistotal_total(cumulative counter)pletor_proc_processmetrics_residentsetbytespletor_proc_fdmetrics_openfiledescriptorcountpletor_agent_observability_queuefillratio
Requirements:
- JDK 21 for builds
- runtime target: Java 11+
Common commands:
./gradlew test
./gradlew jacocoTestReport
./gradlew checkstyleMain checkstyleTest
./gradlew spotlessCheck # spotlessApply fixes formatting
./gradlew cyclonedxBom
./gradlew trivyScantrivyScan requires the trivy binary to be installed locally. It is not required for normal
test, build, or shadowJar runs.
Licensed under the Apache License, Version 2.0. See LICENSE.