ApiaryActive
Try: pause · settings · learn · wipe
← Community / Reading Room
OM
knowledge · 10 min read

Observability Metrics

Monitoring and managing distributed systems is a complex endeavor, akin to observing the intricate dance of a bee colony. Just as bees communicate through…

Monitoring and managing distributed systems is a complex endeavor, akin to observing the intricate dance of a bee colony. Just as bees communicate through subtle cues to maintain the health of their hive, distributed systems rely on finely tuned metrics to ensure stability, scalability, and performance. However, when these metrics are not designed with care, they can become a source of noise, inefficiency, and operational overload. High-resolution metrics—those that capture detailed, contextual data about system behavior—are invaluable for diagnosing issues, optimizing resource usage, and predicting failures. Yet, without a structured approach to dimensionality, cardinality, and retention, they can quickly spiral into a resource drain, obscuring insights rather than clarifying them.

This article explores how to design high-resolution metrics that balance precision with practicality. By addressing the challenges of dimensionality, cardinality, and retention, we aim to provide a framework for engineers and operators to create metrics systems that scale gracefully with growing complexity. Whether you’re managing a microservices architecture, orchestrating self-governing AI agents, or building infrastructure for bee conservation, the principles outlined here will help you avoid the pitfalls of metric overload while maximizing the value of your data.

Understanding Dimensionality in Metrics

At the heart of high-resolution metrics lies dimensionality—the practice of adding contextual attributes to raw numerical data. Dimensions act as labels that provide meaning to metrics, such as service_name, region, instance_id, or user_type. For example, a metric like http_requests_total becomes far more actionable when enriched with dimensions like {service="auth", environment="production", status="200"}. These dimensions enable engineers to slice and dice data, identifying patterns or anomalies within specific subsets of a system.

However, dimensionality comes with a trade-off: each additional dimension multiplies the number of time series generated. Suppose a system has three dimensions—region (10 values), environment (3 values), and instance_type (5 values)—this results in 10 × 3 × 5 = 150 unique time series for a single metric. Multiply this across dozens of metrics, and the data volume grows exponentially. This phenomenon, known as the curse of dimensionality, can overwhelm storage systems, slow down query performance, and inflate costs.

The key to managing dimensionality lies in thoughtful selection. Engineers should ask: Which dimensions are truly necessary to answer operational questions? For example, tracking user_id as a dimension in a metric like login_attempts may be useful for identifying abuse patterns, but it introduces high cardinality (discussed in the next section). Conversely, dimensions like environment or region are often low-cardinality and essential for comparing performance across different clusters. A best practice is to limit the number of dimensions per metric, prioritizing those that provide the most actionable insights.

Cardinality: The Double-Edged Sword of Specificity

Cardinality refers to the number of unique values a dimension can take. A dimension with low cardinality, such as environment (values: production, staging, development), is manageable and useful for aggregating data. In contrast, a dimension with high cardinality, like user_id or session_id, can generate an unmanageable number of time series, leading to performance degradation.

Consider a service that tracks request_duration_seconds with dimensions for user_id. If the service has 100,000 active users, this metric would generate 100,000 time series. Even with modest aggregation intervals, this volume can strain storage engines and slow down queries. Worse, high-cardinality metrics are often redundant. For example, tracking individual user performance may be unnecessary unless troubleshooting a specific user’s experience. Instead, aggregating by user_type (e.g., paid, free) or geographic_region often provides sufficient insight while keeping cardinality low.

Modern time-series databases like Prometheus and InfluxDB have hard limits on the number of time series they can handle efficiently. Prometheus, for instance, recommends keeping the total number of time series per instance below 500,000 to avoid performance issues. To mitigate cardinality explosion, teams should:

  1. Avoid tagging high-cardinality values: Instead of logging user_id as a dimension, use it sparingly or aggregate at query time.
  2. Use summary metrics: Replace per-user tracking with aggregated metrics like average_request_duration_by_user_type.
  3. Leverage hierarchical dimensions: Group high-cardinality values into categories (e.g., user_region instead of user_id).

By proactively managing cardinality, teams can maintain the specificity of their metrics without sacrificing performance or scalability.

Retention Strategies: Balancing Depth and Cost

Retention—the duration for which metrics are stored—is a critical factor in designing sustainable metrics systems. High-resolution metrics often capture transient events like request latencies or error rates, but retaining them indefinitely is neither feasible nor necessary. A tiered retention strategy ensures that data is available for immediate troubleshooting while minimizing long-term costs.

Most organizations adopt a cold-hot storage model. For example:

  • Hot storage (days to weeks): High-resolution metrics are kept in fast, in-memory databases for real-time analysis and alerting.
  • Warm storage (months): Data is compressed and archived to disk-based systems like object storage or columnar databases for historical analysis.
  • Cold storage (years): Rarely accessed metrics are moved to low-cost, durable storage for compliance or long-term trend analysis.

Tools like VictoriaMetrics and Thanos support automated tiered storage, allowing teams to define retention policies based on metric type. For instance, error_rate might be retained for 30 days in hot storage, while user_activity_count (aggregated daily) is archived for a year.

Retention decisions should align with business needs. Metrics critical to service-level objectives (SLOs) may require longer retention periods for root-cause analysis during incidents. Conversely, low-impact metrics like cache_hits can be discarded after a few days if they’re only used for short-term performance tuning. By aligning retention with value, teams avoid the trap of storing all data indiscriminately, which can lead to ballooning costs and complexity.

Balancing Precision and Overhead

High-resolution metrics offer unparalleled precision, but they come at a cost: increased computational overhead. Every additional dimension, time series, and retention period consumes CPU, memory, and disk resources. Engineers must strike a balance between granularity and system efficiency.

One approach is adaptive sampling, where metrics are collected at high resolution during peak times or critical events and at lower resolution during idle periods. For example, a service might sample logs at 100% during a DDoS attack (to capture every anomaly) but switch to 10% sampling during normal operations to conserve resources.

Another technique is aggregation before storage. Instead of storing raw, high-cardinality data, systems can pre-aggregate metrics into summaries like averages, medians, or percentiles. For instance, instead of tracking request_duration_seconds for each user, a system might store average_request_duration per hour. This reduces the volume of data while retaining the ability to analyze trends.

However, aggregation can also lead to information loss. Teams should evaluate whether the trade-off is acceptable. For example, aggregating request_duration_seconds into hourly averages hides outliers and transient spikes, which might be critical for diagnosing performance issues. In such cases, a hybrid approach—storing raw data at short intervals (e.g., 1 minute) and aggregated data for longer intervals (e.g., 1 hour)—can provide the best of both worlds.

Instrumentation Best Practices for Scalability

Effective metrics design begins at the instrumentation layer—the code that collects and emits data. Poor instrumentation practices can introduce noise, redundant metrics, or performance bottlenecks. To avoid these issues, teams should follow these best practices:

  1. Tag with intention: Use dimensions to answer specific questions. For example, tag service_name and operation_type to compare performance across different components, but avoid tagging low-value fields like request_id.
  2. Avoid over-tagging: Each additional tag increases cardinality. Instead of tagging user_id, session_id, and request_id, consider adding these to logs for deep-dive investigations.
  3. Use metrics libraries wisely: Tools like OpenTelemetry or Prometheus clients provide built-in safeguards against common pitfalls, such as automatically limiting the number of time series or offering histogram-based aggregation.
  4. Filter early: Apply filters at the ingestion layer to discard metrics that don’t meet retention or relevance criteria. For example, drop metrics from non-critical services or those with negligible impact on business KPIs.

A real-world example of this is how the Kubernetes ecosystem handles metrics. By default, the kube-state-metrics component exposes metrics with minimal dimensions (e.g., pod_name, namespace), avoiding the cardinality explosion that would occur if it included every pod’s container or volume ID. This approach ensures scalability while still providing enough context for troubleshooting.

Real-World Case Studies: Lessons from the Field

Several prominent incidents in the tech industry highlight the consequences of poor metrics design. One notable example is the 2019 outage at GitHub, where high-cardinality metrics overwhelmed their monitoring systems. GitHub’s team discovered that a misconfigured metric—a tag tracking every unique API endpoint—generated an enormous number of time series, slowing down their alerting systems and delaying resolution. The fix involved aggregating endpoints into categories (e.g., auth, repo, user) and reducing the granularity of less critical endpoints.

Another case comes from Netflix, which faced similar challenges during the early days of their microservices architecture. The sheer number of services and their interactions led to an explosion in metrics, making it difficult to identify the source of performance bottlenecks. Netflix addressed this by implementing metric aggregation at the service boundary. Instead of tracking every individual request, they aggregated metrics by service and endpoint, reducing cardinality while retaining enough detail to monitor service-level performance.

These case studies underscore the importance of proactive metrics design. By learning from real-world failures, teams can avoid repeating costly mistakes and build systems that scale gracefully with complexity.

Tools and Technologies: Enabling High-Resolution Metrics

A robust metrics system relies on tools that support scalability, flexibility, and efficiency. Below are some widely adopted platforms and their features:

  • Prometheus: A time-series database optimized for low-cardinality metrics. Its PromQL query language allows for efficient filtering and aggregation, but it struggles with high-cardinality data due to memory constraints.
  • VictoriaMetrics: A high-performance, cost-effective alternative to Prometheus, designed to handle large volumes of metrics with minimal resource usage.
  • InfluxDB: A time-series database that supports flexible schema and tiered retention policies, making it ideal for long-term storage.
  • Datadog: A commercial platform that automates cardinality management and offers pre-built dashboards for common use cases.
  • OpenTelemetry: An open-source observability framework that standardizes metrics collection, enabling seamless integration with tools like Prometheus and Datadog.

When choosing a tool, teams should consider factors like cardinality limits, storage costs, and ease of integration. For example, Prometheus is excellent for small to medium systems but may require sharding for larger deployments. Conversely, managed services like Datadog or Amazon CloudWatch offer scalability at the cost of vendor lock-in.

Bridging to Self-Governing AI Agents

The principles of high-resolution metrics design are not confined to traditional distributed systems—they also apply to self-governing AI agents. Just as a bee colony relies on real-time environmental cues to adapt to changing conditions, AI agents need precise, contextual data to make autonomous decisions.

Consider an AI agent tasked with optimizing energy usage in a smart hive. By collecting metrics like temperature, humidity, and nectar flow rate, the agent can adjust ventilation or foraging strategies. However, if these metrics are high-cardinality (e.g., tracking each bee’s behavior individually), the agent may become overwhelmed, leading to delayed or incorrect decisions. Instead, aggregating metrics at the hive level—such as average temperature or total nectar influx—provides sufficient context for the agent to act effectively.

Similarly, in self-governing AI systems, metrics must be designed to reflect the agent’s goals. For example, an autonomous vehicle agent might track speed, distance_to_obstacle, and traffic_density, but not individual sensor readings from every component. The right balance between detail and simplicity ensures the agent can operate efficiently without overloading its decision-making processes.

Future Trends: AI-Driven Metrics and Edge Computing

As distributed systems become more complex, the role of metrics will evolve alongside emerging technologies. One promising trend is the use of AI-driven metrics analysis. Machine learning models can automatically detect anomalies, predict failures, and optimize metrics collection in real time. For instance, an AI model might identify that certain dimensions (e.g., user_id) are rarely queried and suggest reducing their cardinality.

Another development is the rise of edge computing, where data is processed closer to the source. In an edge-based metrics system, raw data is aggregated or filtered before being sent to centralized storage, reducing bandwidth and latency. This is particularly valuable in environments like IoT networks or remote bee monitoring stations, where connectivity is limited.

Finally, the integration of observability platforms—which combine metrics, logs, and traces—will become more seamless. These platforms enable engineers to correlate high-resolution metrics with contextual logs and distributed traces, offering a holistic view of system health.

Why It Matters

Designing high-resolution metrics is not merely a technical exercise—it’s a strategic decision that impacts the reliability, cost, and scalability of any system. Whether you’re managing a fleet of microservices, deploying self-governing AI agents, or monitoring the health of bee colonies, the principles of dimensionality, cardinality, and retention remain universal. By carefully balancing precision with practicality, teams can avoid the pitfalls of metric overload while unlocking the full potential of their data.

In the world of bee conservation, just as in distributed systems, the right balance between detail and simplicity ensures resilience and adaptability. As systems grow more complex, the lessons learned from managing metrics will continue to shape the future of scalable, intelligent architectures.

Frequently asked
What is Observability Metrics about?
Monitoring and managing distributed systems is a complex endeavor, akin to observing the intricate dance of a bee colony. Just as bees communicate through…
What should you know about understanding Dimensionality in Metrics?
At the heart of high-resolution metrics lies dimensionality —the practice of adding contextual attributes to raw numerical data. Dimensions act as labels that provide meaning to metrics, such as service_name , region , instance_id , or user_type . For example, a metric like http_requests_total becomes far more…
What should you know about cardinality: The Double-Edged Sword of Specificity?
Cardinality refers to the number of unique values a dimension can take. A dimension with low cardinality, such as environment (values: production , staging , development ), is manageable and useful for aggregating data. In contrast, a dimension with high cardinality, like user_id or session_id , can generate an…
What should you know about retention Strategies: Balancing Depth and Cost?
Retention—the duration for which metrics are stored—is a critical factor in designing sustainable metrics systems. High-resolution metrics often capture transient events like request latencies or error rates, but retaining them indefinitely is neither feasible nor necessary. A tiered retention strategy ensures that…
What should you know about balancing Precision and Overhead?
High-resolution metrics offer unparalleled precision, but they come at a cost: increased computational overhead. Every additional dimension, time series, and retention period consumes CPU, memory, and disk resources. Engineers must strike a balance between granularity and system efficiency.
References & sources
  1. Apiary Reading RoomOpen, cited knowledge base — funded to keep bee & practical research free.
From the Apiary Reading Room. Opinion & editorial — not financial advice. We don't overclaim.
More from the Reading Room