Added cluster mode metric
Build Docker image on push / docker (push) Successful in 22s
Build and push Docker image on tag / docker (push) Successful in 22s

This commit is contained in:
2026-08-17 21:29:09 +02:00
parent c4287c37bc
commit e5a5e6416b
4 changed files with 59 additions and 4 deletions
+16 -3
View File
@@ -12,8 +12,9 @@ type PveClusterStateCollector struct {
apiClient *proxmox.PveApiClient // PVE API client instance.
registry *TTLRegistry // TTL metrics registry.
nodes *TTLGaugeVec // Count of nodes prometheus gauge.
quorate *TTLGaugeVec // Cluster quorum state prometheus gauge.
nodes *TTLGaugeVec // Count of nodes prometheus gauge.
quorate *TTLGaugeVec // Cluster quorum state prometheus gauge.
clusterMode *TTLGaugeVec // PVE cluster mode prometheus gauge.
}
// Create new instance of PVE cluster state collector.
@@ -42,6 +43,17 @@ func NewPveClusterStateCollector(apiClient *proxmox.PveApiClient, registry *TTLR
5*time.Minute,
)
c.registry.Register(c.quorate)
// PVE cluster mode gauge.
c.clusterMode = NewTTLGaugeVec(
prometheus.GaugeOpts{
Name: "pve_cluster_mode",
Help: "PVE cluster mode (1 = cluster, 0 = standalone node).",
},
[]string{"cluster"},
5*time.Minute,
)
c.registry.Register(c.clusterMode)
c.registry.StartCleanupLoop(5 * time.Second)
return &c
@@ -54,9 +66,10 @@ func (c *PveClusterStateCollector) CollectMetrics() error {
return err
}
l := prometheus.Labels{"cluster": cluster.Name}
l := prometheus.Labels{"cluster": cluster.GetClusterName()}
c.nodes.With(l).Set(float64(cluster.Nodes))
c.quorate.With(l).Set(float64(cluster.Quorate))
c.clusterMode.With(l).Set(cluster.GetClusterModeNumeric())
return nil
}