liveBook · Manning

Cardinality

As explained in Logs and Telemetry

Cardinality is the number of distinct label-value combinations or dimensions represented in a telemetry data set.

Cardinality is the number of distinct label-value combinations, or dimensions, represented in a telemetry data set. In Prometheus metrics, every added label can create additional series and collected values. section 5.6.1 section 7.5.2

Treat cardinality as an operational design choice. Stable labels such as server name, type, ID, exporter, or service group support querying, fault diagnosis, and event correlation, while uncontrolled values can significantly affect exporter behavior. section 5.6.1 section 7.5.2

Evaluate cardinality by checking:

  • How many possible values each metric dimension can take. section 7.5.2
  • Whether a label adds useful diagnostic or correlation value. section 5.6.1
  • Whether each dimension creates additional values that Fluent Bit must collect and calculate. section 7.5.2
Listing 5.6 Prometheus exporter: prometheus-exporter-output.conf
[SERVICE]
  flush 5
  log_level info

[INPUT]
  name node_exporter_metrics   #1
  tag node_metrics
  scrape_interval 5            #2

[OUTPUT]
  name  prometheus_exporter     #3
  match *
  port  9885           #4
  host  0.0.0.0
  add_label  fluentbit exporter  #5

A Prometheus exporter configuration adds the constant fluentbit="exporter" label; generated metrics then combine it with dimensions such as CPU mode, CPU number, and disk device. section 5.6.1

Dimensioning metrics from logs

A log-to-metrics configuration uses label_field greeting, producing separate counter values for bonjour, goodbye, and hello. A second counter omits that dimension and reports one total for all messages. The comparison makes the cardinality trade-off visible. section 7.5.2

How Logs and Telemetry covers it

How deep it goes
Defines dimensions and demonstrates their output, while warning about operational effects without exploring cardinality management in depth.
Examples
Uses CPU, disk, server, exporter, service-group, and greeting labels to contrast dimensioned metrics with aggregate totals.
What you can do after
Evaluate metric labels by comparing diagnostic value with the additional values collected and calculated for each dimension.
How it connects
Connects labels and dimensions with Prometheus metrics, Fluent Bit exporters, log transformation, fault diagnosis, and event correlation.

Also explained in

Compare how 8 books explain cardinality →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Logs and Telemetry. The section links point to the parts of the book it draws on.