

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
click for more info
Not enough gems
Cost: 6 gems
1: Metrics
incomplete
2: Prometheus
incomplete
3: System Metrics
incomplete
4: Metrics Exporters
incomplete
5: What to Measure
incomplete
6: Visualizing Metrics
incomplete
7: Service Metrics
incomplete
8: Custom Metrics
incomplete
9: Custom Visualizations
incomplete
10: Status Code Bars
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Now that Prometheus and Grafana are configured and monitoring the operating system, let's configure Linko to expose application-specific metrics. Prometheus provides official Go support via github.com/prometheus/client_golang/prometheus.
Configuring a Go web app to export Prometheus metrics is straightforward. We'll use the github.com/prometheus/client_golang/prometheus/promhttp package, which provides an HTTP handler we can register on an endpoint of our choice. /metrics is the common convention.
mux.Handle("GET /metrics", promhttp.Handler())
That line registers the promhttp.Handler() to respond to GET requests on /metrics.
Update Prometheus and Grafana to monitor Linko's application metrics.
go run .
- job_name: linko
static_configs:
- targets: ["host.docker.internal:8899"]
If you're on WSL2 and the linko target stays DOWN, replace host.docker.internal with your WSL IP from hostname -I.
extra_hosts:
- "host.docker.internal:host-gateway"
docker compose up
go_gc_duration_seconds_sum{job="linko"}
Run and submit the CLI tests from the root of the Linko repo.