Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add redis metrics semantic conventions #2547

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ release.
([#2273](https://github.com/open-telemetry/opentelemetry-specification/pull/2273)).
- Specify optional support for an Exponential Histogram Aggregation.
([#2252](https://github.com/open-telemetry/opentelemetry-specification/pull/2252))
- Add Redis metrics semantic conventions
([#2547](https://github.com/open-telemetry/opentelemetry-specification/pull/2547)).

### Logs

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Instrumenting Redis

**Status**: [Experimental](../../../document-status.md)

This document defines how to apply semantic conventions when instrumenting Redis.

<!-- toc -->

- [Redis Metrics](#redis-metrics)

<!-- tocstop -->

## Redis Metrics

**Description:** General Redis metrics.

| Name | Instrument | Value type | Unit | Unit ([UCUM](../README.md#instrument-units)) | Description | Attribute Key | Attribute Values |
| ---------------------------------------------- | ------------- | ---------- | ------------ | -------------------------------------------- | --------------------------------------------------------------------- | ------------- | ---------------- |
| db.redis.uptime | Counter | Int64 | seconds | `{s}` | Number of seconds since Redis server start | | |
| db.redis.cpu.time | Counter | Double | seconds | `{s}` | System CPU consumed by the Redis server in seconds since server start | `state` | |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why having another metric for "cpu.time" rather than "process.cpu.time" with a "db.system" attribute on the resource?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bogdandrutu is there a guideline around when to add a new metric vs when to add a label to an existing metric? Just want to get some clarity on what other metrics we should be considering this with.

For example the connections received/rejected, uptime and all memory metrics feel like they may fall into this category as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go this path anytime is possible :) Maybe we need some documentation about this?

| db.redis.clients.connected | UpDownCounter | Int64 | clients | `{clients}` | Number of client connections (excluding connections from replicas) | | |
| db.redis.clients.max_input_buffer | Gauge | Int64 | | | Biggest input buffer among current client connections | | |
| db.redis.clients.max_output_buffer | Gauge | Int64 | | | Longest output list among current client connections | | |
| db.redis.clients.blocked | UpDownCounter | Int64 | clients | `{clients}` | Number of clients pending on a blocking call | | |
| db.redis.keys.expired | Counter | Int64 | keys | `{keys}` | Total number of key expiration events | | |
| db.redis.keys.evicted | Counter | Int64 | keys | `{keys}` | Number of evicted keys due to maxmemory limit | | |
| db.redis.connections.received | Counter | Int64 | connections | `{connections}` | Total number of connections accepted by the server | | |
| db.redis.connections.rejected | Counter | Int64 | connections | `{connections}` | Number of connections rejected because of maxclients limit | | |
| db.redis.memory.used | Gauge | Int64 | bytes | `{by}` | Total number of bytes allocated by Redis using its allocator | | |
codeboten marked this conversation as resolved.
Show resolved Hide resolved
| db.redis.memory.peak | Gauge | Int64 | bytes | `{by}` | Peak memory consumed by Redis | | |
codeboten marked this conversation as resolved.
Show resolved Hide resolved
| db.redis.memory.rss | Gauge | Int64 | bytes | `{by}` | Number of bytes that Redis allocated as seen by the operating system | | |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be a more generic metric ie. process.memory.rss

| db.redis.memory.lua | Gauge | Int64 | bytes | `{by}` | Number of bytes used by the Lua engine | | |
| db.redis.memory.fragmentation_ratio | Gauge | Double | | | Ratio between used_memory_rss and used_memory | | |
| db.redis.rdb.changes_since_last_save | UpDownCounter | Int64 | changes | `{changes}` | Number of changes since the last dump | | |
| db.redis.commands | Gauge | Int64 | operations | `{ops}/s` | Number of commands processed per second | | |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to have this when we have the db.redis.commands.processed as counter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the rate could be calculated from the db.redis.commands.processed counter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then why not removing it?

| db.redis.commands.processed | Counter | Int64 | operations | `{ops}` | Total number of commands processed by the server | | |
| db.redis.net.input | Counter | Int64 | bytes | `{by}` | The total number of bytes read from the network | | |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

net input/output could be generalized as process metrics.

| db.redis.net.output | Counter | Int64 | bytes | `{by}` | The total number of bytes written to the network | | |
| db.redis.keyspace.hits | Counter | Int64 | operations | `{ops}` | The total number of successful lookup of keys in the main dictionary | | |
| db.redis.keyspace.misses | Counter | Int64 | operations | `{ops}` | The total number of failed lookup of keys in the main dictionary | | |
| db.redis.latest_fork | Gauge | Int64 | microseconds | `{us}` | Duration of the latest fork operation | | |
| db.redis.replicas.connected | Gauge | Int64 | replicas | `{replicas}` | Number of connected replicas | | |
| db.redis.replication.backlog_first_byte_offset | Gauge | Int64 | | | The master offset of the replication backlog buffer | | |
| db.redis.replication.offset | Gauge | Int64 | | | The server's current replication offset | | |
| db.redis.db.keys | Gauge | Int64 | keys | `{keys}` | Number of keyspace keys | `db` | |
| db.redis.db.expires | Gauge | Int64 | keys | `{keys}` | Number of keyspace keys with an expiration | `db` | |
| db.redis.db.avg_ttl | Gauge | Int64 | milliseconds | `{ms}` | Average keyspace keys TTL | | `db` |
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Below is a table of Process metric instruments.
| `process.cpu.utilization` | Gauge | s | Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process. | `state`, if specified, SHOULD be one of: `system`, `user`, `wait`. A process SHOULD be characterized _either_ by data points with no `state` labels, _or only_ data points with `state` labels. |
| `process.memory.usage` | UpDownCounter | By | The amount of physical memory in use. | |
| `process.memory.virtual` | UpDownCounter | By | The amount of committed virtual memory. | |
| `process.memory.rss` | UpDownCounter | By | The resident state size of the process. | |
| `process.disk.io` | Counter | By | Disk bytes transferred. | `direction` SHOULD be one of: `read`, `write` |

## Attributes
Expand Down