Allow for force gathering ES cluster stats (#4345)
This commit is contained in:
parent
9c9511bde9
commit
0772076378
|
@ -1907,10 +1907,12 @@
|
||||||
# ## - cluster
|
# ## - cluster
|
||||||
# # cluster_health_level = "indices"
|
# # cluster_health_level = "indices"
|
||||||
#
|
#
|
||||||
# ## Set cluster_stats to true when you want to also obtain cluster stats from the
|
# ## Set cluster_stats to true when you want to also obtain cluster stats.
|
||||||
# ## Master node.
|
|
||||||
# cluster_stats = false
|
# cluster_stats = false
|
||||||
#
|
#
|
||||||
|
# ## Only gather cluster_stats from the master node. To work this require local = true
|
||||||
|
# cluster_stats_only_from_master = true
|
||||||
|
#
|
||||||
# ## node_stats is a list of sub-stats that you want to have gathered. Valid options
|
# ## node_stats is a list of sub-stats that you want to have gathered. Valid options
|
||||||
# ## are "indices", "os", "process", "jvm", "thread_pool", "fs", "transport", "http",
|
# ## are "indices", "os", "process", "jvm", "thread_pool", "fs", "transport", "http",
|
||||||
# ## "breaker". Per default, all stats are gathered.
|
# ## "breaker". Per default, all stats are gathered.
|
||||||
|
|
|
@ -29,10 +29,12 @@ or [cluster-stats](https://www.elastic.co/guide/en/elasticsearch/reference/curre
|
||||||
## - cluster
|
## - cluster
|
||||||
# cluster_health_level = "indices"
|
# cluster_health_level = "indices"
|
||||||
|
|
||||||
## Set cluster_stats to true when you want to also obtain cluster stats from the
|
## Set cluster_stats to true when you want to also obtain cluster stats.
|
||||||
## Master node.
|
|
||||||
cluster_stats = false
|
cluster_stats = false
|
||||||
|
|
||||||
|
## Only gather cluster_stats from the master node. To work this require local = true
|
||||||
|
cluster_stats_only_from_master = true
|
||||||
|
|
||||||
## node_stats is a list of sub-stats that you want to have gathered. Valid options
|
## node_stats is a list of sub-stats that you want to have gathered. Valid options
|
||||||
## are "indices", "os", "process", "jvm", "thread_pool", "fs", "transport", "http",
|
## are "indices", "os", "process", "jvm", "thread_pool", "fs", "transport", "http",
|
||||||
## "breaker". Per default, all stats are gathered.
|
## "breaker". Per default, all stats are gathered.
|
||||||
|
|
|
@ -104,10 +104,12 @@ const sampleConfig = `
|
||||||
## - cluster
|
## - cluster
|
||||||
# cluster_health_level = "indices"
|
# cluster_health_level = "indices"
|
||||||
|
|
||||||
## Set cluster_stats to true when you want to also obtain cluster stats from the
|
## Set cluster_stats to true when you want to also obtain cluster stats.
|
||||||
## Master node.
|
|
||||||
cluster_stats = false
|
cluster_stats = false
|
||||||
|
|
||||||
|
## Only gather cluster_stats from the master node. To work this require local = true
|
||||||
|
cluster_stats_only_from_master = true
|
||||||
|
|
||||||
## node_stats is a list of sub-stats that you want to have gathered. Valid options
|
## node_stats is a list of sub-stats that you want to have gathered. Valid options
|
||||||
## are "indices", "os", "process", "jvm", "thread_pool", "fs", "transport", "http",
|
## are "indices", "os", "process", "jvm", "thread_pool", "fs", "transport", "http",
|
||||||
## "breaker". Per default, all stats are gathered.
|
## "breaker". Per default, all stats are gathered.
|
||||||
|
@ -130,6 +132,7 @@ type Elasticsearch struct {
|
||||||
ClusterHealth bool
|
ClusterHealth bool
|
||||||
ClusterHealthLevel string
|
ClusterHealthLevel string
|
||||||
ClusterStats bool
|
ClusterStats bool
|
||||||
|
ClusterStatsOnlyFromMaster bool
|
||||||
NodeStats []string
|
NodeStats []string
|
||||||
tls.ClientConfig
|
tls.ClientConfig
|
||||||
|
|
||||||
|
@ -142,6 +145,7 @@ type Elasticsearch struct {
|
||||||
func NewElasticsearch() *Elasticsearch {
|
func NewElasticsearch() *Elasticsearch {
|
||||||
return &Elasticsearch{
|
return &Elasticsearch{
|
||||||
HttpTimeout: internal.Duration{Duration: time.Second * 5},
|
HttpTimeout: internal.Duration{Duration: time.Second * 5},
|
||||||
|
ClusterStatsOnlyFromMaster: true,
|
||||||
ClusterHealthLevel: "indices",
|
ClusterHealthLevel: "indices",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +220,7 @@ func (e *Elasticsearch) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.ClusterStats && e.isMaster {
|
if e.ClusterStats && (e.isMaster || !e.ClusterStatsOnlyFromMaster || !e.Local) {
|
||||||
if err := e.gatherClusterStats(s+"/_cluster/stats", acc); err != nil {
|
if err := e.gatherClusterStats(s+"/_cluster/stats", acc); err != nil {
|
||||||
acc.AddError(fmt.Errorf(mask.ReplaceAllString(err.Error(), "http(s)://XXX:XXX@")))
|
acc.AddError(fmt.Errorf(mask.ReplaceAllString(err.Error(), "http(s)://XXX:XXX@")))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue