feat(inputs.redis): Support of redis 6.2 ERRORSTATS (#13723)
This commit is contained in:
parent
d259081c2e
commit
3fe151b28d
|
|
@ -164,6 +164,12 @@ and the elapsed time since the last rdb save (rdb\_last\_save\_time\_elapsed).
|
|||
- lag(int, number)
|
||||
- offset(int, number)
|
||||
|
||||
- redis_errorstat
|
||||
- tags:
|
||||
- err
|
||||
- fields:
|
||||
- total (int, number)
|
||||
|
||||
### Tags
|
||||
|
||||
- All measurements have the following tags:
|
||||
|
|
@ -217,3 +223,9 @@ 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_error:
|
||||
|
||||
```text
|
||||
redis_errorstat,err=MOVED,host=host,port=6379,replication_role=master,server=localhost total=4284 1691119309000000000
|
||||
```
|
||||
|
|
|
|||
|
|
@ -419,6 +419,11 @@ func gatherInfoOutput(
|
|||
gatherReplicationLine(name, kline, acc, tags)
|
||||
continue
|
||||
}
|
||||
if section == "Errorstats" {
|
||||
kline := strings.TrimSpace(parts[1])
|
||||
gatherErrorstatsLine(name, kline, acc, tags)
|
||||
continue
|
||||
}
|
||||
|
||||
metric = name
|
||||
}
|
||||
|
|
@ -597,6 +602,30 @@ func gatherReplicationLine(
|
|||
acc.AddFields("redis_replication", fields, tags)
|
||||
}
|
||||
|
||||
// Parse the special Errorstats lines.
|
||||
// Example:
|
||||
//
|
||||
// errorstat_ERR:count=37
|
||||
// errorstat_MOVED:count=3626
|
||||
func gatherErrorstatsLine(
|
||||
name string,
|
||||
line string,
|
||||
acc telegraf.Accumulator,
|
||||
globalTags map[string]string,
|
||||
) {
|
||||
tags := make(map[string]string, len(globalTags)+1)
|
||||
for k, v := range globalTags {
|
||||
tags[k] = v
|
||||
}
|
||||
tags["err"] = strings.TrimPrefix(name, "errorstat_")
|
||||
kv := strings.Split(line, "=")
|
||||
ival, err := strconv.ParseInt(kv[1], 10, 64)
|
||||
if err == nil {
|
||||
fields := map[string]interface{}{"total": ival}
|
||||
acc.AddFields("redis_errorstat", fields, tags)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
inputs.Add("redis", func() telegraf.Input {
|
||||
return &Redis{}
|
||||
|
|
|
|||
|
|
@ -277,6 +277,11 @@ func TestRedis_ParseMetrics(t *testing.T) {
|
|||
}
|
||||
|
||||
acc.AssertContainsTaggedFields(t, "redis_replication", replicationFields, replicationTags)
|
||||
|
||||
errorStatsTags := map[string]string{"host": "redis.net", "replication_role": "master", "err": "MOVED"}
|
||||
errorStatsFields := map[string]interface{}{"total": int64(3628)}
|
||||
|
||||
acc.AssertContainsTaggedFields(t, "redis_errorstat", errorStatsFields, errorStatsTags)
|
||||
}
|
||||
|
||||
func TestRedis_ParseFloatOnInts(t *testing.T) {
|
||||
|
|
@ -514,6 +519,17 @@ cluster_enabled:0
|
|||
cmdstat_set:calls=261265,usec=1634157,usec_per_call=6.25
|
||||
cmdstat_command:calls=1,usec=990,usec_per_call=990.00
|
||||
|
||||
# Errorstats
|
||||
errorstat_CLUSTERDOWN:count=8
|
||||
errorstat_CROSSSLOT:count=3
|
||||
errorstat_ERR:count=172
|
||||
errorstat_LOADING:count=4284
|
||||
errorstat_MASTERDOWN:count=102
|
||||
errorstat_MOVED:count=3628
|
||||
errorstat_NOSCRIPT:count=4
|
||||
errorstat_WRONGPASS:count=2
|
||||
errorstat_WRONGTYPE:count=30
|
||||
|
||||
# Keyspace
|
||||
db0:keys=2,expires=0,avg_ttl=0
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue