Skip to content

Commit 14da437

Browse files
committed
operator: add topology metrics
This commit adds two new metrics providing the two topology modes, control plane and infrastructure respectively. Signed-off-by: Jan Fajerski <[email protected]>
1 parent e418548 commit 14da437

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

pkg/operator/configmetrics/configmetrics.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,27 @@ func Register(configInformer configinformers.SharedInformerFactory) {
3030
Name: "cluster_proxy_enabled",
3131
Help: "Reports whether the cluster has been configured to use a proxy. type is which type of proxy configuration has been set - http for an http proxy, https for an https proxy, and trusted_ca if a custom CA was specified.",
3232
}, []string{"type"}),
33+
controlPlaneTopology: prometheus.NewGaugeVec(prometheus.GaugeOpts{
34+
Name: "cluster_controlplane_topology",
35+
Help: "Reports the clusters expectations for operands that normally run on control plane nodes",
36+
}, []string{"mode"}),
37+
infrastructureTopology: prometheus.NewGaugeVec(prometheus.GaugeOpts{
38+
Name: "cluster_infrastructure_topology",
39+
Help: "Reports the clusters expectations for infrastructure operands that normally do not run on control plane nodes",
40+
}, []string{"mode"}),
3341
})
3442
}
3543

3644
// configMetrics implements metrics gathering for this component.
3745
type configMetrics struct {
38-
cloudProvider *prometheus.GaugeVec
39-
featureSet *prometheus.GaugeVec
40-
proxyEnablement *prometheus.GaugeVec
41-
infrastructureLister configlisters.InfrastructureLister
42-
featuregateLister configlisters.FeatureGateLister
43-
proxyLister configlisters.ProxyLister
46+
cloudProvider *prometheus.GaugeVec
47+
featureSet *prometheus.GaugeVec
48+
proxyEnablement *prometheus.GaugeVec
49+
controlPlaneTopology *prometheus.GaugeVec
50+
infrastructureTopology *prometheus.GaugeVec
51+
infrastructureLister configlisters.InfrastructureLister
52+
featuregateLister configlisters.FeatureGateLister
53+
proxyLister configlisters.ProxyLister
4454
}
4555

4656
func (m *configMetrics) Create(version *semver.Version) bool {
@@ -52,6 +62,8 @@ func (m *configMetrics) Describe(ch chan<- *prometheus.Desc) {
5262
ch <- m.cloudProvider.WithLabelValues("", "", "").Desc()
5363
ch <- m.featureSet.WithLabelValues("").Desc()
5464
ch <- m.proxyEnablement.WithLabelValues("").Desc()
65+
ch <- m.controlPlaneTopology.WithLabelValues("").Desc()
66+
ch <- m.infrastructureTopology.WithLabelValues("").Desc()
5567
}
5668

5769
// Returns external platform name if present, empty string otherwise
@@ -91,6 +103,16 @@ func (m *configMetrics) Collect(ch chan<- prometheus.Metric) {
91103
g.Set(value)
92104
ch <- g
93105
}
106+
{
107+
g := m.controlPlaneTopology.WithLabelValues(string(infra.Status.ControlPlaneTopology))
108+
g.Set(1)
109+
ch <- g
110+
}
111+
{
112+
g := m.infrastructureTopology.WithLabelValues(string(infra.Status.InfrastructureTopology))
113+
g.Set(1)
114+
ch <- g
115+
}
94116
}
95117
if features, err := m.featuregateLister.Get("cluster"); err == nil {
96118
ch <- booleanGaugeValue(

0 commit comments

Comments
 (0)