Added support to override metric_url in newrelic output plugin (#9342)
This commit is contained in:
parent
769f582245
commit
cc82c7ccf9
|
|
@ -21,6 +21,10 @@ Telegraf minimum version: Telegraf 1.15.0
|
|||
## HTTP Proxy override. If unset use values from the standard
|
||||
## proxy environment variables to determine proxy, if any.
|
||||
# http_proxy = "http://corporate.proxy:3128"
|
||||
|
||||
## Metric URL override to enable geographic location endpoints.
|
||||
# If not set use values from the standard
|
||||
# metric_url = "https://metric-api.newrelic.com/metric/v1"
|
||||
```
|
||||
|
||||
[Metrics API]: https://docs.newrelic.com/docs/data-ingest-apis/get-data-new-relic/metric-api/introduction-metric-api
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ type NewRelic struct {
|
|||
MetricPrefix string `toml:"metric_prefix"`
|
||||
Timeout config.Duration `toml:"timeout"`
|
||||
HTTPProxy string `toml:"http_proxy"`
|
||||
MetricURL string `toml:"metric_url"`
|
||||
|
||||
harvestor *telemetry.Harvester
|
||||
dc *cumulative.DeltaCalculator
|
||||
|
|
@ -49,6 +50,10 @@ func (nr *NewRelic) SampleConfig() string {
|
|||
## HTTP Proxy override. If unset use values from the standard
|
||||
## proxy environment variables to determine proxy, if any.
|
||||
# http_proxy = "http://corporate.proxy:3128"
|
||||
|
||||
## Metric URL override to enable geographic location endpoints.
|
||||
# If not set use values from the standard
|
||||
# metric_url = "https://metric-api.newrelic.com/metric/v1"
|
||||
`
|
||||
}
|
||||
|
||||
|
|
@ -77,6 +82,9 @@ func (nr *NewRelic) Connect() error {
|
|||
nr.errorCount++
|
||||
nr.savedErrors[nr.errorCount] = errorString
|
||||
}
|
||||
if nr.MetricURL != "" {
|
||||
cfg.MetricsURLOverride = nr.MetricURL
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to connect to newrelic %v", err)
|
||||
|
|
|
|||
|
|
@ -173,6 +173,14 @@ func TestNewRelic_Connect(t *testing.T) {
|
|||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Test: Metric URL ",
|
||||
newrelic: &NewRelic{
|
||||
InsightsKey: "12121212",
|
||||
MetricURL: "https://test.nr.com",
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue