prometheus / prometheus/client_js

Initialize metrics with labels to 0

Open
#641 1 comment 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting on author
Dominant language
JavaScript
Stars
3.5k
Forks
429
Avg merge
3d 3h
Merged PRs (30d)
22

Description

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"});

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Summary metric implementation and pull request 139, which established initialization for metrics without labels. Trace how label values are currently created, then define the expected behavior for init({"response_status":"success"}) and init({"response_status":"error"}) and add coverage showing those labeled series start at 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
observability-sre
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.