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

fix: debug cloudwatch, update deps #10051

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ require (
github.com/aristanetworks/glog v0.0.0-20191112221043-67e8567f59f3 // indirect
github.com/aristanetworks/goarista v0.0.0-20190325233358-a123909ec740
github.com/armon/go-metrics v0.3.3 // indirect
github.com/aws/aws-sdk-go-v2 v1.9.2
github.com/aws/aws-sdk-go-v2 v1.10.0
github.com/aws/aws-sdk-go-v2/config v1.8.3
github.com/aws/aws-sdk-go-v2/credentials v1.4.3
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.5.3 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.0.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.7.0
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.5.2
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.9.0
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.8.0
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.5.0
github.com/aws/aws-sdk-go-v2/service/ec2 v1.1.0
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.3.0 // indirect
Expand All @@ -67,7 +67,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.4.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.7.2
github.com/aws/aws-sdk-go-v2/service/timestreamwrite v1.3.2
github.com/aws/smithy-go v1.8.0
github.com/aws/smithy-go v1.8.1
github.com/benbjohnson/clock v1.1.0
github.com/beorn7/perks v1.0.1 // indirect
github.com/bitly/go-hostpool v0.1.0 // indirect
Expand Down
15 changes: 8 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ github.com/aws/aws-sdk-go-v2 v1.8.0/go.mod h1:xEFuWz+3TYdlPRuo+CqATbeDWIWyaT5uAP
github.com/aws/aws-sdk-go-v2 v1.8.1/go.mod h1:xEFuWz+3TYdlPRuo+CqATbeDWIWyaT5uAPwPaWtgse0=
github.com/aws/aws-sdk-go-v2 v1.9.0/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4=
github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4=
github.com/aws/aws-sdk-go-v2 v1.9.2 h1:dUFQcMNZMLON4BOe273pl0filK9RqyQMhCK/6xssL6s=
github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4=
github.com/aws/aws-sdk-go-v2 v1.10.0 h1:+dCJ5W2HiZNa4UtaIc5ljKNulm0dK0vS5dxb5LdDOAA=
github.com/aws/aws-sdk-go-v2 v1.10.0/go.mod h1:U/EyyVvKtzmFeQQcca7eBotKdlpcP2zzU6bXBYcf7CE=
github.com/aws/aws-sdk-go-v2/config v1.6.0/go.mod h1:TNtBVmka80lRPk5+S9ZqVfFszOQAGJJ9KbT3EM3CHNU=
github.com/aws/aws-sdk-go-v2/config v1.6.0/go.mod h1:TNtBVmka80lRPk5+S9ZqVfFszOQAGJJ9KbT3EM3CHNU=
github.com/aws/aws-sdk-go-v2/config v1.6.1/go.mod h1:t/y3UPu0XEDy0cEw6mvygaBQaPzWiYAxfP2SzgtvclA=
Expand Down Expand Up @@ -344,10 +345,10 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.2.1/go.mod h1:Pv3WenDjI0v2Jl7UaMFII
github.com/aws/aws-sdk-go-v2/internal/ini v1.2.3/go.mod h1:EES9ToeC3h063zCFDdqWGnARExNdULPaBvARm1FLwxA=
github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4 h1:leSJ6vCqtPpTmBIgE7044B1wql1E4n//McF+mEgNrYg=
github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ=
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.7.0 h1:vXZPcDQg7e5z2IKz0huei6zhfAxDoZdXej2o3jUbjCI=
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.7.0/go.mod h1:BlrFkwOhSgESkbdS+zJBy4+1mQ3f3Fq9Gp8nT+gaSwk=
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.5.2 h1:B120/boLr82yRaQFEPn9u01OwWMnc+xGvz5SOHfBrHY=
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.5.2/go.mod h1:td1djV1rAzEPcit9L8urGneIi2pYvtI7b/kfMWdpe84=
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.9.0 h1:SZiVvMwLnXwx34MMnpicxQnQZq6ter7EGG7xwZGZry0=
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.9.0/go.mod h1:iX4tSMY8NP1mzU2PMS6arLyB/Yufz2LxCkn9DsgiWEI=
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.8.0 h1:WQY4Qit9/XiIAH4mhbT8qaMFIWl2OExcXrFecz2eGXQ=
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.8.0/go.mod h1:clJaIaj1E6A3vSq1Qd++dfcG3dbF8gUfTEUiaTZxpVY=
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.5.0 h1:SGwKUQaJudQQZE72dDQlL2FGuHNAEK1CyqKLTjh6mqE=
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.5.0/go.mod h1:XY5YhCS9SLul3JSQ08XG/nfxXxrkh6RR21XPq/J//NY=
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.4.0 h1:QbFWJr2SAyVYvyoOHvJU6sCGLnqNT94ZbWElJMEI1JY=
Expand Down Expand Up @@ -399,10 +400,10 @@ github.com/aws/smithy-go v1.0.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB
github.com/aws/smithy-go v1.7.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
github.com/aws/smithy-go v1.7.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
github.com/aws/smithy-go v1.7.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
github.com/aws/smithy-go v1.8.0 h1:AEwwwXQZtUwP5Mz506FeXXrKBe0jA8gVM+1gEcSRooc=
github.com/aws/smithy-go v1.8.0 h1:AEwwwXQZtUwP5Mz506FeXXrKBe0jA8gVM+1gEcSRooc=
github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
github.com/aws/smithy-go v1.8.1 h1:9Y6qxtzgEODaLNGN+oN2QvcHvKUe4jsH8w4M+8LXzGk=
github.com/aws/smithy-go v1.8.1/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
github.com/awslabs/kinesis-aggregation/go v0.0.0-20210630091500-54e17340d32f h1:Pf0BjJDga7C98f0vhw+Ip5EaiE07S3lTKpIYPNS0nMo=
github.com/awslabs/kinesis-aggregation/go v0.0.0-20210630091500-54e17340d32f/go.mod h1:SghidfnxvX7ribW6nHI7T+IBbc9puZ9kk5Tx/88h8P4=
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
Expand Down
11 changes: 9 additions & 2 deletions plugins/inputs/cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {

// Get all of the possible queries so we can send groups of 100.
queries := c.getDataQueries(filteredMetrics)
c.Log.Debugf("running %d queries", len(queries))
if len(queries) == 0 {
return nil
}
Expand Down Expand Up @@ -426,13 +427,14 @@ func (c *CloudWatch) fetchNamespaceMetrics() ([]types.Metric, error) {
}

for _, namespace := range c.Namespaces {
c.Log.Debugf("fetching metrics from namespace: %s", namespace)
params.Namespace = aws.String(namespace)
for {
resp, err := c.client.ListMetrics(context.Background(), params)
if err != nil {
return nil, fmt.Errorf("failed to list metrics with params per namespace: %v", err)
}

c.Log.Debugf("found %d metrics", len(resp.Metrics))
metrics = append(metrics, resp.Metrics...)
if resp.NextToken == nil {
break
Expand Down Expand Up @@ -563,7 +565,9 @@ func (c *CloudWatch) gatherMetrics(
if err != nil {
return nil, fmt.Errorf("failed to get metric data: %v", err)
}

for _, result := range resp.MetricDataResults {
c.Log.Debugf("%s %f", *result.Label, result.Values)
}
results = append(results, resp.MetricDataResults...)
if resp.NextToken == nil {
break
Expand All @@ -583,6 +587,7 @@ func (c *CloudWatch) aggregateMetrics(
)

for namespace, results := range metricDataResults {
c.Log.Debugf("aggregating metrics for namespace: %s (%d results)", namespace, len(results))
namespace = sanitizeMeasurement(namespace)

for _, result := range results {
Expand All @@ -593,7 +598,9 @@ func (c *CloudWatch) aggregateMetrics(
}
tags["region"] = c.Region

c.Log.Debugf("%s: found %d values", *result.Label, len(result.Values))
for i := range result.Values {
c.Log.Debugf("recording metric: \"%s\" tags: \"%s\" fields: \"%s=%s\"", namespace, tags, *result.Label, result.Values[i])
if err := grouper.Add(namespace, tags, result.Timestamps[i], *result.Label, result.Values[i]); err != nil {
acc.AddError(err)
}
Expand Down
3 changes: 3 additions & 0 deletions plugins/inputs/cloudwatch/cloudwatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func TestGather(t *testing.T) {
Delay: internalDuration,
Period: internalDuration,
RateLimit: 200,
Log: testutil.Logger{},
}

var acc testutil.Accumulator
Expand Down Expand Up @@ -136,6 +137,7 @@ func TestGather_MultipleNamespaces(t *testing.T) {
Delay: internalDuration,
Period: internalDuration,
RateLimit: 200,
Log: testutil.Logger{},
}

var acc testutil.Accumulator
Expand Down Expand Up @@ -212,6 +214,7 @@ func TestSelectMetrics(t *testing.T) {
Delay: internalDuration,
Period: internalDuration,
RateLimit: 200,
Log: testutil.Logger{},
Metrics: []*Metric{
{
MetricNames: []string{"Latency", "RequestCount"},
Expand Down