forked from grafana/k8s-monitoring-helm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalloy-metrics.alloy
147 lines (136 loc) · 3.89 KB
/
alloy-metrics.alloy
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Destination: prometheus (prometheus)
otelcol.exporter.prometheus "prometheus" {
add_metric_suffixes = true
forward_to = [prometheus.remote_write.prometheus.receiver]
}
prometheus.remote_write "prometheus" {
endpoint {
url = "http://prometheus.prometheus.svc:9090/api/v1/write"
headers = {
"X-Scope-OrgID" = convert.nonsensitive(remote.kubernetes.secret.prometheus.data["tenantId"]),
}
basic_auth {
username = convert.nonsensitive(remote.kubernetes.secret.prometheus.data["prom-username"])
password = remote.kubernetes.secret.prometheus.data["access-token"]
}
tls_config {
insecure_skip_verify = false
ca_pem = convert.nonsensitive(remote.kubernetes.secret.prometheus.data["ca"])
cert_pem = convert.nonsensitive(remote.kubernetes.secret.prometheus.data["cert"])
key_pem = remote.kubernetes.secret.prometheus.data["key"]
}
send_native_histograms = false
queue_config {
capacity = 10000
min_shards = 1
max_shards = 50
max_samples_per_send = 2000
batch_send_deadline = "5s"
min_backoff = "30ms"
max_backoff = "5s"
retry_on_http_429 = true
sample_age_limit = "0s"
}
write_relabel_config {
source_labels = ["cluster"]
regex = ""
replacement = "external-secrets-example-cluster"
target_label = "cluster"
}
write_relabel_config {
source_labels = ["k8s.cluster.name"]
regex = ""
replacement = "external-secrets-example-cluster"
target_label = "cluster"
}
}
wal {
truncate_frequency = "2h"
min_keepalive_time = "5m"
max_keepalive_time = "8h"
}
}
remote.kubernetes.secret "prometheus" {
name = "my-monitoring-secret"
namespace = "monitoring"
}
// Feature: Prometheus Operator Objects
declare "prometheus_operator_objects" {
argument "metrics_destinations" {
comment = "Must be a list of metric destinations where collected metrics should be forwarded to"
}
// Prometheus Operator PodMonitor objects
prometheus.operator.podmonitors "pod_monitors" {
clustering {
enabled = true
}
scrape {
default_scrape_interval = "60s"
}
forward_to = argument.metrics_destinations.value
}
// Prometheus Operator Probe objects
prometheus.operator.probes "probes" {
clustering {
enabled = true
}
scrape {
default_scrape_interval = "60s"
}
forward_to = argument.metrics_destinations.value
}
// Prometheus Operator ServiceMonitor objects
prometheus.operator.servicemonitors "service_monitors" {
clustering {
enabled = true
}
scrape {
default_scrape_interval = "60s"
}
forward_to = argument.metrics_destinations.value
}
}
prometheus_operator_objects "feature" {
metrics_destinations = [
prometheus.remote_write.prometheus.receiver,
]
}
// Self Reporting
prometheus.exporter.unix "kubernetes_monitoring_telemetry" {
set_collectors = ["textfile"]
textfile {
directory = "/etc/alloy"
}
}
discovery.relabel "kubernetes_monitoring_telemetry" {
targets = prometheus.exporter.unix.kubernetes_monitoring_telemetry.targets
rule {
target_label = "instance"
action = "replace"
replacement = "k8smon"
}
rule {
target_label = "job"
action = "replace"
replacement = "integrations/kubernetes/kubernetes_monitoring_telemetry"
}
}
prometheus.scrape "kubernetes_monitoring_telemetry" {
job_name = "integrations/kubernetes/kubernetes_monitoring_telemetry"
targets = discovery.relabel.kubernetes_monitoring_telemetry.output
scrape_interval = "60s"
clustering {
enabled = true
}
forward_to = [prometheus.relabel.kubernetes_monitoring_telemetry.receiver]
}
prometheus.relabel "kubernetes_monitoring_telemetry" {
rule {
source_labels = ["__name__"]
regex = "grafana_kubernetes_monitoring_.*"
action = "keep"
}
forward_to = [
prometheus.remote_write.prometheus.receiver,
]
}