Skip to content

Commit

Permalink
Improve cloudwatch output performance (influxdata#4320)
Browse files Browse the repository at this point in the history
  • Loading branch information
david7482 authored and otherpirate committed Mar 15, 2019
1 parent a3de2c7 commit f213f84
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions plugins/outputs/cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,17 @@ func (c *CloudWatch) Close() error {
}

func (c *CloudWatch) Write(metrics []telegraf.Metric) error {

var datums []*cloudwatch.MetricDatum
for _, m := range metrics {
err := c.WriteSinglePoint(m)
if err != nil {
return err
}
d := BuildMetricDatum(m)
datums = append(datums, d...)
}

return nil
}

// Write data for a single point. A point can have many fields and one field
// is equal to one MetricDatum. There is a limit on how many MetricDatums a
// request can have so we process one Point at a time.
func (c *CloudWatch) WriteSinglePoint(point telegraf.Metric) error {
datums := BuildMetricDatum(point)

const maxDatumsPerCall = 20 // PutMetricData only supports up to 20 data metrics per call

for _, partition := range PartitionDatums(maxDatumsPerCall, datums) {
err := c.WriteToCloudWatch(partition)

if err != nil {
return err
}
Expand Down

0 comments on commit f213f84

Please sign in to comment.