From 4d30d31562dd937901a99118ae3d894f02b84179 Mon Sep 17 00:00:00 2001 From: "anton.voskresensky" Date: Wed, 4 Sep 2024 10:46:24 +0300 Subject: [PATCH 1/8] add metrics --- collector/cluster-settings.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/collector/cluster-settings.go b/collector/cluster-settings.go index fdf87fe..db04c9f 100644 --- a/collector/cluster-settings.go +++ b/collector/cluster-settings.go @@ -11,8 +11,9 @@ type ClusterSettingsCollector struct { client *Client logger *logrus.Logger - excludeExists *prometheus.Desc - maxShardsPerNode *prometheus.Desc + excludeExists *prometheus.Desc + maxShardsPerNode *prometheus.Desc + totalShardsPerNodeExists *prometheus.Desc } func NewClusterSettingsCollector(logger *logrus.Logger, client *Client, labels, labels_group []string, datepattern string, @@ -25,6 +26,10 @@ func NewClusterSettingsCollector(logger *logrus.Logger, client *Client, labels, prometheus.BuildFQName(namespace, "exclude", "exists"), "Exclude exists in cluster settings", labels, constLabels, ), + totalShardsPerNodeExists: prometheus.NewDesc( + prometheus.BuildFQName(namespace, "exclude", "exists"), + "total_shards_per_node exists in cluster settings", labels, constLabels, + ), maxShardsPerNode: prometheus.NewDesc( prometheus.BuildFQName(namespace, "clustersettings_stats", "max_shards_per_node"), "Current maximum number of shards per node setting.", @@ -36,6 +41,7 @@ func NewClusterSettingsCollector(logger *logrus.Logger, client *Client, labels, func (c *ClusterSettingsCollector) Describe(ch chan<- *prometheus.Desc) { ch <- c.excludeExists ch <- c.maxShardsPerNode + ch <- c.totalShardsPerNodeExists } func (c *ClusterSettingsCollector) Collect(ch chan<- prometheus.Metric) { @@ -58,6 +64,20 @@ func (c *ClusterSettingsCollector) Collect(ch chan<- prometheus.Metric) { ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "transient") } + path = "persistent.routing.allocation.total_shards_per_node" + if _, ok := walk(settings, path); ok { + ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 1, "persistent") + } else { + ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "persistent") + } + + path = "transient.routing.allocation.total_shards_per_node" + if _, ok := walk(settings, path); ok { + ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 1, "transient") + } else { + ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "transient") + } + path = "persistent.cluster.max_shards_per_node" if count, ok := walk(settings, path); ok { if v, ok := count.(string); ok { From 201202a1ac349c3645f1cad074494098f94ac264 Mon Sep 17 00:00:00 2001 From: "anton.voskresensky" Date: Wed, 4 Sep 2024 10:49:59 +0300 Subject: [PATCH 2/8] add metrics --- collector/cluster-settings.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/collector/cluster-settings.go b/collector/cluster-settings.go index db04c9f..c2cb107 100644 --- a/collector/cluster-settings.go +++ b/collector/cluster-settings.go @@ -66,16 +66,16 @@ func (c *ClusterSettingsCollector) Collect(ch chan<- prometheus.Metric) { path = "persistent.routing.allocation.total_shards_per_node" if _, ok := walk(settings, path); ok { - ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 1, "persistent") + ch <- prometheus.MustNewConstMetric(c.totalShardsPerNodeExists, prometheus.CounterValue, 1, "persistent") } else { - ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "persistent") + ch <- prometheus.MustNewConstMetric(c.totalShardsPerNodeExists, prometheus.CounterValue, 0, "persistent") } path = "transient.routing.allocation.total_shards_per_node" if _, ok := walk(settings, path); ok { - ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 1, "transient") + ch <- prometheus.MustNewConstMetric(c.totalShardsPerNodeExists, prometheus.CounterValue, 1, "transient") } else { - ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "transient") + ch <- prometheus.MustNewConstMetric(c.totalShardsPerNodeExists, prometheus.CounterValue, 0, "transient") } path = "persistent.cluster.max_shards_per_node" From 0a82b645e0722c5ecd9006823cc078495cba2fe9 Mon Sep 17 00:00:00 2001 From: "anton.voskresensky" Date: Wed, 4 Sep 2024 10:53:42 +0300 Subject: [PATCH 3/8] add metrics --- collector/cluster-settings.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/cluster-settings.go b/collector/cluster-settings.go index c2cb107..e98b5ac 100644 --- a/collector/cluster-settings.go +++ b/collector/cluster-settings.go @@ -27,7 +27,7 @@ func NewClusterSettingsCollector(logger *logrus.Logger, client *Client, labels, "Exclude exists in cluster settings", labels, constLabels, ), totalShardsPerNodeExists: prometheus.NewDesc( - prometheus.BuildFQName(namespace, "exclude", "exists"), + prometheus.BuildFQName(namespace, "total_shards_per_node", "exists"), "total_shards_per_node exists in cluster settings", labels, constLabels, ), maxShardsPerNode: prometheus.NewDesc( From d75a20bbe5a045f4111380cd8f36a25a930d99a3 Mon Sep 17 00:00:00 2001 From: "anton.voskresensky" Date: Wed, 4 Sep 2024 10:58:53 +0300 Subject: [PATCH 4/8] add metrics --- collector/cluster-settings.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/cluster-settings.go b/collector/cluster-settings.go index e98b5ac..4e82d6b 100644 --- a/collector/cluster-settings.go +++ b/collector/cluster-settings.go @@ -33,7 +33,7 @@ func NewClusterSettingsCollector(logger *logrus.Logger, client *Client, labels, maxShardsPerNode: prometheus.NewDesc( prometheus.BuildFQName(namespace, "clustersettings_stats", "max_shards_per_node"), "Current maximum number of shards per node setting.", - nil, nil, + labels, nil, ), } } From a64b9c2923154c866cfa8e145304ff40ae030be6 Mon Sep 17 00:00:00 2001 From: "anton.voskresensky" Date: Wed, 4 Sep 2024 11:04:48 +0300 Subject: [PATCH 5/8] add metrics --- collector/cluster-settings.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/collector/cluster-settings.go b/collector/cluster-settings.go index 4e82d6b..9ffe1e5 100644 --- a/collector/cluster-settings.go +++ b/collector/cluster-settings.go @@ -33,7 +33,7 @@ func NewClusterSettingsCollector(logger *logrus.Logger, client *Client, labels, maxShardsPerNode: prometheus.NewDesc( prometheus.BuildFQName(namespace, "clustersettings_stats", "max_shards_per_node"), "Current maximum number of shards per node setting.", - labels, nil, + labels, constLabels, ), } } @@ -88,15 +88,15 @@ func (c *ClusterSettingsCollector) Collect(ch chan<- prometheus.Metric) { if v, ok := count_transient.(string); ok { maxShardsPerNodeTransient, err := strconv.ParseInt(v, 10, 64) if err == nil { - ch <- prometheus.MustNewConstMetric(c.maxShardsPerNode, prometheus.GaugeValue, float64(maxShardsPerNodeTransient)) + ch <- prometheus.MustNewConstMetric(c.maxShardsPerNode, prometheus.GaugeValue, float64(maxShardsPerNodeTransient), "transient") } else { - ch <- prometheus.MustNewConstMetric(c.maxShardsPerNode, prometheus.GaugeValue, float64(maxShardsPerNode)) + ch <- prometheus.MustNewConstMetric(c.maxShardsPerNode, prometheus.GaugeValue, float64(maxShardsPerNode), "persistent") } } else { - ch <- prometheus.MustNewConstMetric(c.maxShardsPerNode, prometheus.GaugeValue, float64(maxShardsPerNode)) + ch <- prometheus.MustNewConstMetric(c.maxShardsPerNode, prometheus.GaugeValue, float64(maxShardsPerNode), "persistent") } } else { - ch <- prometheus.MustNewConstMetric(c.maxShardsPerNode, prometheus.GaugeValue, float64(maxShardsPerNode)) + ch <- prometheus.MustNewConstMetric(c.maxShardsPerNode, prometheus.GaugeValue, float64(maxShardsPerNode), "persistent") } } else { c.logger.Errorf("got invalid %q value: %#v", path, count) @@ -105,7 +105,7 @@ func (c *ClusterSettingsCollector) Collect(ch chan<- prometheus.Metric) { c.logger.Errorf("got invalid %q value: %#v", path, count) } } else { - ch <- prometheus.MustNewConstMetric(c.maxShardsPerNode, prometheus.GaugeValue, 1000.0) + ch <- prometheus.MustNewConstMetric(c.maxShardsPerNode, prometheus.GaugeValue, 1000.0, "default") } } From 9603e0999a4c0cdc05e3eea9ea0c59e3f9c2be6b Mon Sep 17 00:00:00 2001 From: "anton.voskresensky" Date: Wed, 4 Sep 2024 11:05:42 +0300 Subject: [PATCH 6/8] add metrics --- collector/cluster-settings.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/collector/cluster-settings.go b/collector/cluster-settings.go index 9ffe1e5..a73e6d3 100644 --- a/collector/cluster-settings.go +++ b/collector/cluster-settings.go @@ -32,8 +32,7 @@ func NewClusterSettingsCollector(logger *logrus.Logger, client *Client, labels, ), maxShardsPerNode: prometheus.NewDesc( prometheus.BuildFQName(namespace, "clustersettings_stats", "max_shards_per_node"), - "Current maximum number of shards per node setting.", - labels, constLabels, + "Current maximum number of shards per node setting.", labels, constLabels, ), } } From 9bff5eb8c233b7027e53fac1e21a0fd045baedb2 Mon Sep 17 00:00:00 2001 From: "anton.voskresensky" Date: Wed, 4 Sep 2024 11:13:06 +0300 Subject: [PATCH 7/8] add metrics --- collector/cluster-settings.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collector/cluster-settings.go b/collector/cluster-settings.go index a73e6d3..1d98d5e 100644 --- a/collector/cluster-settings.go +++ b/collector/cluster-settings.go @@ -63,14 +63,14 @@ func (c *ClusterSettingsCollector) Collect(ch chan<- prometheus.Metric) { ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "transient") } - path = "persistent.routing.allocation.total_shards_per_node" + path = "persistent.cluster..routing.allocation.total_shards_per_node" if _, ok := walk(settings, path); ok { ch <- prometheus.MustNewConstMetric(c.totalShardsPerNodeExists, prometheus.CounterValue, 1, "persistent") } else { ch <- prometheus.MustNewConstMetric(c.totalShardsPerNodeExists, prometheus.CounterValue, 0, "persistent") } - path = "transient.routing.allocation.total_shards_per_node" + path = "transient.cluster.routing.allocation.total_shards_per_node" if _, ok := walk(settings, path); ok { ch <- prometheus.MustNewConstMetric(c.totalShardsPerNodeExists, prometheus.CounterValue, 1, "transient") } else { From 9516276814eee3e55c16e4049fdc7954bb679ff8 Mon Sep 17 00:00:00 2001 From: "anton.voskresensky" Date: Wed, 4 Sep 2024 11:39:38 +0300 Subject: [PATCH 8/8] add metrics --- collector/cluster-settings.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/cluster-settings.go b/collector/cluster-settings.go index 1d98d5e..5e92e82 100644 --- a/collector/cluster-settings.go +++ b/collector/cluster-settings.go @@ -63,7 +63,7 @@ func (c *ClusterSettingsCollector) Collect(ch chan<- prometheus.Metric) { ch <- prometheus.MustNewConstMetric(c.excludeExists, prometheus.CounterValue, 0, "transient") } - path = "persistent.cluster..routing.allocation.total_shards_per_node" + path = "persistent.cluster.routing.allocation.total_shards_per_node" if _, ok := walk(settings, path); ok { ch <- prometheus.MustNewConstMetric(c.totalShardsPerNodeExists, prometheus.CounterValue, 1, "persistent") } else {