From 2b9f539048de9bbd360f46b8f86104aa93229ef7 Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Tue, 5 Sep 2023 11:41:41 -0600 Subject: [PATCH 1/2] feat(inputs.redis): Add additional commandstat fields fixes: 13861 --- plugins/inputs/redis/README.md | 6 ++++-- plugins/inputs/redis/redis.go | 2 +- plugins/inputs/redis/redis_test.go | 11 +++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/inputs/redis/README.md b/plugins/inputs/redis/README.md index 361a1a40fdb62..6963f6c668f05 100644 --- a/plugins/inputs/redis/README.md +++ b/plugins/inputs/redis/README.md @@ -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) @@ -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: diff --git a/plugins/inputs/redis/redis.go b/plugins/inputs/redis/redis.go index 3e1efb492bf57..7b924358c0209 100644 --- a/plugins/inputs/redis/redis.go +++ b/plugins/inputs/redis/redis.go @@ -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 diff --git a/plugins/inputs/redis/redis_test.go b/plugins/inputs/redis/redis_test.go index 4bb9ae0109cee..e5e588fd76e23 100644 --- a/plugins/inputs/redis/redis_test.go +++ b/plugins/inputs/redis/redis_test.go @@ -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", @@ -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 From 4424e8da06bd076f112c5e3470e6d6cc9ecb113d Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Fri, 8 Sep 2023 10:58:54 -0600 Subject: [PATCH 2/2] update example with new fields --- plugins/inputs/redis/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/redis/README.md b/plugins/inputs/redis/README.md index 6963f6c668f05..e79f902b47da8 100644 --- a/plugins/inputs/redis/README.md +++ b/plugins/inputs/redis/README.md @@ -223,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: