prometheus / client_golang

Prometheus instrumentation library for Go applications
https://pkg.go.dev/github.com/prometheus/client_golang
Apache License 2.0
5.39k stars 1.18k forks source link

Access the list of registered uninitialised metrics. #1636

Open arjunbakshi245 opened 2 weeks ago

arjunbakshi245 commented 2 weeks ago

I am using the gather function to get all the metrics registered. I see that uninitialised metrics that do NOT have any labels are seen on the gather() output with default values. However, uninitialised metrics with label values are not seen on the gather() output. Possibly due to prometheus not knowing what to put in place of these label values. This breaks the uniformity of gather output based on existence of labels. If labels exist I can't list out all the metrics I have(irrespective of initialisation). Not sure if I am missing a way to get all the metric names registered in a registry through some other way, but I think there must be support to populate the default values for the labeled metrics as well. These can be deleted automatically once the metric is set at least once WithLabelValues(). That way the gather can be used to see what all metrics exist. Is the same exists for unlabelled metrics, it could be helpful for labeled metrics as well.

arjunbakshi245 commented 2 weeks ago

@bwplotka ^^