You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Injectable}from'@nestjs/common';import{InjectMetric}from'@willsoto/nestjs-prometheus';import{Counter}from'prom-client';
@InjectableexportclassService{constructor(
@InjectMetric('metric_name')privatereadonlycounter: Counter<string>,){}publicfoo(){// NOTE: label values count must be the same as labels count in `makeCounterProvider`this.counter.labels('value1','value2').inc();}}
Scrap metrics
http http://localhost:3000/metrics
# HELP process_cpu_user_seconds_total Total user CPU time spent in seconds.# TYPE process_cpu_user_seconds_total counter
process_cpu_user_seconds_total 0.28837199999999996
# ...# ...