Skip to content

Commit

Permalink
Merge pull request #10 from flant/422951-exclude-in-cluster-settings-…
Browse files Browse the repository at this point in the history
…transient

Добавляем метрику oneday_elasticsearch_exclude_exists для transient
  • Loading branch information
uzhinskiy authored Feb 26, 2024
2 parents 78e32ef + d8a5409 commit 55618a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion collector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (c *Client) GetClusterSettings() (map[string]interface{}, error) {
c.logger.Debug("Getting cluster settings")
resp, err := c.es.Cluster.GetSettings(
c.es.Cluster.GetSettings.WithIncludeDefaults(true),
c.es.Cluster.GetSettings.WithFilterPath("persistent.cluster.routing.allocation.exclude"),
c.es.Cluster.GetSettings.WithFilterPath("*.cluster.routing.allocation.exclude"),
)
if err != nil {
return nil, fmt.Errorf("error getting response: %s", err)
Expand Down
12 changes: 11 additions & 1 deletion collector/cluster-settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ func (c *ClusterSettingsCollector) Collect(ch chan<- prometheus.Metric) {

if len(settings) == 0 {
ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "persistent")
ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "transient")
} else {
ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 1, "persistent")
if settings["persistent"] == nil {
ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "persistent")
} else {
ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 1, "persistent")
}
if settings["transient"] == nil {
ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "transient")
} else {
ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 1, "transient")
}
}
}

0 comments on commit 55618a6

Please sign in to comment.