Skip to content

Delete stale metrics on object delete#944

Merged
darkowlzz merged 1 commit intomainfrom
stale-metrics
Aug 14, 2023
Merged

Delete stale metrics on object delete#944
darkowlzz merged 1 commit intomainfrom
stale-metrics

Conversation

@darkowlzz
Copy link
Copy Markdown
Contributor

@darkowlzz darkowlzz commented Aug 10, 2023

Depends on fluxcd/pkg#612

The metrics helper now accepts owned finalizers to determine if an object is no longer managed by the controller and is being deleted, and deletes the metrics associated with the object.

Before this change, the following metrics continued to be exported even after the associated object is deleted:

gotk_reconcile_condition{kind="Kustomization",name="podinfo",namespace="default",status="False",type="Ready"} 0
gotk_reconcile_condition{kind="Kustomization",name="podinfo",namespace="default",status="True",type="Ready"} 1
gotk_reconcile_condition{kind="Kustomization",name="podinfo",namespace="default",status="Unknown",type="Ready"} 0
...
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="0.01"} 1
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="0.038363583488692544"} 1
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="0.1471764538093883"} 2
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="0.5646216173286169"} 2
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="2.166090855590701"} 2
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="8.309900738254731"} 2
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="31.879757075478317"} 2
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="122.30217221643493"} 2
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="469.19495946736544"} 2
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="1799.9999999999986"} 2
gotk_reconcile_duration_seconds_bucket{kind="Kustomization",name="podinfo",namespace="default",le="+Inf"} 2
gotk_reconcile_duration_seconds_sum{kind="Kustomization",name="podinfo",namespace="default"} 0.092792429
gotk_reconcile_duration_seconds_count{kind="Kustomization",name="podinfo",namespace="default"} 2
...
gotk_suspend_status{kind="Kustomization",name="podinfo",namespace="default"} 0

With this change, they get deleted once the associated object is deleted.

Also, the metrics helper no longer exports ConditionDelete for readiness metrics.

@darkowlzz darkowlzz added the enhancement New feature or request label Aug 10, 2023
@darkowlzz darkowlzz force-pushed the stale-metrics branch 5 times, most recently from 4cd1e13 to bda3ae6 Compare August 11, 2023 13:58
The metrics helper now accepts owned finalizers to determine if an
object is no longer managed by the controller and is being deleted, and
deletes the metrics associated with the object.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
@darkowlzz darkowlzz merged commit 385df67 into main Aug 14, 2023
@darkowlzz darkowlzz deleted the stale-metrics branch August 14, 2023 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants