Skip to content

Commit fc255fe

Browse files
yaten2302mashhurs
authored andcommitted
Retrieve info from CLUSTER INFO redis cmd (open-telemetry#42406)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Currently, the redisreceiver fetches only from the INFO command (and is capable of monitoring individual redis performance). We need to record from the CLUSTER INFO command too. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#38117 <!--Describe what testing was performed and which tests were added.--> #### Testing Added tests for the `CLUSTER INFO` command in the `receiver/redisreceiver/client_test.go` file. However, the `cluster_info.txt` is yet to be added. <!--Please delete paragraphs that you did not use before submitting.--> --------- Signed-off-by: Yaten <[email protected]>
1 parent 48beb61 commit fc255fe

16 files changed

+1639
-259
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: "enhancement"
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: "redisreceiver"
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Add `ClusterInfo` capability to `redisreceiver`"
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [38117]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

receiver/redisreceiver/client.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
type client interface {
1414
// retrieves a string of key/value pairs of redis metadata
1515
retrieveInfo() (string, error)
16+
// retrieves a string of key/value pairs of redis cluster metadata
17+
retrieveClusterInfo() (string, error)
1618
// line delimiter
1719
// redis lines are delimited by \r\n, files (for testing) by \n
1820
delimiter() string
@@ -44,6 +46,11 @@ func (c *redisClient) retrieveInfo() (string, error) {
4446
return c.client.Info(context.Background(), "all").Result()
4547
}
4648

49+
// Retrieve Redis CLUSTER INFO.
50+
func (c *redisClient) retrieveClusterInfo() (string, error) {
51+
return c.client.ClusterInfo(context.Background()).Result()
52+
}
53+
4754
// close client to release connection pool.
4855
func (c *redisClient) close() error {
4956
return c.client.Close()

receiver/redisreceiver/client_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ func (fakeClient) retrieveInfo() (string, error) {
3333
return readFile("info")
3434
}
3535

36+
func (fakeClient) retrieveClusterInfo() (string, error) {
37+
return readFile("cluster_info")
38+
}
39+
3640
func (fakeClient) close() error {
3741
return nil
3842
}

receiver/redisreceiver/documentation.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,108 @@ metrics:
278278
enabled: true
279279
```
280280
281+
### redis.cluster.known_nodes
282+
283+
Number of known nodes in the cluster
284+
285+
| Unit | Metric Type | Value Type | Stability |
286+
| ---- | ----------- | ---------- | --------- |
287+
| {node} | Gauge | Int | development |
288+
289+
### redis.cluster.links_buffer_limit_exceeded.count
290+
291+
Total number of times the cluster links buffer limit was exceeded
292+
293+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
294+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
295+
| {count} | Sum | Int | Cumulative | true | development |
296+
297+
### redis.cluster.node.count
298+
299+
Number of master nodes in the cluster
300+
301+
| Unit | Metric Type | Value Type | Stability |
302+
| ---- | ----------- | ---------- | --------- |
303+
| {node} | Gauge | Int | development |
304+
305+
### redis.cluster.node.uptime
306+
307+
The node's current epoch
308+
309+
| Unit | Metric Type | Value Type | Stability |
310+
| ---- | ----------- | ---------- | --------- |
311+
| s | Gauge | Int | development |
312+
313+
### redis.cluster.slots_assigned
314+
315+
Number of slots assigned in the cluster
316+
317+
| Unit | Metric Type | Value Type | Stability |
318+
| ---- | ----------- | ---------- | --------- |
319+
| {slot} | Gauge | Int | development |
320+
321+
### redis.cluster.slots_fail
322+
323+
Number of slots in the cluster that are in a failing state
324+
325+
| Unit | Metric Type | Value Type | Stability |
326+
| ---- | ----------- | ---------- | --------- |
327+
| {slot} | Gauge | Int | development |
328+
329+
### redis.cluster.slots_ok
330+
331+
Number of slots in the cluster that are ok
332+
333+
| Unit | Metric Type | Value Type | Stability |
334+
| ---- | ----------- | ---------- | --------- |
335+
| {slot} | Gauge | Int | development |
336+
337+
### redis.cluster.slots_pfail
338+
339+
Number of slots in the cluster that are in a 'potentially failing' state
340+
341+
| Unit | Metric Type | Value Type | Stability |
342+
| ---- | ----------- | ---------- | --------- |
343+
| {slot} | Gauge | Int | development |
344+
345+
### redis.cluster.state
346+
347+
State of the cluster
348+
349+
| Unit | Metric Type | Value Type | Stability |
350+
| ---- | ----------- | ---------- | --------- |
351+
| {state} | Gauge | Int | development |
352+
353+
#### Attributes
354+
355+
| Name | Description | Values | Optional |
356+
| ---- | ----------- | ------ | -------- |
357+
| cluster_state | State of the cluster | Str: ``ok``, ``fail`` | false |
358+
359+
### redis.cluster.stats_messages_received
360+
361+
Total number of messages received by the cluster
362+
363+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
364+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
365+
| {message} | Sum | Int | Cumulative | true | development |
366+
367+
### redis.cluster.stats_messages_sent
368+
369+
Total number of messages sent by the cluster
370+
371+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
372+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
373+
| {message} | Sum | Int | Cumulative | true | development |
374+
375+
### redis.cluster.uptime
376+
377+
Current epoch of the cluster
378+
379+
| Unit | Metric Type | Value Type | Stability |
380+
| ---- | ----------- | ---------- | --------- |
381+
| s | Gauge | Int | development |
382+
281383
### redis.cmd.calls
282384
283385
Total number of calls for a command

receiver/redisreceiver/internal/metadata/generated_config.go

Lines changed: 83 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)