Allow configuring cache_ttl for cloudwatch metrics.
This commit is contained in:
parent
a2f66682df
commit
eac7f23609
|
@ -22,6 +22,7 @@ type (
|
||||||
Delay internal.Duration `toml:"delay"`
|
Delay internal.Duration `toml:"delay"`
|
||||||
Namespace string `toml:"namespace"`
|
Namespace string `toml:"namespace"`
|
||||||
Metrics []*Metric `toml:"metrics"`
|
Metrics []*Metric `toml:"metrics"`
|
||||||
|
CacheTTL string `toml:"cache_ttl"`
|
||||||
client cloudwatchClient
|
client cloudwatchClient
|
||||||
metricCache *MetricCache
|
metricCache *MetricCache
|
||||||
}
|
}
|
||||||
|
@ -74,6 +75,10 @@ func (c *CloudWatch) SampleConfig() string {
|
||||||
## gaps or overlap in pulled data
|
## gaps or overlap in pulled data
|
||||||
interval = '1m'
|
interval = '1m'
|
||||||
|
|
||||||
|
## Configure the TTL for the internal cache of metrics.
|
||||||
|
## Defaults to 1 hr if not specified
|
||||||
|
#cache_ttl = '10m'
|
||||||
|
|
||||||
## Metric Statistic Namespace (required)
|
## Metric Statistic Namespace (required)
|
||||||
namespace = 'AWS/ELB'
|
namespace = 'AWS/ELB'
|
||||||
|
|
||||||
|
@ -152,7 +157,9 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("cloudwatch", func() telegraf.Input {
|
inputs.Add("cloudwatch", func() telegraf.Input {
|
||||||
return &CloudWatch{}
|
return &CloudWatch{
|
||||||
|
CacheTTL: "1hr",
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +204,7 @@ func (c *CloudWatch) fetchNamespaceMetrics() (metrics []*cloudwatch.Metric, err
|
||||||
more = token != nil
|
more = token != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheTTL, _ := time.ParseDuration("1hr")
|
cacheTTL, _ := time.ParseDuration(c.CacheTTL)
|
||||||
c.metricCache = &MetricCache{
|
c.metricCache = &MetricCache{
|
||||||
Metrics: metrics,
|
Metrics: metrics,
|
||||||
Fetched: time.Now(),
|
Fetched: time.Now(),
|
||||||
|
|
Loading…
Reference in New Issue