-
Notifications
You must be signed in to change notification settings - Fork 459
/
scrapeconfig.go
54 lines (50 loc) · 1.82 KB
/
scrapeconfig.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package controlplane
import (
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
monitoringv1alpha1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1alpha1"
"k8s.io/utils/ptr"
shootprometheus "github.com/gardener/gardener/pkg/component/observability/monitoring/prometheus/shoot"
monitoringutils "github.com/gardener/gardener/pkg/component/observability/monitoring/utils"
)
// ScrapeConfig returns the scrape configs related to the blackbox-exporter for the shoot control plane use-case.
func ScrapeConfig(namespace string, kubeAPIServerTarget monitoringv1alpha1.Target) []*monitoringv1alpha1.ScrapeConfig {
return []*monitoringv1alpha1.ScrapeConfig{{
ObjectMeta: monitoringutils.ConfigObjectMeta("blackbox-apiserver", namespace, shootprometheus.Label),
Spec: monitoringv1alpha1.ScrapeConfigSpec{
Params: map[string][]string{"module": {moduleName}},
MetricsPath: ptr.To("/probe"),
StaticConfigs: []monitoringv1alpha1.StaticConfig{{
Targets: []monitoringv1alpha1.Target{kubeAPIServerTarget},
}},
RelabelConfigs: []*monitoringv1.RelabelConfig{
{
TargetLabel: "type",
Replacement: "seed",
},
{
SourceLabels: []monitoringv1.LabelName{"__address__"},
TargetLabel: "__param_target",
Action: "replace",
},
{
SourceLabels: []monitoringv1.LabelName{"__param_target"},
TargetLabel: "instance",
Action: "replace",
},
{
TargetLabel: "__address__",
Replacement: "blackbox-exporter:9115",
Action: "replace",
},
{
Action: "replace",
Replacement: "blackbox-apiserver",
TargetLabel: "job",
},
},
},
}}
}