cardinality: The number of unique label combinations a metric has. High cardinality (e.g. user_id as a label) blows up storage and cost. Cardinality in monitoring is the number of unique combinations of label values a metric has. A metric http_requests with labels for method and status code has a few dozen combinations. Add user_id as a label and it can have millions.
Every combination is stored as a separate time series. High cardinality makes monitoring systems like Prometheus slow and expensive, and can crash them outright.
What should you keep in mind with cardinality?
Keep labels to values with a small, fixed set of options: endpoint name, status class, region. Put unique identifiers such as user IDs, order numbers or full URLs in logs or traces instead, where they belong. A useful rule is to ask whether you would ever draw a separate line on a graph for each value. If not, it should not be a label.
What does an example of cardinality look like?
http_requests{user_id="..."} → millions of series = bad
Full Sentry SDK setup for PHP. Use when asked to "add Sentry to PHP", "install sentry/sentry", "setup Sentry in PHP", or configure error monitoring, tracing, profiling, logging, metrics, crons, or AI monitoring for PHP applications. Supports plain PHP, Laravel, and Symfony.
Set up Prometheus for comprehensive metric collection, storage, and monitoring of infrastructure and applications. Use when implementing metrics collection, setting up monitoring infrastructure, or configuring alerting systems.
Define and implement Service Level Indicators (SLIs) and Service Level Objectives (SLOs) with error budgets and alerting. Use when establishing reliability targets, implementing SRE practices, or measuring service performance.