Rename CloudWatchOutput to just CloudWatch.
Also fix CloudWatch.Close() to return nil instead of error
This commit is contained in:
parent
262abb4d25
commit
2b5ea8c17a
|
@ -19,7 +19,7 @@ import (
|
||||||
"github.com/meirf/gopart"
|
"github.com/meirf/gopart"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CloudWatchOutput struct {
|
type CloudWatch struct {
|
||||||
Region string // AWS Region
|
Region string // AWS Region
|
||||||
Namespace string // CloudWatch Metrics Namespace
|
Namespace string // CloudWatch Metrics Namespace
|
||||||
svc *cloudwatch.CloudWatch
|
svc *cloudwatch.CloudWatch
|
||||||
|
@ -33,15 +33,15 @@ var sampleConfig = `
|
||||||
namespace = 'InfluxData/Telegraf'
|
namespace = 'InfluxData/Telegraf'
|
||||||
`
|
`
|
||||||
|
|
||||||
func (c *CloudWatchOutput) SampleConfig() string {
|
func (c *CloudWatch) SampleConfig() string {
|
||||||
return sampleConfig
|
return sampleConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatchOutput) Description() string {
|
func (c *CloudWatch) Description() string {
|
||||||
return "Configuration for AWS CloudWatch output."
|
return "Configuration for AWS CloudWatch output."
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatchOutput) Connect() error {
|
func (c *CloudWatch) Connect() error {
|
||||||
Config := &aws.Config{
|
Config := &aws.Config{
|
||||||
Region: aws.String(c.Region),
|
Region: aws.String(c.Region),
|
||||||
Credentials: credentials.NewChainCredentials(
|
Credentials: credentials.NewChainCredentials(
|
||||||
|
@ -69,11 +69,11 @@ func (c *CloudWatchOutput) Connect() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatchOutput) Close() error {
|
func (c *CloudWatch) Close() error {
|
||||||
return errors.New("Error")
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatchOutput) Write(points []*client.Point) error {
|
func (c *CloudWatch) Write(points []*client.Point) error {
|
||||||
for _, pt := range points {
|
for _, pt := range points {
|
||||||
err := c.WriteSinglePoint(pt)
|
err := c.WriteSinglePoint(pt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -87,7 +87,7 @@ func (c *CloudWatchOutput) Write(points []*client.Point) error {
|
||||||
// Write data for a single point. A point can have many fields and one field
|
// 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
|
// 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.
|
// request can have so we process one Point at a time.
|
||||||
func (c *CloudWatchOutput) WriteSinglePoint(point *client.Point) error {
|
func (c *CloudWatch) WriteSinglePoint(point *client.Point) error {
|
||||||
datums := buildMetricDatum(point)
|
datums := buildMetricDatum(point)
|
||||||
|
|
||||||
const maxDatumsPerCall = 20 // PutMetricData only supports up to 20 data points per call
|
const maxDatumsPerCall = 20 // PutMetricData only supports up to 20 data points per call
|
||||||
|
@ -103,7 +103,7 @@ func (c *CloudWatchOutput) WriteSinglePoint(point *client.Point) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatchOutput) WriteToCloudWatch(datums []*cloudwatch.MetricDatum) error {
|
func (c *CloudWatch) WriteToCloudWatch(datums []*cloudwatch.MetricDatum) error {
|
||||||
params := &cloudwatch.PutMetricDataInput{
|
params := &cloudwatch.PutMetricDataInput{
|
||||||
MetricData: datums,
|
MetricData: datums,
|
||||||
Namespace: aws.String(c.Namespace),
|
Namespace: aws.String(c.Namespace),
|
||||||
|
@ -183,6 +183,6 @@ func buildDimensions(ptTags map[string]string) []*cloudwatch.Dimension {
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
outputs.Add("cloudwatch", func() outputs.Output {
|
outputs.Add("cloudwatch", func() outputs.Output {
|
||||||
return &CloudWatchOutput{}
|
return &CloudWatch{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue