---
title: "Configure golang to generate Prometheus metrics | Grafana Cloud documentation"
description: "Configure a Go application to send metrics"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Configure golang to generate Prometheus metrics

For instructions on how to instrument a Go application with Prometheus exporter, refer to [Instrumenting a Go application for Prometheus](https://prometheus.io/docs/guides/go-application/).

## Metrics and KPIs

Expand table

| Metric                                                 | KPI                                                                                                                                                                                                                                                                                |
|--------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Metric**                                             | **KPI**                                                                                                                                                                                                                                                                            |
| Memory `process_resident_memory_bytes`                 | Utilization in k8s<br /><br /><br /><br />`process_resident_memory_bytes / kube_node_status_allocatable{resource=“memory”}`<br /><br /><br /><br />Utilization in non k8s<br /><br /><br /><br />`process_resident_memory_bytes / node_memory_MemTotal_bytes`                      |
| CPU<br /><br /><br /><br />`process_cpu_seconds_total` | Utilization in k8s<br /><br /><br /><br />`rate(process_cpu_seconds_total[5m]) / kube_pod_container_resource_limits{resource=“cpu”}`<br /><br /><br /><br />Utilization in non k8s<br /><br /><br /><br />`rate(process_cpu_seconds_total[5m]) / rate(node_cpu_seconds_total[5m])` |

## Dashboard

The following Go KPI dashboard shows KPIs listed in the table, and the following Go runtime metrics.

### Memory metrics

- Heap Memory `go_memstats_heap_alloc_bytes`
- Off-Heap Memory `go_memstats_mspan_inuse_bytes`
- Stack Memory `go_memstats_stack_inuse_bytes`
- Total Memory `go_memstats_sys_bytes`

### Objects, allocation, and GC metrics

- Live Object Count `go_memstats_mallocs_total-go_memstats_frees_total`
- Object Allocation Rate `rate(go_memstats_mallocs_total`)
- Memory Allocation Rate `rate(go_memstats_alloc_bytes_total)`
- GC Duration Quantiles `go_gc_duration_seconds`

### Go routines and pointers metrics

- Number of routines `go_goroutines`
- Number of pointer dereferences `rate(go_memstats_lookups_total)`
