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

Configurable basicstats #3580

Merged
merged 3 commits into from
Dec 15, 2017

Conversation

JeffAshton
Copy link
Contributor

Basic implementation of configuring which stats are pushed from basicstats aggregator (#3413)

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

statsConfig *configuredStats
}

type configuredStats struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also do this as flags, but not sure it's a win

@@ -114,23 +127,101 @@ func (m *BasicStats) Add(in telegraf.Metric) {
}

func (m *BasicStats) Push(acc telegraf.Accumulator) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the first pass, only using the configuration to control which stats are pushed. I'm not trying to optimize the computation of each stat as they are added.

The balance between checking the configuration per calculation seems like a micro optimization we can make later.

}
//if count == 1 StdDev = infinite => so I won't send data
}
acc.AddFields(aggregate.name, fields, aggregate.tags)

if len(fields) > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an empty array is specified in the configuration, then we push nothing. I plan to use this with the field specific configuration, in other words, only produce aggregations for known fields.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can determine an empty array from a unset array with our current toml parsing, so you should always have at least one field.

Remember you can use the regular measurement filtering options to control what fields are added in the first place.

Copy link
Contributor Author

@JeffAshton JeffAshton Dec 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. I still feel like this check isn't a bad thing. It would still happen if I passed an invalid stat, for example:

[[aggregators.basicstats]]
  period = "5s"
  drop_original = true
  stats = [ "-" ]

Which would produce this case. So in the interest of being robust, I think the check is worth it.

parsed.stdev = true

default:
log.Printf("W! Unrecognized basic stat '%s', ignoring", name)
Copy link
Contributor Author

@JeffAshton JeffAshton Dec 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sample output:

2017-12-13T23:09:30Z W! Unrecognized basic stat '[wacky]', ignoring

return parsed
}

func defaultStats() *configuredStats {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly for backwards compatibility. If not specified in the config, you get the old default of everything.

}

// Test only aggregating minimum and maximum
func TestBasicStatsWithMinAndMax(t *testing.T) {
Copy link
Contributor Author

@JeffAshton JeffAshton Dec 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test for 2 stats

@danielnelson danielnelson added this to the 1.6.0 milestone Dec 14, 2017
@danielnelson danielnelson added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Dec 14, 2017
@danielnelson danielnelson merged commit fcc9c82 into influxdata:master Dec 15, 2017
@JeffAshton JeffAshton deleted the configurable-basicstats branch December 21, 2017 19:36
aromeyer pushed a commit to aromeyer/telegraf that referenced this pull request May 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants