Added cluster mode metric
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user