@@ -35,14 +35,14 @@ func BuildServiceMonitors(params manifestutils.Params) []client.Object {
35
35
36
36
func buildServiceMonitor (params manifestutils.Params , component string , port string ) * monitoringv1.ServiceMonitor {
37
37
labels := manifestutils .ComponentLabels (component , params .Tempo .Name )
38
- return NewServiceMonitor (params .Tempo .Namespace , params .Tempo .Name , labels , params .CtrlConfig .Gates .HTTPEncryption , component , port )
38
+ return NewServiceMonitor (params .Tempo .Namespace , params .Tempo .Name , labels , params .CtrlConfig .Gates .HTTPEncryption , component , [] string { port } )
39
39
}
40
40
41
41
func buildFrontEndServiceMonitor (params manifestutils.Params , port string ) * monitoringv1.ServiceMonitor {
42
42
labels := manifestutils .ComponentLabels (manifestutils .QueryFrontendComponentName , params .Tempo .Name )
43
43
tls := params .CtrlConfig .Gates .HTTPEncryption && params .Tempo .Spec .Template .Gateway .Enabled
44
44
return NewServiceMonitor (params .Tempo .Namespace , params .Tempo .Name , labels , tls ,
45
- manifestutils .QueryFrontendComponentName , port )
45
+ manifestutils .QueryFrontendComponentName , [] string { port } )
46
46
}
47
47
48
48
// NewServiceMonitor creates a ServiceMonitor.
@@ -52,7 +52,7 @@ func NewServiceMonitor(
52
52
labels labels.Set ,
53
53
tls bool ,
54
54
component string ,
55
- port string ,
55
+ ports [] string ,
56
56
) * monitoringv1.ServiceMonitor {
57
57
scheme := "http"
58
58
var tlsConfig * monitoringv1.TLSConfig
@@ -91,6 +91,30 @@ func NewServiceMonitor(
91
91
}
92
92
}
93
93
94
+ var endpoints []monitoringv1.Endpoint
95
+
96
+ for _ , port := range ports {
97
+ endpoints = append (endpoints , monitoringv1.Endpoint {
98
+ Scheme : scheme ,
99
+ Port : port ,
100
+ Path : "/metrics" ,
101
+ TLSConfig : tlsConfig ,
102
+ // Custom relabel configs to be compatible with predefined Tempo dashboards:
103
+ // https://grafana.com/docs/tempo/latest/operations/monitoring/#dashboards
104
+ RelabelConfigs : []* monitoringv1.RelabelConfig {
105
+ {
106
+ SourceLabels : []monitoringv1.LabelName {"__meta_kubernetes_service_label_app_kubernetes_io_instance" },
107
+ TargetLabel : "cluster" ,
108
+ },
109
+ {
110
+ SourceLabels : []monitoringv1.LabelName {"__meta_kubernetes_namespace" , "__meta_kubernetes_service_label_app_kubernetes_io_component" },
111
+ Separator : ptr .To ("/" ),
112
+ TargetLabel : "job" ,
113
+ },
114
+ },
115
+ })
116
+ }
117
+
94
118
return & monitoringv1.ServiceMonitor {
95
119
TypeMeta : metav1.TypeMeta {
96
120
APIVersion : monitoringv1 .SchemeGroupVersion .String (),
@@ -102,25 +126,7 @@ func NewServiceMonitor(
102
126
Labels : labels ,
103
127
},
104
128
Spec : monitoringv1.ServiceMonitorSpec {
105
- Endpoints : []monitoringv1.Endpoint {{
106
- Scheme : scheme ,
107
- Port : port ,
108
- Path : "/metrics" ,
109
- TLSConfig : tlsConfig ,
110
- // Custom relabel configs to be compatible with predefined Tempo dashboards:
111
- // https://grafana.com/docs/tempo/latest/operations/monitoring/#dashboards
112
- RelabelConfigs : []* monitoringv1.RelabelConfig {
113
- {
114
- SourceLabels : []monitoringv1.LabelName {"__meta_kubernetes_service_label_app_kubernetes_io_instance" },
115
- TargetLabel : "cluster" ,
116
- },
117
- {
118
- SourceLabels : []monitoringv1.LabelName {"__meta_kubernetes_namespace" , "__meta_kubernetes_service_label_app_kubernetes_io_component" },
119
- Separator : ptr .To ("/" ),
120
- TargetLabel : "job" ,
121
- },
122
- },
123
- }},
129
+ Endpoints : endpoints ,
124
130
NamespaceSelector : monitoringv1.NamespaceSelector {
125
131
MatchNames : []string {namespace },
126
132
},
0 commit comments