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

feat(inputs.redis): Add additional commandstat fields #13866

Merged
merged 2 commits into from
Sep 8, 2023
Merged
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
8 changes: 5 additions & 3 deletions plugins/inputs/redis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ and the elapsed time since the last rdb save (rdb\_last\_save\_time\_elapsed).
- avg_ttl(int, number)

- redis_cmdstat
Every Redis used command will have 3 new fields:
Every Redis used command could have the following fields:
- calls(int, number)
- failed_calls(int, number)
- rejected_calls(int, number)
- usec(int, mircoseconds)
- usec_per_call(float, microseconds)

Expand All @@ -169,7 +171,7 @@ and the elapsed time since the last rdb save (rdb\_last\_save\_time\_elapsed).
- err
- fields:
- total (int, number)

### Tags

- All measurements have the following tags:
Expand Down Expand Up @@ -221,7 +223,7 @@ redis_keyspace,database=db1,host=host,server=localhost,port=6379,replication_rol
redis_command:

```text
redis_cmdstat,command=publish,host=host,port=6379,replication_role=master,server=localhost calls=68113i,usec=325146i,usec_per_call=4.77 1559227136000000000
redis_cmdstat,command=publish,host=host,port=6379,replication_role=master,server=localhost calls=569514i,failed_calls=0i,rejected_calls=0i,usec=9916334i,usec_per_call=17.41 1559227136000000000
```

redis_error:
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ func gatherCommandstateLine(
switch kv[0] {
case "calls":
fallthrough
case "usec":
case "usec", "rejected_calls", "failed_calls":
ival, err := strconv.ParseInt(kv[1], 10, 64)
if err == nil {
fields[kv[0]] = ival
Expand Down
11 changes: 11 additions & 0 deletions plugins/inputs/redis/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ func TestRedis_ParseMetrics(t *testing.T) {
}
acc.AssertContainsTaggedFields(t, "redis_cmdstat", cmdstatCommandFields, cmdstatCommandTags)

cmdstatPublishTags := map[string]string{"host": "redis.net", "replication_role": "master", "command": "publish"}
cmdstatPublishFields := map[string]interface{}{
"calls": int64(488662),
"usec": int64(8573493),
"usec_per_call": float64(17.54),
"rejected_calls": int64(0),
"failed_calls": int64(0),
}
acc.AssertContainsTaggedFields(t, "redis_cmdstat", cmdstatPublishFields, cmdstatPublishTags)

replicationTags := map[string]string{
"host": "redis.net",
"replication_role": "slave",
Expand Down Expand Up @@ -518,6 +528,7 @@ cluster_enabled:0
# Commandstats
cmdstat_set:calls=261265,usec=1634157,usec_per_call=6.25
cmdstat_command:calls=1,usec=990,usec_per_call=990.00
cmdstat_publish:calls=488662,usec=8573493,usec_per_call=17.54,rejected_calls=0,failed_calls=0

# Errorstats
errorstat_CLUSTERDOWN:count=8
Expand Down