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

Add template invalidity metric #1242

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wahabmk
Copy link
Contributor

@wahabmk wahabmk commented Mar 20, 2025

Description

Add a metric to track currently invalid templates. Example:

# HELP kcm_template_invalidity Number of invalid templates
# TYPE kcm_template_invalidity gauge
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="aws-hosted-cp-0-1-5",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="aws-standalone-cp-0-1-5",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="azure-aks-0-1-1",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="azure-hosted-cp-0-1-5",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="azure-standalone-cp-0-1-5",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="docker-hosted-cp-0-1-3",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="gcp-hosted-cp-0-1-3",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="gcp-standalone-cp-0-1-3",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="openstack-standalone-cp-0-1-8",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="remote-cluster-0-1-3",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="vsphere-hosted-cp-0-1-5",template_namespace="kcm-system"} 1
kcm_template_invalidity{template_kind="ClusterTemplate",template_name="vsphere-standalone-cp-0-1-5",template_namespace="kcm-system"} 1

@wahabmk wahabmk self-assigned this Mar 20, 2025
@wahabmk wahabmk force-pushed the add_template_error_metrics branch 3 times, most recently from a3991aa to 9732c1b Compare March 20, 2025 14:29
@wahabmk wahabmk marked this pull request as ready for review March 20, 2025 19:21
@wahabmk wahabmk requested a review from BROngineer March 20, 2025 19:21
@wahabmk wahabmk force-pushed the add_template_error_metrics branch from e23d272 to 8a69093 Compare March 21, 2025 15:25
)
}

func TrackMetricTemplateUsageSet(ctx context.Context, templateKind, templateName, parentKind string, parent metav1.ObjectMeta) {
func TrackMetricTemplateUsageSet(ctx context.Context, templateKind, templateName, parentKind string, parent metav1.ObjectMeta, value float64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

a small suggestion to consider here and for the invalidity function: will it be ok to replace the value parameter with something inUse bool (and isInvalid bool), it'd mitigate potential misusage (highly likely the linter will fail and it is okay to disable it in this case with the nolint:<name> // false-positive)

let me know what you think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants