Skip to content

Commit f656dfe

Browse files
authored
[RHOAIENG-31975] - Onboard metrics to the centralized metrics platform (opendatahub-io#502)
chore: Add the `monitoring.opendatahub.io/scrape: "true"` annotation to Pod and Service monitors so the metrics can be collected by the Centralized RHOAI Observability platform. Signed-off-by: Spolti <fspolti@redhat.com>
1 parent 8024562 commit f656dfe

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

internal/controller/constants/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const (
3131
IstioSidecarInjectAnnotationName = "sidecar.istio.io/inject"
3232
KserveNetworkVisibility = "networking.kserve.io/visibility"
3333
KserveGroupAnnotation = "serving.kserve.io/inferenceservice"
34+
RhoaiObservabilityLabel = "monitoring.opendatahub.io/scrape"
3435

3536
EnableAuthODHAnnotation = "security.opendatahub.io/enable-auth"
3637
LabelAuthGroup = "security.opendatahub.io/authorization-group"

internal/controller/serving/reconcilers/kserve_istio_podmonitor_reconciler.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"context"
2020
"fmt"
2121

22+
"github.com/opendatahub-io/odh-model-controller/internal/controller/constants"
23+
2224
"github.com/go-logr/logr"
2325
kservev1beta1 "github.com/kserve/kserve/pkg/apis/serving/v1beta1"
2426
v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
@@ -84,6 +86,9 @@ func (r *KserveIstioPodMonitorReconciler) createDesiredResource(ctx context.Cont
8486
ObjectMeta: metav1.ObjectMeta{
8587
Name: istioPodMonitorName,
8688
Namespace: isvc.Namespace,
89+
Labels: map[string]string{
90+
constants.RhoaiObservabilityLabel: "true",
91+
},
8792
},
8893
Spec: v1.PodMonitorSpec{
8994
Selector: metav1.LabelSelector{

internal/controller/serving/reconcilers/kserve_metrics_service_reconciler.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/go-logr/logr"
2323
kservev1beta1 "github.com/kserve/kserve/pkg/apis/serving/v1beta1"
2424
"github.com/kserve/kserve/pkg/constants"
25-
constants2 "github.com/opendatahub-io/odh-model-controller/internal/controller/constants"
25+
odhconstants "github.com/opendatahub-io/odh-model-controller/internal/controller/constants"
2626
"github.com/opendatahub-io/odh-model-controller/internal/controller/utils"
2727
v1 "k8s.io/api/core/v1"
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -96,7 +96,8 @@ func (r *KserveRawMetricsServiceReconciler) createDesiredResource(ctx context.Co
9696
Name: getMetricsServiceName(isvc),
9797
Namespace: isvc.Namespace,
9898
Labels: map[string]string{
99-
"name": getMetricsServiceName(isvc),
99+
"name": getMetricsServiceName(isvc),
100+
odhconstants.RhoaiObservabilityLabel: "true",
100101
},
101102
},
102103
Spec: v1.ServiceSpec{
@@ -110,7 +111,7 @@ func (r *KserveRawMetricsServiceReconciler) createDesiredResource(ctx context.Co
110111
},
111112
Type: v1.ServiceTypeClusterIP,
112113
Selector: map[string]string{
113-
constants2.KserveGroupAnnotation: isvc.Name,
114+
odhconstants.KserveGroupAnnotation: isvc.Name,
114115
},
115116
},
116117
}

internal/controller/serving/reconcilers/kserve_metrics_servicemonitor_reconciler.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package reconcilers
1818
import (
1919
"context"
2020

21+
"github.com/opendatahub-io/odh-model-controller/internal/controller/constants"
22+
2123
"github.com/go-logr/logr"
2224
kservev1beta1 "github.com/kserve/kserve/pkg/apis/serving/v1beta1"
2325
"github.com/opendatahub-io/odh-model-controller/internal/controller/utils"
@@ -81,6 +83,9 @@ func (r *KserveRawMetricsServiceMonitorReconciler) createDesiredResource(ctx con
8183
ObjectMeta: metav1.ObjectMeta{
8284
Name: getMetricsServiceMonitorName(isvc),
8385
Namespace: isvc.Namespace,
86+
Labels: map[string]string{
87+
constants.RhoaiObservabilityLabel: "true",
88+
},
8489
},
8590
Spec: v1.ServiceMonitorSpec{
8691
Endpoints: []v1.Endpoint{

0 commit comments

Comments
 (0)