feat: (outputs.elasticsearch) Add healthcheck timeout (#10853)
This commit is contained in:
parent
32222d96ce
commit
6a0311c24f
|
|
@ -197,6 +197,8 @@ POST https://es.us-east-1.amazonaws.com/2021-01-01/opensearch/upgradeDomain
|
|||
## Set the interval to check if the Elasticsearch nodes are available
|
||||
## Setting to "0s" will disable the health check (not recommended in production)
|
||||
health_check_interval = "10s"
|
||||
## Set the timeout for periodic health checks.
|
||||
# health_check_timeout = "1s"
|
||||
## HTTP basic authentication details.
|
||||
# username = "telegraf"
|
||||
# password = "mypassword"
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ type Elasticsearch struct {
|
|||
FloatReplacement float64 `toml:"float_replacement_value"`
|
||||
ForceDocumentID bool `toml:"force_document_id"`
|
||||
HealthCheckInterval config.Duration `toml:"health_check_interval"`
|
||||
HealthCheckTimeout config.Duration `toml:"health_check_timeout"`
|
||||
IndexName string `toml:"index_name"`
|
||||
ManageTemplate bool `toml:"manage_template"`
|
||||
OverwriteTemplate bool `toml:"overwrite_template"`
|
||||
|
|
@ -66,6 +67,8 @@ var sampleConfig = `
|
|||
## Set the interval to check if the Elasticsearch nodes are available
|
||||
## Setting to "0s" will disable the health check (not recommended in production)
|
||||
health_check_interval = "10s"
|
||||
## Set the timeout for periodic health checks.
|
||||
# health_check_timeout = "1s"
|
||||
## HTTP basic authentication details
|
||||
# username = "telegraf"
|
||||
# password = "mypassword"
|
||||
|
|
@ -246,6 +249,7 @@ func (a *Elasticsearch) Connect() error {
|
|||
elastic.SetScheme(elasticURL.Scheme),
|
||||
elastic.SetURL(a.URLs...),
|
||||
elastic.SetHealthcheckInterval(time.Duration(a.HealthCheckInterval)),
|
||||
elastic.SetHealthcheckTimeout(time.Duration(a.HealthCheckTimeout)),
|
||||
elastic.SetGzip(a.EnableGzip),
|
||||
)
|
||||
|
||||
|
|
@ -544,6 +548,7 @@ func init() {
|
|||
return &Elasticsearch{
|
||||
Timeout: config.Duration(time.Second * 5),
|
||||
HealthCheckInterval: config.Duration(time.Second * 10),
|
||||
HealthCheckTimeout: config.Duration(time.Second * 1),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ func TestConnectAndWriteIntegration(t *testing.T) {
|
|||
TemplateName: "telegraf",
|
||||
OverwriteTemplate: false,
|
||||
HealthCheckInterval: config.Duration(time.Second * 10),
|
||||
HealthCheckTimeout: config.Duration(time.Second * 1),
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ func TestConnectAndWriteMetricWithNaNValueEmpty(t *testing.T) {
|
|||
TemplateName: "telegraf",
|
||||
OverwriteTemplate: false,
|
||||
HealthCheckInterval: config.Duration(time.Second * 10),
|
||||
HealthCheckTimeout: config.Duration(time.Second * 1),
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +95,7 @@ func TestConnectAndWriteMetricWithNaNValueNone(t *testing.T) {
|
|||
TemplateName: "telegraf",
|
||||
OverwriteTemplate: false,
|
||||
HealthCheckInterval: config.Duration(time.Second * 10),
|
||||
HealthCheckTimeout: config.Duration(time.Second * 1),
|
||||
FloatHandling: "none",
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
|
|
@ -129,6 +132,7 @@ func TestConnectAndWriteMetricWithNaNValueDrop(t *testing.T) {
|
|||
TemplateName: "telegraf",
|
||||
OverwriteTemplate: false,
|
||||
HealthCheckInterval: config.Duration(time.Second * 10),
|
||||
HealthCheckTimeout: config.Duration(time.Second * 1),
|
||||
FloatHandling: "drop",
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
|
|
@ -165,6 +169,7 @@ func TestConnectAndWriteMetricWithNaNValueReplacement(t *testing.T) {
|
|||
TemplateName: "telegraf",
|
||||
OverwriteTemplate: false,
|
||||
HealthCheckInterval: config.Duration(time.Second * 10),
|
||||
HealthCheckTimeout: config.Duration(time.Second * 1),
|
||||
FloatHandling: "3.1415",
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue