Report Garbage Collection stats using Prometheus
This module has a peer dependency on
prom-client. Currently, 10 is supported.
This module follows the same API as the core default metrics. To start collection GC stats, invoke the exported function to create the metrics, then invoke the returned function to start the collecting.
The exported function takes a single parameter, which is a registry. If provided, and the version of prom-client you use support it, that is
the registry which the metrics will register to. If no registry is provided it will use the default one provided by
const prometheus = ;const gcStats = ;prometheus;const startGcStats = ; // gcStats() would have the same effect in this case;
The module doing the GC stats collecting is
gc-stats. This module requires native dependencies.
If the stats don't show up, make sure to check
npm's install log for failures.
This module exposes 3 metrics:
nodejs_gc_runs_total: Counts the number of time GC is invoked
nodejs_gc_pause_seconds_total: Time spent in GC in seconds
nodejs_gc_reclaimed_bytes_total: The number of bytes GC has freed
You can add a prefix to metric names using options:
const startGcStats =;
Thanks to @tcolgate for the original implementation.