feat: add proxy support for outputs/cloudwatch (#11399)
This commit is contained in:
parent
a5bc5b5974
commit
20acbf7090
|
|
@ -59,6 +59,10 @@ The IAM user needs only the `cloudwatch:PutMetricData` permission.
|
||||||
## ex: endpoint_url = "http://localhost:8000"
|
## ex: endpoint_url = "http://localhost:8000"
|
||||||
# endpoint_url = ""
|
# endpoint_url = ""
|
||||||
|
|
||||||
|
## Set http_proxy
|
||||||
|
# use_system_proxy = false
|
||||||
|
# http_proxy_url = "http://localhost:8888"
|
||||||
|
|
||||||
## Namespace for the CloudWatch MetricDatums
|
## Namespace for the CloudWatch MetricDatums
|
||||||
namespace = "InfluxData/Telegraf"
|
namespace = "InfluxData/Telegraf"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
internalaws "github.com/influxdata/telegraf/config/aws"
|
internalaws "github.com/influxdata/telegraf/config/aws"
|
||||||
|
|
||||||
|
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/plugins/outputs"
|
"github.com/influxdata/telegraf/plugins/outputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -26,12 +29,10 @@ type CloudWatch struct {
|
||||||
Namespace string `toml:"namespace"` // CloudWatch Metrics Namespace
|
Namespace string `toml:"namespace"` // CloudWatch Metrics Namespace
|
||||||
HighResolutionMetrics bool `toml:"high_resolution_metrics"`
|
HighResolutionMetrics bool `toml:"high_resolution_metrics"`
|
||||||
svc *cloudwatch.Client
|
svc *cloudwatch.Client
|
||||||
|
WriteStatistics bool `toml:"write_statistics"`
|
||||||
WriteStatistics bool `toml:"write_statistics"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
|
||||||
Log telegraf.Logger `toml:"-"`
|
|
||||||
|
|
||||||
internalaws.CredentialConfig
|
internalaws.CredentialConfig
|
||||||
|
httpconfig.HTTPClientConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type statisticType int
|
type statisticType int
|
||||||
|
|
@ -159,12 +160,24 @@ func (*CloudWatch) SampleConfig() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatch) Connect() error {
|
func (c *CloudWatch) Connect() error {
|
||||||
|
|
||||||
cfg, err := c.CredentialConfig.Credentials()
|
cfg, err := c.CredentialConfig.Credentials()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.svc = cloudwatch.NewFromConfig(cfg)
|
ctx := context.Background()
|
||||||
|
client, err := c.HTTPClientConfig.CreateClient(ctx, c.Log)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
c.svc = cloudwatch.NewFromConfig(cfg, func(options *cloudwatch.Options) {
|
||||||
|
options.HTTPClient = client
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@
|
||||||
## ex: endpoint_url = "http://localhost:8000"
|
## ex: endpoint_url = "http://localhost:8000"
|
||||||
# endpoint_url = ""
|
# endpoint_url = ""
|
||||||
|
|
||||||
|
## Set http_proxy
|
||||||
|
# use_system_proxy = false
|
||||||
|
# http_proxy_url = "http://localhost:8888"
|
||||||
|
|
||||||
## Namespace for the CloudWatch MetricDatums
|
## Namespace for the CloudWatch MetricDatums
|
||||||
namespace = "InfluxData/Telegraf"
|
namespace = "InfluxData/Telegraf"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue