The most popular tools for monitoring Go applications are Prometheus for metrics, Grafana for dashboards and OpenTelemetry for traces, while logging is best done with the standard library's log/slog package, or with Zap or Zerolog when you need maximum throughput. In production you normally combine one tool from each group: metrics, logs and traces.
Since Go 1.21, structured logging is part of the standard library, so Logrus (now in maintenance mode) is no longer the default choice for new projects.
Before picking tools, separate the three signals that observability tools deal with:
| Signal | Question it answers | Typical Go tools |
|---|---|---|
| Metrics | Is the service healthy, and how fast is it? | Prometheus client, OpenTelemetry metrics, Grafana |
| Logs | What exactly happened in this request? | log/slog, Zap, Zerolog, Loki, the ELK stack |
| Traces | Where did the time go across services? | OpenTelemetry, Jaeger, Grafana Tempo |
| Profiles | Which functions use CPU or memory? | net/http/pprof, runtime/trace, Pyroscope |
Prometheus scrapes an HTTP endpoint (usually /metrics) on a schedule and stores the values as time series. You query them with PromQL and alert on them with Alertmanager. Grafana reads from Prometheus and draws dashboards.
The official client is github.com/prometheus/client_golang. Use promauto so metrics register themselves, and add labels sparingly, because every unique label combination creates a new time series.
The middleware records a counter and a latency histogram for every request. The Go client also exposes runtime metrics such as goroutine count, GC pauses and memory by default. In Grafana, add Prometheus as a data source and chart queries such as rate(http_requests_total[5m]).
OpenTelemetry (OTel) is the CNCF standard for traces, metrics and logs. The Go SDK lets you instrument once and export to many back ends: Jaeger, Grafana Tempo, Datadog, New Relic, Honeycomb and others. Libraries such as otelhttp wrap net/http handlers and clients so trace context propagates across services automatically.
Choose OpenTelemetry when requests cross several services, or when you do not want to be locked to one vendor. For a single service, Prometheus metrics alone are often enough.
Structured logs (key-value pairs, usually JSON) are searchable by machines. The common options are:
| Library | Notes |
|---|---|
log/slog | Standard library since Go 1.21. Good default, pluggable handlers, no dependency. |
| Zap (Uber) | Very fast, low allocation, strongly typed fields. |
| Zerolog | Zero-allocation JSON logger with a fluent API. |
| Logrus | Popular and widely used, but in maintenance mode. Avoid it for new code. |
A slog example:
If benchmarks show logging is a hot path, you can keep the slog API and plug in a faster back end, because slog.Handler is an interface. Zap and Zerolog both provide handlers for it.
Write logs to standard output as JSON and let the platform collect them. Common aggregation stacks:
Include a request or trace ID in every log line so you can jump from a trace to the matching logs.
Go ships profiling tools in the standard library. Importing net/http/pprof on an internal-only port exposes CPU, heap, goroutine and block profiles that you inspect with go tool pprof. For latency problems, runtime/trace shows scheduler and GC behaviour. Continuous profilers such as Pyroscope or Grafana Cloud Profiles keep this data over time. Never expose pprof endpoints on a public interface.
Start with log/slog. It is in the standard library, structured and good enough for most services. Move to Zap or Zerolog only if profiling shows logging overhead matters.
For metrics and alerting, yes. Add OpenTelemetry tracing when you need to follow requests across several services.
It is in maintenance mode: it receives security and bug fixes but no new features. The Logrus authors recommend newer libraries for new projects.
Never use unbounded values such as user IDs, full URLs or error strings as label values. Use route patterns and status codes instead.
Use Prometheus and Grafana for metrics, OpenTelemetry for traces, log/slog (or Zap and Zerolog for extreme throughput) for structured logs, and Loki or Elastic to store and search them. Add pprof for profiling, keep metric labels low-cardinality, and correlate logs and traces with a shared request ID.