Log no metrics found at debug level in cloudwatch input (#6665)

This commit is contained in:
Daniel Nelson 2019-11-15 18:52:55 -08:00 committed by GitHub
parent 122ec0fa39
commit 7a90ddd1b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -111,7 +111,7 @@ func (ac *accumulator) AddError(err error) {
return return
} }
NErrors.Incr(1) NErrors.Incr(1)
log.Printf("D! [%s] Error in plugin: %v", ac.maker.LogName(), err) log.Printf("E! [%s] Error in plugin: %v", ac.maker.LogName(), err)
} }
func (ac *accumulator) SetPrecision(precision time.Duration) { func (ac *accumulator) SetPrecision(precision time.Duration) {

View File

@ -1,7 +1,6 @@
package cloudwatch package cloudwatch
import ( import (
"errors"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -12,7 +11,6 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatch" "github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/filter" "github.com/influxdata/telegraf/filter"
"github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/internal"
@ -44,6 +42,8 @@ type (
CacheTTL internal.Duration `toml:"cache_ttl"` CacheTTL internal.Duration `toml:"cache_ttl"`
RateLimit int `toml:"ratelimit"` RateLimit int `toml:"ratelimit"`
Log telegraf.Logger `toml:"-"`
client cloudwatchClient client cloudwatchClient
statFilter filter.Filter statFilter filter.Filter
metricCache *metricCache metricCache *metricCache
@ -197,6 +197,10 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
return err return err
} }
if len(queries) == 0 {
return nil
}
// Limit concurrency or we can easily exhaust user connection limit. // Limit concurrency or we can easily exhaust user connection limit.
// See cloudwatch API request limits: // See cloudwatch API request limits:
// http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/cloudwatch_limits.html // http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/cloudwatch_limits.html
@ -481,7 +485,8 @@ func (c *CloudWatch) getDataQueries(filteredMetrics []filteredMetric) ([]*cloudw
} }
if len(dataQueries) == 0 { if len(dataQueries) == 0 {
return nil, errors.New("no metrics found to collect") c.Log.Debug("no metrics found to collect")
return nil, nil
} }
if c.metricCache == nil { if c.metricCache == nil {