Skip to content

Commit

Permalink
pkg/cvo/metrics: Add a cluster_version_capability metric
Browse files Browse the repository at this point in the history
Fleet capability choices should make their way up to Red Hat via
Insights uploads.  But some clusters have Telemetry enabled but
Insights disabled [1].  For these clusters, we'll want this data in
Telemetry, and getting it into metrics (this commit) is the first
step.  After this lands, we'll need to update the monitoring operator
like [2] to get these shipped up off of cluster.

[1]: openshift/enhancements#922 (comment)
[2]: openshift/cluster-monitoring-operator#1477
  • Loading branch information
wking committed Mar 23, 2022
1 parent fc7d096 commit 60ee931
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/cvo/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type operatorMetrics struct {

version *prometheus.GaugeVec
availableUpdates *prometheus.GaugeVec
capability *prometheus.GaugeVec
clusterOperatorUp *prometheus.GaugeVec
clusterOperatorConditions *prometheus.GaugeVec
clusterOperatorConditionTransitions *prometheus.GaugeVec
Expand Down Expand Up @@ -87,6 +88,10 @@ version for 'cluster', or empty for 'initial'.
Name: "cluster_version_available_updates",
Help: "Report the count of available versions for an upstream and channel.",
}, []string{"upstream", "channel"}),
capability: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "cluster_version_capability",
Help: "Report currently enabled cluster capabilities. 0 is disabled, and 1 is enabled.",
}, []string{"name"}),
clusterOperatorUp: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "cluster_operator_up",
Help: "Reports key highlights of the active cluster operators.",
Expand Down Expand Up @@ -333,6 +338,7 @@ func (m *operatorMetrics) clusterOperatorChanged(oldObj, obj interface{}) {
func (m *operatorMetrics) Describe(ch chan<- *prometheus.Desc) {
ch <- m.version.WithLabelValues("", "", "", "").Desc()
ch <- m.availableUpdates.WithLabelValues("", "").Desc()
ch <- m.capability.WithLabelValues("").Desc()
ch <- m.clusterOperatorUp.WithLabelValues("", "").Desc()
ch <- m.clusterOperatorConditions.WithLabelValues("", "", "").Desc()
ch <- m.clusterOperatorConditionTransitions.WithLabelValues("", "").Desc()
Expand Down Expand Up @@ -432,6 +438,21 @@ func (m *operatorMetrics) Collect(ch chan<- prometheus.Metric) {
ch <- g
}

enabledCapabilities := make(map[configv1.ClusterVersionCapability]struct{}, len(cv.Status.Capabilites.EnabledCapabilities))
for _, capability := range cv.Status.Capabilites.EnabledCapabilities {
g := m.capability.WithLabelValues(string(capability))
g.Set(float64(1))
ch <- g
enabledCapabilities[capability] = struct{}{}
}
for _, capability := range cv.Status.Capabilites.KnownCapabilities {
if _, ok := enabledCapabilities[capability]; !ok {
g := m.capability.WithLabelValues(string(capability))
g.Set(float64(0))
ch <- g
}
}

for _, condition := range cv.Status.Conditions {
if condition.Status != configv1.ConditionFalse && condition.Status != configv1.ConditionTrue {
klog.V(2).Infof("skipping metrics for ClusterVersion condition %s=%s (neither True nor False)", condition.Type, condition.Status)
Expand Down

0 comments on commit 60ee931

Please sign in to comment.