Prometheus – Quick start for a newbie!

In the world of oberservability, the winner seems, by-a-mile, to be Prometheus.

The purpose of this series is to explore how Prometheus works, its different type of metrics, etc.

1) Quickstart 2) Adding basic metrics to our sample Go application 3) Adding custom metrics to our sample Go application

Quickstart

On my Ubuntu box I simply followed the quickstart guide

curl --location -Ok https://github.com/prometheus/prometheus/releases/download/v3.2.0/prometheus-3.2.0.linux-amd64.tar.gz
./promtheus

The quickstart guide says we can see a list Prometheus’s own metrics (Promception!) by visiting the /metrics URL:

alan@APZ-OMEN:/mnt/c/Users/alan$ curl -s http://172.22.202.216:9090/metrics | more
# HELP go_gc_cycles_automatic_gc_cycles_total Count of completed GC cycles generated by the Go runtime. Sourced from /gc/cycles/automatic:gc-cycles.
# TYPE go_gc_cycles_automatic_gc_cycles_total counter
go_gc_cycles_automatic_gc_cycles_total 10
# HELP go_gc_cycles_forced_gc_cycles_total Count of completed GC cycles forced by the application. Sourced from /gc/cycles/forced:gc-cycles.
# TYPE go_gc_cycles_forced_gc_cycles_total counter
go_gc_cycles_forced_gc_cycles_total 0
# HELP go_gc_cycles_total_gc_cycles_total Count of all completed GC cycles. Sourced from /gc/cycles/total:gc-cycles.
# TYPE go_gc_cycles_total_gc_cycles_total counter
go_gc_cycles_total_gc_cycles_total 10
# HELP go_gc_duration_seconds A summary of the wall-time pause (stop-the-world) duration in garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 3.3353e-05
go_gc_duration_seconds{quantile="0.25"} 4.5974e-05
go_gc_duration_seconds{quantile="0.5"} 0.000163919
go_gc_duration_seconds{quantile="0.75"} 0.000247898
go_gc_duration_seconds{quantile="1"} 0.000265798
go_gc_duration_seconds_sum 0.00141824
go_gc_duration_seconds_count 10

The quickstart goes on to say we can query the history of a metric by pasting it into the query box and running execute -> we tried go_gc_cycles_forced_gc_cycles_total and it seems to work !

One thing we see: the results are annotated with “instance” and “job” labels – this answers our question about how Prometheus handles multiple applications exposing the same metric.