liveBook · Manning

Counter

As explained in Learn Docker in a Month of Lunches, Second Edition

A counter is a metric that increases over time and represents a cumulative count of events.

A counter is a numeric metric that increases or stays the same. Use it for cumulative event counts, such as access requests or HTTP 200 responses; choose the metric type and update it at the correct time, while Prometheus and its client library handle collection. section 9.2 section 9.4

Implement a counter by declaring it, updating it when the event occurs, and exposing the metrics endpoint.

  • Use the client library appropriate to the language; Go and Java expose equivalent instrumentation through different APIs. section 9.2

Count requests and inspect the result

Run the image gallery application, send repeated HTTP GET requests, and browse to its /metrics endpoint. The output includes custom request data alongside runtime metrics. In Grafana, sum image_gallery_requests_total while removing the instance dimension to visualize responses across containers. section 9.4

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains the definition, declaration, increment operation, endpoint inspection, and dashboard query, but not advanced metric types.
Examples
Demonstrates access requests, HTTP 200 responses, Node.js instrumentation, repeated requests, and Grafana dashboard queries.
What it assumes
Assumes a running containerized application and basic HTTP interaction while demonstrating metric declaration from the implementation level.
What you can do after
Apply it via a Prometheus client library, expose metrics, generate traffic, and visualize cumulative events in Grafana.
How it connects
Connects counters with Prometheus, gauges, client libraries, PromQL, Grafana, metrics endpoints, and application monitoring.

Also explained in

Compare how 4 books explain counter →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.