I am using:
var registry = prometheus.NewRegistry() I know I can do for some goroutine (etc.) related metrics:
registry.MustRegistry(collectors.NewGoCollector()); But, I cannot see http metrics which I see when using default registry, like:
promhttp_metric_handler_requests_total{code="200"} 1 promhttp_metric_handler_requests_total{code="500"} 0 promhttp_metric_handler_requests_total{code="503"} 0 How to bring these metrics?
Also, I cannot see http_requests_total irrespective of the registry I use. Is there a way to automatically expose it (instead of defining it)?
1 Answer
You also need to register your custom defined metric like http_requests_total (in this case).
This should solve your problem :
`registry.MustRegistry(promHttpRequestTotal)
Here promHttpRequestTotal is the variable in which your metric http_requests_total is defined.