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

gatherCommandstatsLine #5774

Closed
lingfan opened this issue Apr 28, 2019 · 5 comments
Closed

gatherCommandstatsLine #5774

lingfan opened this issue Apr 28, 2019 · 5 comments
Labels
area/redis feature request Requests for new plugin and for new features to existing plugins
Milestone

Comments

@lingfan
Copy link

lingfan commented Apr 28, 2019

Feature Request

Opening a feature request kicks off a discussion.

Proposal:

Current behavior:

Desired behavior:

func gatherCommandstatsLine(
	name string,
	line string,
	acc telegraf.Accumulator,
	global_tags map[string]string,
) {
	if strings.Contains(line, "calls=") {
		fields := make(map[string]interface{})
		tags := make(map[string]string)
		for k, v := range global_tags {
			tags[k] = v
		}
		tags["key_name"] = name
		dbparts := strings.Split(line, ",")
		for _, dbp := range dbparts {
			kv := strings.Split(dbp, "=")
			ival, err := strconv.ParseInt(kv[1], 10, 64)
			if err == nil {
				fields[kv[0]] = ival
			}
		}
		acc.AddFields("commandstats", fields, tags)
	}
}

Use case:

@danielnelson
Copy link
Contributor

Link to upstream documentation: https://redis.io/commands/info

The commandstats section provides statistics based on the command type, including the number of calls, the total CPU time consumed by these commands, and the average CPU consumed per command execution.

For each command type, the following line is added:

  • cmdstat_XXX: calls=XXX,usec=XXX,usec_per_call=XXX

The cluster section currently only contains a unique field:

  • cluster_enabled: Indicate Redis cluster is enabled

The keyspace section provides statistics on the main dictionary of each database. The statistics are the number of keys, and the number of keys with an expiration.

For each database, the following line is added:

  • dbXXX: keys=XXX,expires=XXX

@danielnelson danielnelson added area/redis feature request Requests for new plugin and for new features to existing plugins labels Apr 29, 2019
@wingyplus
Copy link
Contributor

wingyplus commented May 14, 2019

I start prototyping gathering commandstats from info here.

Screen Shot 2562-05-14 at 21 49 41

Love to hear your feedback. :)

@glinton
Copy link
Contributor

glinton commented May 16, 2019

Awesome, feel free to open a pull request from your branch

wingyplus added a commit to wingyplus/telegraf that referenced this issue May 17, 2019
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
@wingyplus
Copy link
Contributor

@lingfan @glinton @danielnelson pull request opened. Suggestion are welcome. :)

wingyplus added a commit to wingyplus/telegraf that referenced this issue May 18, 2019
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
@danielnelson danielnelson added this to the 1.12.0 milestone Aug 16, 2019
@danielnelson
Copy link
Contributor

Added in #5926

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/redis feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants