Skip to content
Snippets Groups Projects
Unverified Commit fc30c192 authored by anarcat's avatar anarcat
Browse files

expand on the metrics howto

parent 36772f76
No related branches found
No related tags found
No related merge requests found
......@@ -33,9 +33,35 @@ dashboards for most purposes other than debugging.
If you want your service to be monitored by Prometheus, you need to
[write](https://prometheus.io/docs/instrumenting/writing_exporters/) or [reuse an existing exporter](https://prometheus.io/docs/instrumenting/exporters/). [Writing an
exporter](https://prometheus.io/docs/instrumenting/writing_exporters/) is more involved, but still fairly easy and might be
exporter][] is more involved, but still fairly easy and might be
necessary if you are the maintainer of an application not already
instrumented for Prometheus.
instrumented for Prometheus.
[Writing an exporter]: https://prometheus.io/docs/instrumenting/writing_exporters/
The [actual documentation][Writing an exporter] is fairly good, but basically: a
Prometheus exporter is a simple HTTP server which responds to a
specific URL (`/metrics`, by convention, but it can be anything) and
responds with a key/value list of entries, one on each line. Each
"key" is a simple string with an arbitrary list of "labels" enclosed
in curly braces. For example, here's how the "node exporter" exports
CPU usage:
# HELP node_cpu_seconds_total Seconds the cpus spent in each mode.
# TYPE node_cpu_seconds_total counter
node_cpu_seconds_total{cpu="0",mode="idle"} 948736.11
node_cpu_seconds_total{cpu="0",mode="iowait"} 1659.94
node_cpu_seconds_total{cpu="0",mode="irq"} 0
node_cpu_seconds_total{cpu="0",mode="nice"} 516.23
node_cpu_seconds_total{cpu="0",mode="softirq"} 16491.47
node_cpu_seconds_total{cpu="0",mode="steal"} 0
node_cpu_seconds_total{cpu="0",mode="system"} 35893.84
node_cpu_seconds_total{cpu="0",mode="user"} 67711.74
Obviously, you don't necessarily have to write all that logic
yourself, however: there are [client libraries](https://prometheus.io/docs/instrumenting/clientlibs/) (see the [Golang
guide](https://prometheus.io/docs/guides/go-application/), [Python demo](https://github.com/prometheus/client_python#three-step-demo) or [C documentation](https://digitalocean.github.io/prometheus-client-c/) for examples) that
do most of the job for you.
Once you have an exporter endpoint (say at
`http://example.com:9090/metrics`), make sure it works:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment