set a default value of 10 for ratelimit

This commit is contained in:
Nathan Haneysmith 2016-08-29 11:41:43 -07:00
parent 0589a1d0a5
commit ca49babf3a
2 changed files with 10 additions and 2 deletions

View File

@ -36,7 +36,7 @@ API endpoint. In the following order the plugin will attempt to authenticate.
## Maximum requests per second. Note that the global default AWS rate limit is ## Maximum requests per second. Note that the global default AWS rate limit is
## 10 reqs/sec, so if you define multiple namespaces, these should add up to a ## 10 reqs/sec, so if you define multiple namespaces, these should add up to a
## maximum of 10. ## maximum of 10. Optional - default value is 10.
ratelimit = 10 ratelimit = 10
## Metrics to Pull (optional) ## Metrics to Pull (optional)

View File

@ -99,7 +99,7 @@ func (c *CloudWatch) SampleConfig() string {
## Maximum requests per second. Note that the global default AWS rate limit is ## Maximum requests per second. Note that the global default AWS rate limit is
## 10 reqs/sec, so if you define multiple namespaces, these should add up to a ## 10 reqs/sec, so if you define multiple namespaces, these should add up to a
## maximum of 10. ## maximum of 10. Optional - default value is 10.
ratelimit = 10 ratelimit = 10
## Metrics to Pull (optional) ## Metrics to Pull (optional)
@ -120,6 +120,8 @@ func (c *CloudWatch) Description() string {
} }
func (c *CloudWatch) Gather(acc telegraf.Accumulator) error { func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
c.setDefaultValues()
if c.client == nil { if c.client == nil {
c.initializeCloudWatch() c.initializeCloudWatch()
} }
@ -197,6 +199,12 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
return errChan.Error() return errChan.Error()
} }
func (c *CloudWatch) setDefaultValues() {
if c.RateLimit == 0 {
c.RateLimit = 10
}
}
func init() { func init() {
inputs.Add("cloudwatch", func() telegraf.Input { inputs.Add("cloudwatch", func() telegraf.Input {
ttl, _ := time.ParseDuration("1hr") ttl, _ := time.ParseDuration("1hr")