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 7aebe9a0 [horus] Add pod cleaner indicator (#432)
7aebe9a0 is described below
commit 7aebe9a09538955fa593fe254852071718005d74
Author: mfordjody <[email protected]>
AuthorDate: Sun Oct 6 10:06:44 2024 +0800
[horus] Add pod cleaner indicator (#432)
---
app/horus/core/horuser/metrics.go | 47 +++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/app/horus/core/horuser/metrics.go
b/app/horus/core/horuser/metrics.go
index f0670973..d9845cd1 100644
--- a/app/horus/core/horuser/metrics.go
+++ b/app/horus/core/horuser/metrics.go
@@ -63,6 +63,21 @@ var (
"recovery_mark",
},
nil)
+ PodStagnativeInfo = prometheus.NewDesc(
+ "pod_stagnative_info",
+ "pod_stagnative_info",
+ []string{
+ "pod_name",
+ "pod_ip",
+ "node_name",
+ "cluster_name",
+ "module_name",
+ "reason",
+ "first_date",
+ "create_time",
+ "update_time",
+ },
+ nil)
)
func (h *Horuser) Collect(ch chan<- prometheus.Metric) {
@@ -117,6 +132,38 @@ func (h *Horuser) Collect(ch chan<- prometheus.Metric) {
}
nodeFunc()
+ podFunc := func() {
+ pods, err := db.GetPod()
+ if err != nil {
+ klog.Errorf("horus metrics collect db get pod err:%v",
err)
+ return
+ }
+ klog.Info("horus metrics collect db get pod success.")
+ if len(pods) == 0 {
+ klog.Infof("horus metrics collect db zero err:%v", err)
+ return
+ }
+ for _, v := range pods {
+ v := v
+ ct := v.CreateTime.Local().Format("2006-01-02 15:04:05")
+ ut := v.UpdateTime.Local().Format("2006-01-02 15:04:05")
+ p := prometheus.MustNewConstMetric(PodStagnativeInfo,
+ prometheus.GaugeValue, 1,
+ v.PodName,
+ v.PodIP,
+ v.NodeName,
+ v.ClusterName,
+ v.ModuleName,
+ v.Reason,
+ v.FirstDate,
+ ct,
+ ut,
+ )
+ ch <- p
+ }
+ }
+ podFunc()
+
for k, clusterName := range info {
s := strings.Split(k, ",")
feature, enabled := s[0], s[1]