Skip to content

Commit

Permalink
Move CloudWatch rate limit to config
Browse files Browse the repository at this point in the history
Reference influxdata#1670
  • Loading branch information
tmonk42 committed Aug 26, 2016
1 parent e9d3372 commit 2457d95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions plugins/inputs/cloudwatch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ API endpoint. In the following order the plugin will attempt to authenticate.
## Metric Statistic Namespace (required)
namespace = 'AWS/ELB'

## 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
## maximum of 10.
ratelimit = 10

## Metrics to Pull (optional)
## Defaults to all Metrics in Namespace if nothing is provided
## Refreshes Namespace available metrics every 1h
Expand Down
13 changes: 7 additions & 6 deletions plugins/inputs/cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ type (
Filename string `toml:"shared_credential_file"`
Token string `toml:"token"`

Period internal.Duration `toml:"period"`
Delay internal.Duration `toml:"delay"`
Namespace string `toml:"namespace"`
Metrics []*Metric `toml:"metrics"`
CacheTTL internal.Duration `toml:"cache_ttl"`
Period internal.Duration `toml:"period"`
Delay internal.Duration `toml:"delay"`
Namespace string `toml:"namespace"`
Metrics []*Metric `toml:"metrics"`
CacheTTL internal.Duration `toml:"cache_ttl"`
RateLimit internal.RateLimit `toml:"ratelimit"`
client cloudwatchClient
metricCache *MetricCache
}
Expand Down Expand Up @@ -175,7 +176,7 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
// limit concurrency or we can easily exhaust user connection limit
// see cloudwatch API request limits:
// http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/cloudwatch_limits.html
lmtr := limiter.NewRateLimiter(10, time.Second)
lmtr := limiter.NewRateLimiter(c.RateLimit, time.Second)
defer lmtr.Stop()
var wg sync.WaitGroup
wg.Add(len(metrics))
Expand Down

0 comments on commit 2457d95

Please sign in to comment.