Documentation Index
Fetch the complete documentation index at: https://docs.localops.co/llms.txt
Use this file to discover all available pages before exploring further.
A complete walkthrough of instrumenting a Go service using the official
client_golang library.
See the overview for the general approach.
1. Add the dependency
go get github.com/prometheus/client_golang/prometheus
go get github.com/prometheus/client_golang/prometheus/promauto
go get github.com/prometheus/client_golang/prometheus/promhttp
2. Register custom metrics and expose /metrics
The default registry automatically exports Go runtime metrics (go_* — goroutines, GC pauses, heap, etc.) and process
metrics (process_* — CPU, memory, open FDs).
package main
import (
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var emailsSent = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "emails_sent_total",
Help: "Total number of emails sent",
},
[]string{"status"},
)
func main() {
emailsSent.WithLabelValues("success").Inc()
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":9090", nil)
}
If your service already serves HTTP on another port, you can mount promhttp.Handler() on your existing mux at
/metrics instead of starting a separate listener. Just point ops.json’s port at your main app port.
3. Declare the metrics endpoint in ops.json
{
"metrics": {
"endpoint": "/metrics",
"interval": 15,
"port": 9090
}
}
| Dashboard | ID | Notes |
|---|
| Go Runtime Metrics | 14061 | Built by Grafana Labs specifically for the Prometheus Go Client Library — recommended starting point. |
| Go Processes | 6671 | Long-running community dashboard. Memory used, file descriptors, GC details, per-process status. |
| Go Metrics | 10826 | Kubernetes-oriented Go runtime dashboard, useful if you deploy via Helm. |
To import: in Grafana, go to Dashboards → New → Import, enter the dashboard ID, and select your LocalOps Prometheus
data source. You’ll instantly see goroutine counts, GC pause times, heap allocations, and CPU usage. Your custom
application metrics (emails_sent_total, etc.) can be charted alongside.