Metrics, counters and rates
Worked example
This is an offline lesson. Data are fictional and Docker commands are unexecuted. Any optional execution requires an authorized disposable VM, a verified context, synthetic data, restricted access and no external transmission. Do not collect secrets or private output. Before any authorized optional observation, verify the effective daemon endpoint including overrides, exact object ID and observation window. Bound collection time and output bytes; do not generate resource pressure or export private telemetry. Mark unavailable measurements NOT RUN.
Synthetic samples from the same container and counter lifetime:Time (s) Net received bytes Memory used MiB0 100000 3220 160000 4040 5000 35 # reported restart between samplesRate for first interval: (160000 - 100000)/20 = 3000 B/sSecond interval: reset/discontinuity, not -7750 B/sStaged command: docker stats --no-stream bm-observeCompute a counter rate from two samples with matching identity, unit and time base, then handle resets and gaps. Do not divide a cumulative network or block-I/O total by an arbitrary interval. A gauge can be compared directly to a compatible limit: 40 MiB out of 128 MiB is 31.25%. Docker CLI memory accounting on Linux adjusts raw usage for cache, so compare like with like. CPU percentages can exceed 100% across cores; a sample does not establish saturation. Engine Prometheus metrics expose daemon measurements and are not a complete per-application monitoring system. Design an authenticated, restricted collection path for separate container and application exporters; do not expose a daemon socket or metrics endpoint publicly. In Prometheus, rate() handles counter resets within a sampled series; apply rate before summing separate counter series. Use explicit units and timestamps. The sample after restart is outside the first counter lifetime, even though its heading describes the initial samples as one lifetime. The offline helper returns None for a reset or changed lifetime; it does not implement Prometheus extrapolation or recover lost traffic. The practice rate is 8000 B/s and the memory fraction is 37.5%.
Common mistake
A lower byte counter after restart is not negative network traffic. A missing sample is not zero usage.
Manual practice
Calculate the rate for 80,000 additional bytes over 10 seconds, and the memory percentage for 48 MiB of 128 MiB. Explain why the restart interval cannot be estimated by simple subtraction.
Worksheet: lab-fixtures/docker-observability/04-metrics/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Metrics, counters and rates — Knowledge check
Interpret synthetic observability evidence and choose safe diagnostic actions.
What is the first interval receive rate?
In the fictional samples, the receive counter falls after a reported restart. What should you record?
Which describes a gauge?