Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.Capabilities.EnabledCapabilities))
for _, capability := range cv.Status.Capabilities.EnabledCapabilities {
g := m.capability.WithLabelValues(string(capability))
g.Set(float64(1))
ch <- g
enabledCapabilities[capability] = struct{}{}
}
for _, capability := range cv.Status.Capabilities.KnownCapabilities {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not clear on why we need to send known capabilities.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two use cases:

  • conditional updates using local PromQL can distinguish between "yeah, that cap is not enabled here" (value 0) and "err, something's broken with scraping this metrics" (no match)
  • Telemetry can gauge the install-fraction for a capability (countOfClustersWithCapEnabled / countOfClustersWithCapKnown). with count by (name) (cluster_version_capability == 1) / count by (name) (cluster_version_capability). If cluster_version_capability did not include known-but-not-enabled caps, you'd need some added filtering to get at countOfClustersWithCapKnown.

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