siimon / prom-client

Prometheus client for node.js
Apache License 2.0
3.15k stars 378 forks source link

Initialize metrics with labels to 0 #641

Open robrichard opened 1 month ago

robrichard commented 1 month ago

In https://github.com/siimon/prom-client/pull/139 metrics without labels are initialized to 0 when created. Would it be possible to have a function that can initialize metrics with labels to 0 for a known set of label values? Something like:

const summary = new promClient.Summary({
    name: 'http_request_duration_seconds',
    labelNames: labels
});
summary.init({"response_status": "success"});
summary.init({"response_status": "error"});