-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Collect info commandstats from redis #5874
Conversation
@@ -188,7 +188,10 @@ func (r *Redis) gatherServer(client Client, acc telegraf.Accumulator) error { | |||
return err | |||
} | |||
|
|||
rdr := strings.NewReader(info) | |||
// skip for commandstats if we can't retrieve it. | |||
cmdstats, _ := client.Info("commandstats").Result() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this isn't skipping if you can't retrieve, line 194 would be affected as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that which ways is better betwen log an error and let info return default information if we cannot collect command stats and returns an error.
plugins/inputs/redis/redis.go
Outdated
// db0:keys=2,expires=0,avg_ttl=0 | ||
// And there is one for each db on the redis instance | ||
// | ||
// TODO: write code comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove or do TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
tags["cmdstat"] = strings.TrimPrefix(name, "cmdstat_") | ||
stats := strings.Split(line, ",") | ||
for _, stat := range stats { | ||
kv := strings.Split(stat, "=") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check length to avoid a panic later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
plugins/inputs/redis/redis.go
Outdated
ival interface{} | ||
err error | ||
) | ||
// only calls that always be int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: rephrase this comment
fields[kv[0]] = ival | ||
} | ||
} | ||
acc.AddFields("redis_commandstats", fields, tags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if fields
is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s hard to be empty because redis are not returns any line if it has no any command calls. Except that commandstats return the result incorrectly.
Redis has an info type "commandstats" that can be collect each command statistics inside redis. To make this work, I call info with commandstats argument after called info (default information), append it and then parse metrics. Closes influxdata#5774
f0631eb
to
a1b88bf
Compare
This functionality was merged in #5926 |
Redis has an info type "commandstats" that can be collect each command
statistics inside redis. To make this work, I call info with commandstats
argument after called info (default information), append it and then parse
metrics.
Closes #5774
Required for all PRs: