content/develop/clients/observability.md
Some Redis client libraries implement the OpenTelemetry (OTel) observability framework to let you gather performance metrics for your application. This can help you optimize performance and pinpoint problems quickly. Currently, the following clients support OTel:
Metrics are quantitative measurements of the behavior of your application. They provide information such as how often a certain operation occurs, how long it takes to complete, or how many errors have occurred. By analyzing these metrics, you can identify performance bottlenecks, errors, and other issues that need to be addressed.
Redis clients follow the OTel push model. This uses the OLTP protocol to send metrics to a collector (both OLTP/gRPC and OTLP/HTTP are supported). A storage layer (such as Prometheus) can then pull the metrics from a collector endpoint, making the data available for monitoring tools (such as Grafana) to query and visualize. The basic flow of data is shown below.
sequenceDiagram
participant App as Redis Client
participant Collector as OTel Collector
participant Storage as Storage Layer
(Prometheus)
participant Monitor as Monitoring Tool
(Grafana)
App->>Collector: Push metrics
Note over App,Collector: OTel push model
Storage->>Collector: Pull metrics from endpoint
Collector-->>Storage: Return metrics
Monitor->>Storage: Query metrics data
Storage-->>Monitor: Return metrics
Note over Monitor: Visualize
The Redis client observability demonstration on GitHub contains examples showing how to set up a local Grafana instance, then connect it to a Redis client and visualize the metric data as it arrives.
In Redis clients, the metrics collected by OTel are organized into the following metric groups:
resiliency: data related to the availability and health of the Redis connection.connection-basic: minimal metrics about Redis connections made by the client.connection-advanced: more detailed metrics about Redis connections.command: metrics about Redis commands executed by the client.client-side-caching: metrics about
[client-side caching]({{< relref "/develop/clients/client-side-caching" >}}) operations.streaming: metrics about
[stream]({{< relref "/develop/data-types/streams" >}}) operations.pubsub: metrics about
[pub/sub]({{< relref "/develop/pubsub" >}}) operations.When you configure the client to activate OTel, you can select which metric groups
you are interested in. By default, only the resiliency and connection-basic groups are enabled.
The metrics in each group are described in the
Metrics reference below.
The metric groups and the metrics they contain are described below. The name in parentheses after each group name is the group's identifier, which you use when you configure the client to select which metrics to collect.
The metrics contain attributes that provide extra information (such as the client library and server details) that you can use to filter and aggregate the data. The attributes are described in the Attributes section following the metric groups. The badge shown after the attribute name can be any of the following:
required: This attribute will always be present in the metrics.optional: This attribute may be present in the metrics.conditionally required: This attribute will be present in the metrics only if a certain condition is met,
such as when a specific error occurs. The condition is described in the attribute description.recommended: Specific client libraries may not support this attribute in some situations.{{< otel-metric-groups >}}