Skip to content

Commit 0d135f3

Browse files
authored
Downgrade PMD error logs for systemmetrics pipeline (#2073)
1 parent e360ba4 commit 0d135f3

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

plugins/outputs/cloudwatch/cloudwatch.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,13 @@ func (c *CloudWatch) backoffSleep() {
367367
d = c.config.BackoffRetryBase * time.Duration(1<<c.retries)
368368
}
369369
d = (d / 2) + publishJitter(d/2)
370-
log.Printf("W! cloudwatch: %v retries, going to sleep %v ms before retrying.",
371-
c.retries, d.Milliseconds())
370+
if !c.config.DowngradeErrors {
371+
log.Printf("W! cloudwatch: %v retries, going to sleep %v ms before retrying.",
372+
c.retries, d.Milliseconds())
373+
} else {
374+
log.Printf("I! cloudwatch: %v retries, going to sleep %v ms before retrying.",
375+
c.retries, d.Milliseconds())
376+
}
372377
c.retries++
373378
time.Sleep(d)
374379
}
@@ -423,7 +428,11 @@ func (c *CloudWatch) WriteToCloudWatch(req interface{}) {
423428
continue
424429

425430
default:
426-
log.Printf("E! cloudwatch: code: %s, message: %s, original error: %+v", awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
431+
if !c.config.DowngradeErrors {
432+
log.Printf("E! cloudwatch: code: %s, message: %s, original error: %+v", awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
433+
} else {
434+
log.Printf("I! cloudwatch: PutMetricData unsuccessful")
435+
}
427436
c.backoffSleep()
428437
}
429438
} else {
@@ -432,7 +441,11 @@ func (c *CloudWatch) WriteToCloudWatch(req interface{}) {
432441
break
433442
}
434443
if err != nil {
435-
log.Println("E! cloudwatch: WriteToCloudWatch failure, err: ", err)
444+
if !c.config.DowngradeErrors {
445+
log.Println("E! cloudwatch: WriteToCloudWatch failure, err: ", err)
446+
} else {
447+
log.Println("I! cloudwatch: WriteToCloudWatch unsuccessful, batch dropped")
448+
}
436449
}
437450
}
438451

plugins/outputs/cloudwatch/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ type Config struct {
4242
BackoffRetryBase time.Duration `mapstructure:"backoff_retry_base,omitempty"`
4343
// MaxConcurrentPublishers is the number of concurrent workers making PMD calls. Defaults to 10.
4444
MaxConcurrentPublishers int `mapstructure:"max_concurrent_publishers,omitempty"`
45+
// DowngradeErrors suppresses PutMetricData failure logs: E! and W! are downgraded to I! level.
46+
DowngradeErrors bool `mapstructure:"downgrade_errors,omitempty"`
4547
}
4648

4749
var _ component.Config = (*Config)(nil)

translator/tocwconfig/sampleConfig/system_metrics_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ exporters:
2626
rollup_dimensions:
2727
- - InstanceId
2828
- [ ]
29+
downgrade_errors: true
2930
extensions:
3031
agenthealth/metrics:
3132
is_usage_data_enabled: true

translator/translate/otel/pipeline/systemmetrics/cloudwatch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func (t *cloudWatchTranslator) Translate(_ *confmap.Conf) (component.Config, err
4747
cfg.MaxRetryCount = 2
4848
cfg.BackoffRetryBase = time.Minute
4949
cfg.MaxConcurrentPublishers = 1
50+
cfg.DowngradeErrors = true
5051

5152
return cfg, nil
5253
}

0 commit comments

Comments
 (0)