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

feat: Add placement status metrics #1077

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

britaniar
Copy link
Contributor

@britaniar britaniar commented Mar 12, 2025

Description of your changes

Fixes #

I have: added a metric to emit crp condition status' along with a test.

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Special notes for your reviewer

@britaniar britaniar marked this pull request as ready for review March 12, 2025 23:28
@britaniar britaniar force-pushed the addEdgeMetrics branch 4 times, most recently from c25f067 to 42093bd Compare March 13, 2025 21:03
Copy link
Contributor

@zhiying-lin zhiying-lin left a comment

Choose a reason for hiding this comment

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

Should we emit the last condition if the crp is not completed? since your metrics type is gauge. WE only need to know the current status.

@@ -222,12 +223,12 @@ func (r *Reconciler) handleUpdate(ctx context.Context, crp *fleetv1beta1.Cluster
klog.V(2).InfoS("Placement has finished the rollout process and reached the desired status", "clusterResourcePlacement", crpKObj, "generation", crp.Generation)
r.Recorder.Event(crp, corev1.EventTypeNormal, "PlacementRolloutCompleted", "Placement has finished the rollout process and reached the desired status")
}
metrics.FleetPlacementStatus.WithLabelValues(crp.Name).Set(1)
metrics.FleetPlacementComplete.WithLabelValues(crp.Name).SetToCurrentTime()
Copy link
Contributor

Choose a reason for hiding this comment

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

i remember i never see people emit the cpu metrics with the timestamp. Could you please investigate how people create the gauge metrics?

Copy link
Contributor

Choose a reason for hiding this comment

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

I talked to Arvind about this too as my reaction was exactly the same "I never see people emit metrics with the timestamp" but it turned out there is actually a reason for this

Copy link
Contributor

Choose a reason for hiding this comment

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

the timestamp is there to help to setup alerts for "snapshot" instead of including all the history

return condition.IsConditionStatusTrue(crp.GetCondition(string(fleetv1beta1.ClusterResourcePlacementScheduledConditionType)), crp.Generation)
cond := crp.GetCondition(string(fleetv1beta1.ClusterResourcePlacementScheduledConditionType))
if cond != nil {
emitPlacementStatusMetric(cond, crp)
Copy link
Contributor

Choose a reason for hiding this comment

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

there are multiple ways to create the status metrics,

for example,
the label is, crp name, generation, value is status for that generation.

could you please investigate how others emit metrics?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if including the crp name can result in cardinality being too large?

@ryanzhang-oss
Copy link
Contributor

@britaniar britaniar force-pushed the addEdgeMetrics branch 2 times, most recently from e8afb26 to d7683e2 Compare March 29, 2025 00:31
cond := crp.GetCondition(string(fleetv1beta1.ClusterResourcePlacementScheduledConditionType))
if cond != nil {
metrics.FleetPlacementStatus.DeletePartialMatch(prometheus.Labels{"name": crp.Name})
metrics.FleetPlacementStatus.WithLabelValues(crp.Name, strconv.FormatInt(crp.Generation, 10), cond.Type, string(cond.Status)).SetToCurrentTime()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any thought on setting it as SetToCurrentTime() or Set(float(LastTransitionTime.Unixnano()))

Copy link
Contributor

Choose a reason for hiding this comment

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

it seems that SetToCurrentTime is a built-in? If so, I would prefer that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I will leave as is then.

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.

4 participants