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

This commit is contained in:
Joshua Powers 2023-09-08 12:11:09 -06:00 committed by GitHub
parent 67f9a0ea82
commit 47c5665f50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -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:
@ -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:

View File

@ -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

View File

@ -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