prometheus / prometheus/client_js

Gauge without label should not have a default value of 0 (zero)

Open
#622 5 comments 0 reactions 1 assignee View on GitHub

@jdmarshall is already working on this.

Since Aug 21, 2026.

semver-major
Dominant language
JavaScript
Stars
3.5k
Forks
429
Avg merge
3d 3h
Merged PRs (30d)
22

Description

A gauge that is registered but does not have a value set is currently set to 0 (zero). I believe this behavior to be incorrect because a gauge without a label does not work like it.

const client = require('prom-client');
const gauge = new client.Gauge({ name: 'metric_name', help: 'metric_help', labelNames: ['example'] });
const gauge2 = new client.Gauge({ name: 'metric_name2', help: 'metric_help2' });

console.log(await client.register.metrics())

gauge.set({ example: 'true' }, 1)

console.log(await client.register.metrics())

gauge.reset();

console.log(await client.register.metrics())

Output 1 after initialization:

# HELP metric_name metric_help
# TYPE metric_name gauge

# HELP metric_name2 metric_help2
# TYPE metric_name2 gauge
metric_name2 0

Output 2 after setting gauge:

# HELP metric_name metric_help
# TYPE metric_name gauge
metric_name{example="true"} 1

# HELP metric_name2 metric_help2
# TYPE metric_name2 gauge
metric_name2 0

Output 3 after reset:

# HELP metric_name metric_help
# TYPE metric_name gauge

# HELP metric_name2 metric_help2
# TYPE metric_name2 gauge
metric_name2 0

I would expect the output 1 of both gauges to be the same and instead of a default of 0 having a default of undefined.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.