How to add labels to Go runtime prometheus metrics?

207 views
Skip to first unread message

cpu...@gmail.com

unread,
Mar 6, 2024, 5:40:29 AM3/6/24
to golang-nuts
The Go runtime exposes various metrics. To collect metrics from multiple servers I'd like to add labels for server name. Is it possible to extend the build-in metrics for this purpose?

Thanks,
Andi

Brian Candler

unread,
Mar 6, 2024, 7:38:12 AM3/6/24
to golang-nuts
The server name will be added by Prometheus itself as an "instance" label for each target being scraped (or you can manually set the instance label for each target), so in general what you're asking is not necessary.  None of the standard Prometheus exporters include a label for the hostname (e.g. node_exporter, windows_exporter etc).

If there's something special about your situation which means you need to do this, can you explain your use case further?

cpu...@gmail.com

unread,
Mar 6, 2024, 2:29:23 PM3/6/24
to golang-nuts
Situation here may be a bit specific. Running 2 cloud machines behind reverse proxy. I realise this is per chance if the proxy will hit any of the two, but that would be good enough id I could distinguish their metrics.
Reply all
Reply to author
Forward
0 new messages