This is an automated email from the ASF dual-hosted git repository.
zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new 8041cb9c [horus] Add feature function indicator values (#428)
8041cb9c is described below
commit 8041cb9cfe52392f92b4b45f6be68c0bb221a56b
Author: mfordjody <[email protected]>
AuthorDate: Sat Oct 5 12:10:45 2024 +0800
[horus] Add feature function indicator values (#428)
---
app/horus/core/horuser/metrics.go | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/app/horus/core/horuser/metrics.go
b/app/horus/core/horuser/metrics.go
index d9688783..b5e666f1 100644
--- a/app/horus/core/horuser/metrics.go
+++ b/app/horus/core/horuser/metrics.go
@@ -16,14 +16,25 @@
package horuser
import (
+ "fmt"
"github.com/prometheus/client_golang/prometheus"
"strings"
)
var (
+ FeatureInfo = prometheus.NewDesc(
+ "horus_feature_info",
+ "Indicates the enabled status of specific features in different
clusters, with each feature represented by its name, enabled state, and
associated cluster name.",
+ []string{
+ "feature",
+ "enabled",
+ "cluster_name",
+ },
+ nil)
+
MultipleInfo = prometheus.NewDesc(
"horus_multiple_info",
- "horus_multiple_info",
+ "Tracks the Prometheus multiple addresses associated with
different clusters, providing visibility into the Prometheus endpoints used by
each cluster.",
[]string{
"cluster_name",
"prometheus_multiple_address",
@@ -40,10 +51,24 @@ func (h *Horuser) Collect(ch chan<- prometheus.Metric) {
return strings.Join(s, ",")
}
info := map[string]string{}
- buttons := map[bool]string{}
- modularKey := buttons[h.cc.CustomModular.Enabled]
+ buttons := map[bool]string{true: "Open", false: "Close"}
+
+ modularKey := fmt.Sprintf("custom modular,%s",
buttons[h.cc.CustomModular.Enabled])
info[modularKey] = kFunc(h.cc.CustomModular.KubeMultiple)
+ downtimeKey := fmt.Sprintf("node downtime,%s",
buttons[h.cc.NodeDownTime.Enabled])
+ info[downtimeKey] = kFunc(h.cc.NodeDownTime.KubeMultiple)
+ for k, clusterName := range info {
+ s := strings.Split(k, ",")
+ feature, enabled := s[0], s[1]
+ p := prometheus.MustNewConstMetric(FeatureInfo,
+ prometheus.GaugeValue, 1,
+ feature,
+ enabled,
+ clusterName,
+ )
+ ch <- p
+ }
for clusterName, address := range h.cc.PromMultiple {
p := prometheus.MustNewConstMetric(MultipleInfo,
prometheus.GaugeValue, 1,
@@ -55,5 +80,6 @@ func (h *Horuser) Collect(ch chan<- prometheus.Metric) {
}
func (h *Horuser) Describe(ch chan<- *prometheus.Desc) {
+ ch <- FeatureInfo
ch <- MultipleInfo
}