Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROX-22549: Remove excessive labels for the addon metric #1880

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 2 additions & 16 deletions internal/dinosaur/pkg/services/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (p *AddonProvisioner) Provision(cluster api.Cluster, dataplaneClusterConfig
}
if clusterInstallationDifferent(installedOnCluster, versionInstalledInOCM) {
multiErr = multierror.Append(multiErr, p.updateAddon(clusterID, expectedConfig))
p.updateAddonStatusMetric(dataplaneClusterConfig.ClusterName, installedOnCluster, versionInstalledInOCM, metrics.AddonUpgrade)
metrics.UpdateClusterAddonStatusMetric(installedOnCluster.ID, dataplaneClusterConfig.ClusterName, metrics.AddonUpgrade)
} else {
glog.V(10).Infof("Addon %s is already up-to-date", installedOnCluster.ID)
multiErr = validateUpToDateAddon(multiErr, installedInOCM, installedOnCluster)
p.updateAddonStatusMetric(dataplaneClusterConfig.ClusterName, installedOnCluster, versionInstalledInOCM, metrics.AddonUp)
metrics.UpdateClusterAddonStatusMetric(installedOnCluster.ID, dataplaneClusterConfig.ClusterName, metrics.AddonUp)
}
}

Expand All @@ -132,20 +132,6 @@ func (p *AddonProvisioner) Provision(cluster api.Cluster, dataplaneClusterConfig
return errorOrNil(multiErr)
}

func (p *AddonProvisioner) updateAddonStatusMetric(clusterName string, installedOnCluster dbapi.AddonInstallation, versionInstalledInOCM *clustersmgmtv1.AddOnVersion, status metrics.AddonStatus) {
metrics.UpdateClusterAddonStatusMetric(
installedOnCluster.ID,
clusterName,
versionInstalledInOCM.ID(),
versionInstalledInOCM.SourceImage(),
versionInstalledInOCM.PackageImage(),
installedOnCluster.Version,
installedOnCluster.SourceImage,
installedOnCluster.PackageImage,
status,
)
}

func validateUpToDateAddon(multiErr *multierror.Error, ocmInstallation *clustersmgmtv1.AddOnInstallation, dataPlaneInstallation dbapi.AddonInstallation) *multierror.Error {
if ocmInstallation.State() == clustersmgmtv1.AddOnInstallationStateFailed {
// addon is already up-to-date with gitops config and still failed
Expand Down
26 changes: 3 additions & 23 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ const (
LabelDatabaseQueryType = "query"
LabelRegion = "region"
LabelInstanceType = "instance_type"

labelAddonOCMVersion = "ocm_version"
labelAddonOCMSourceImage = "ocm_source_image"
labelAddonOCMPackageImage = "ocm_package_image"
labelAddonClusterVersion = "cluster_version"
labelAddonClusterSourceImage = "cluster_source_image"
labelAddonClusterPackageImage = "cluster_package_image"
)

// JobType metric to capture
Expand Down Expand Up @@ -184,12 +177,6 @@ var clusterStatusCapacityLabels = []string{
var clusterAddonStatusLabels = []string{
LabelID,
LabelClusterName,
labelAddonOCMVersion,
labelAddonOCMSourceImage,
labelAddonOCMPackageImage,
labelAddonClusterVersion,
labelAddonClusterSourceImage,
labelAddonClusterPackageImage,
}

// #### Metrics for Dataplane clusters - Start ####
Expand Down Expand Up @@ -749,17 +736,10 @@ var clusterAddonStatusMetric = prometheus.NewGaugeVec(
)

// UpdateClusterAddonStatusMetric updates ClusterAddonStatusMetric Metric
func UpdateClusterAddonStatusMetric(addonID, clusterName, ocmVersion, ocmSourceImage, ocmPackageImage,
clusterVersion, clusterSourceImage, clusterPackageImage string, status AddonStatus) {
func UpdateClusterAddonStatusMetric(addonID, clusterName string, status AddonStatus) {
labels := prometheus.Labels{
LabelID: addonID,
LabelClusterName: clusterName,
labelAddonOCMVersion: ocmVersion,
labelAddonOCMSourceImage: ocmSourceImage,
labelAddonOCMPackageImage: ocmPackageImage,
labelAddonClusterVersion: clusterVersion,
labelAddonClusterSourceImage: clusterSourceImage,
labelAddonClusterPackageImage: clusterPackageImage,
LabelID: addonID,
LabelClusterName: clusterName,
}
clusterAddonStatusMetric.With(labels).Set(float64(status))
}
Expand Down
Loading