Skip to main content

Metrics

Metric are measurement over the time, where for each measurement the measured value, the current timestamp and optional metadata are collected. Those measurement typically are not for one specific request or task. Instead they provide statistical information about the whole system, all requests/tasks or a specific type of requests. Typical metrics are:

  • Total number of bytes read/received/sent
  • Current CPU/Memory usage
  • Average duration of something
  • Number of occurred errors

Metrics are typically stored in time series databases.

Metric types

One often distinguished the following metric types counter, gauge and histogram.

Counter

A counter measures a value which can only increase. Often just one exception to this rule is allowed: Resetting the counter to zero when the system restarts. With this exception the instrumentation must not store the counter in a place which survives restarts. Therefore, the absolute value of the counter is often not very useful and instead one often want to know how fast the counter has gone up over some defined recent time window.

For example the total number of requests can be modelled as counters. From this metric one can easily calculate the requests per time range.

Gauge

A gauge just measures a numeric value.

For example the current CPU-Usage can be modelled as gauge.

Histogram

A Histogram is a client side aggregation of values. It is well suited to collect the distribution of values, such as request latencies.