-
Notifications
You must be signed in to change notification settings - Fork 450
/
scrapeconfigs.go
75 lines (71 loc) · 2.4 KB
/
scrapeconfigs.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package seed
import (
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
monitoringv1alpha1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
monitoringutils "github.com/gardener/gardener/pkg/component/observability/monitoring/utils"
)
// CentralScrapeConfigs returns the central ScrapeConfig resources for the seed prometheus.
func CentralScrapeConfigs() []*monitoringv1alpha1.ScrapeConfig {
return []*monitoringv1alpha1.ScrapeConfig{
{
ObjectMeta: metav1.ObjectMeta{
Name: "prometheus",
},
Spec: monitoringv1alpha1.ScrapeConfigSpec{
RelabelConfigs: []*monitoringv1.RelabelConfig{{
Action: "replace",
Replacement: "prometheus",
TargetLabel: "job",
}},
StaticConfigs: []monitoringv1alpha1.StaticConfig{{
Targets: []monitoringv1alpha1.Target{"localhost:9090"},
}},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "cadvisor",
},
Spec: monitoringv1alpha1.ScrapeConfigSpec{
HonorLabels: ptr.To(true),
HonorTimestamps: ptr.To(false),
MetricsPath: ptr.To("/federate"),
Params: map[string][]string{
"match[]": {
`{job="cadvisor",namespace=~"extension-(.+)"}`,
`{job="cadvisor",namespace="garden"}`,
`{job="cadvisor",namespace=~"istio-(.+)"}`,
`{job="cadvisor",namespace="kube-system"}`,
},
},
StaticConfigs: []monitoringv1alpha1.StaticConfig{{
Targets: []monitoringv1alpha1.Target{"prometheus-cache.garden.svc"},
}},
RelabelConfigs: []*monitoringv1.RelabelConfig{{
Action: "replace",
Replacement: "cadvisor",
TargetLabel: "job",
}},
MetricRelabelConfigs: monitoringutils.StandardMetricRelabelConfig(
"container_cpu_cfs_periods_total",
"container_cpu_cfs_throttled_periods_total",
"container_cpu_cfs_throttled_seconds_total",
"container_cpu_usage_seconds_total",
"container_fs_inodes_total",
"container_fs_limit_bytes",
"container_fs_usage_bytes",
"container_last_seen",
"container_memory_working_set_bytes",
"container_network_receive_bytes_total",
"container_network_transmit_bytes_total",
"container_oom_events_total",
),
},
},
}
}