Instrumenting services using counter

There are many usages of the counter metric. We can measure the number of requests entering the system, the number of bytes sent through the network, the number of errors, and so on. Whenever we want to record an incremental value, a counter is a good choice.

We'll use counter to track errors produced by a service. With such a goal, a counter is usually put around code that handles errors.

The examples that follow are taken from Docker Flow Swarm Listener ( The code is written in Go. Do not be afraid if that is not your language of choice. As you will see, examples are straightforward and can be easily extrapolated to any programming language.

Prometheus provides ...

Get The DevOps 2.2 Toolkit now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.