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

RHIROS-1221 Filter out and log Invalid recommendations on Prometheus #121

Closed
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
2 changes: 1 addition & 1 deletion internal/services/report_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func ProcessReport(msg *kafka.Message) {
continue
}

if kruize.Is_valid_recommendation(recommendation) {
if kruize.Is_valid_recommendation(recommendation, experiment_name) {
containers := recommendation[0].Kubernetes_objects[0].Containers
for _, container := range containers {
for _, v := range container.Recommendations.Data {
Expand Down
44 changes: 38 additions & 6 deletions internal/utils/kruize/kruize_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,46 @@ func Update_recommendations(experiment_name string, interval_end_time time.Time)

}

func Is_valid_recommendation(d []kruizePayload.ListRecommendations) bool {
func Is_valid_recommendation(d []kruizePayload.ListRecommendations, experiment_name string) bool {
if len(d) > 0 {

// To maintain a local reference the following map has been created from
// https://github.com/kruize/autotune/blob/master/design/NotificationCodes.md#detailed-codes
notificationCodeValidities := map[string]bool{
"112101": true,
"120001": false,
"221001": false,
"221002": false,
"221003": false,
"221004": false,
"223001": false,
"223002": false,
"223003": false,
"223004": false,
"224001": false,
"224002": false,
"224003": false,
"224004": false,
}

notifications := d[0].Kubernetes_objects[0].Containers[0].Recommendations.Notifications
// 112101 is notification code for "Duration Based Recommendations Available".
if _, ok := notifications["112101"]; ok {
return true
} else {
return false

for key := range notifications{
isValid, keyExists := notificationCodeValidities[key]
if !keyExists {
return false
}

if !isValid {
// Setting the metric counter to 1 as we expect a single metric
// for a combination of notification_code and experiment_name
kruizeInvalidRecommendation.WithLabelValues(key, experiment_name).Set(1)
return false
} else {
return true
}


}
}
return false
Expand Down
11 changes: 11 additions & 0 deletions internal/utils/kruize/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@ var (
[]string{"path"},
)
)


var (
kruizeInvalidRecommendation = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "rosocp_kruize_invalid_recommendation_detail",
Help: "List of INFO/ERROR type recommendations from Kruize",
},
[]string{"notification_code", "experiment_name"},
)
)
Loading