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

Introduce MR metrics #1281

Merged
merged 1 commit into from
Apr 25, 2024
Merged

Introduce MR metrics #1281

merged 1 commit into from
Apr 25, 2024

Conversation

mergenci
Copy link
Collaborator

@mergenci mergenci commented Apr 22, 2024

Description of your changes

Consume crossplane/crossplane-runtime#683 and crossplane/upjet#390.

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

I used the following configuration and followed the steps below:

apiVersion: ec2.aws.upbound.io/v1beta1
kind: VPC
metadata:
  name: test-pr-1281-vpc
spec:
  forProvider:
    region: us-west-1
    cidrBlock: 172.16.0.0/16
    tags:
      Name: test-pr-1281-vpc
  1. Before applying the configuration, visit :8080/metrics and check that no metrics with prefix “managed_resource” are reported.
  2. Apply the configuration: kubectl apply -f vpc.yaml
  3. Upon successful creation, relevant metrics should look like below:
# HELP crossplane_managed_resource_exists The number of managed resources that exist
# TYPE crossplane_managed_resource_exists gauge
crossplane_managed_resource_exists{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 1
# HELP crossplane_managed_resource_first_time_to_readiness_seconds The time it took for a managed resource to become ready first time after creation
# TYPE crossplane_managed_resource_first_time_to_readiness_seconds histogram
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1"} 0
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="5"} 0
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="10"} 0
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="15"} 1
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="30"} 1
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="60"} 1
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="120"} 1
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="300"} 1
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="600"} 1
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1800"} 1
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="3600"} 1
crossplane_managed_resource_first_time_to_readiness_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="+Inf"} 1
crossplane_managed_resource_first_time_to_readiness_seconds_sum{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 11.314458
crossplane_managed_resource_first_time_to_readiness_seconds_count{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 1
# HELP crossplane_managed_resource_first_time_to_reconcile_seconds The time it took for a managed resource to be detected by the controller
# TYPE crossplane_managed_resource_first_time_to_reconcile_seconds histogram
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1e-08"} 0
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1e-07"} 0
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1e-06"} 0
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="9.999999999999999e-06"} 0
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="9.999999999999999e-05"} 0
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="0.001"} 0
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="0.01"} 0
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="0.1"} 0
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1"} 1
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="10"} 1
crossplane_managed_resource_first_time_to_reconcile_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="+Inf"} 1
crossplane_managed_resource_first_time_to_reconcile_seconds_sum{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 0.174357
crossplane_managed_resource_first_time_to_reconcile_seconds_count{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 1
# HELP crossplane_managed_resource_ready The number of managed resources in Ready=True state
# TYPE crossplane_managed_resource_ready gauge
crossplane_managed_resource_ready{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 1
# HELP crossplane_managed_resource_synced The number of managed resources in Synced=True state
# TYPE crossplane_managed_resource_synced gauge
crossplane_managed_resource_synced{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 1
  1. Edit the resource, add a tag for example, to introduce a drift: kubectl edit vpc.ec2.aws.upbound.io/test-pr-1281-vpc. Upon reconciliation, crossplane_managed_resource_drift_seconds should appear:
# HELP crossplane_managed_resource_drift_seconds ALPHA: How long since the previous successful reconcile when a resource was found to be out of sync; excludes restart of the provider
# TYPE crossplane_managed_resource_drift_seconds histogram
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1e-08"} 0
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1e-07"} 0
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1e-06"} 0
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="9.999999999999999e-06"} 0
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="9.999999999999999e-05"} 0
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="0.001"} 0
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="0.01"} 0
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="0.1"} 0
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1"} 0
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="10"} 0
crossplane_managed_resource_drift_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="+Inf"} 1
crossplane_managed_resource_drift_seconds_sum{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 65.694694333
crossplane_managed_resource_drift_seconds_count{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 1
  1. Finally, delete the resource, to observe crossplane_managed_resource_deletion_seconds: kubectl delete vpc.ec2.aws.upbound.io/test-pr-1281-vpc.
# HELP crossplane_managed_resource_deletion_seconds The time it took for a managed resource to be deleted
# TYPE crossplane_managed_resource_deletion_seconds histogram
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1"} 0
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="5"} 0
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="10"} 1
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="15"} 1
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="30"} 1
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="60"} 1
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="120"} 1
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="300"} 1
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="600"} 1
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="1800"} 1
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="3600"} 1
crossplane_managed_resource_deletion_seconds_bucket{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC",le="+Inf"} 1
crossplane_managed_resource_deletion_seconds_sum{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 5.061364
crossplane_managed_resource_deletion_seconds_count{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 1

Note that because of a known issue in the draft crossplane-runtime PR, MR status metrics are not set to zero after resource deletion:

# HELP crossplane_managed_resource_exists The number of managed resources that exist
# TYPE crossplane_managed_resource_exists gauge
crossplane_managed_resource_exists{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 1
# HELP crossplane_managed_resource_ready The number of managed resources in Ready=True state
# TYPE crossplane_managed_resource_ready gauge
crossplane_managed_resource_ready{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 1
# HELP crossplane_managed_resource_synced The number of managed resources in Synced=True state
# TYPE crossplane_managed_resource_synced gauge
crossplane_managed_resource_synced{gvk="ec2.aws.upbound.io/v1beta1, Kind=VPC"} 1

@mergenci
Copy link
Collaborator Author

/test-examples="examples/iam/v1beta1/role.yaml"

Signed-off-by: Cem Mergenci <cmergenci@gmail.com>
@mergenci
Copy link
Collaborator Author

/test-examples="examples/ec2/v1beta1/securitygroupingressrule.yaml"

@mergenci mergenci marked this pull request as ready for review April 25, 2024 13:06
Copy link
Collaborator

@ulucinar ulucinar left a comment

Choose a reason for hiding this comment

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

Thank you @mergenci, lgtm.

@ulucinar ulucinar merged commit 58c7765 into crossplane-contrib:main Apr 25, 2024
12 checks passed
@mergenci mergenci deleted the mr-metrics branch April 25, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants