forked from GuyBarros/nomad_jobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprometheus.nomad.tpl
247 lines (221 loc) · 6.95 KB
/
prometheus.nomad.tpl
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
job "monitoring" {
datacenters = ["eu-west-1","eu-west-2","eu-west-3","ukwest","sa-east-1","ap-northeast-1","dc1"]
type = "service"
group "prometheus-grafana" {
count = 1
ephemeral_disk {
size = 300
}
vault {
policies = ["superuser"]
}
restart {
attempts = 0
mode = "fail"
}
# volume "prometheus_vol" {
# type = "host"
# config {
# source = "prometheus_mount"
# }
# }
task "prometheus" {
template {
change_mode = "noop"
destination = "local/prometheus.yml"
data = <<EOH
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
scrape_configs:
- job_name: 'nomad_metrics'
scheme: 'https'
tls_config:
insecure_skip_verify: true
consul_sd_configs:
- server: '{{ env "NOMAD_IP_prometheus_ui" }}:8500'
services: ['nomad-client']
relabel_configs:
- source_labels: ['__meta_consul_tags']
regex: '(.*)http(.*)'
action: keep
scrape_interval: 5s
metrics_path: /v1/metrics
params:
format: ['prometheus']
- job_name: 'consul_metrics'
scheme: 'http'
consul_sd_configs:
- server: '{{ env "NOMAD_IP_prometheus_ui" }}:8500'
services:
- 'consul'
scrape_interval: 5s
metrics_path: /v1/agent/metrics
params:
format: ['prometheus']
relabel_configs:
- source_labels: [__address__]
regex: ^(.*):(.*)$
target_label: __address__
replacement: $${1}:8500
- source_labels: [__meta_consul_node]
regex: (.*)
target_label: host
replacement: $${1}
# https://www.robustperception.io/extracting-labels-from-legacy-metric-names
metric_relabel_configs:
- source_labels: [__name__]
regex: '(consul_memberlist_tcp)_(.*)'
replacement: '$${2}'
target_label: type
- source_labels: [__name__]
regex: '(consul_memberlist_tcp)_(.*)'
replacement: '$${1}_count'
target_label: __name__
- source_labels: [__name__]
regex: '(consul_memberlist_udp)_(.*)'
replacement: '$${2}'
target_label: type
- source_labels: [__name__]
regex: '(consul_memberlist_udp)_(.*)'
replacement: '$${1}_count'
target_label: __name__
- source_labels: [__name__]
regex: '(consul_raft_replication_heartbeat)_(.+)(_\w?)?'
replacement: '$${2}'
target_label: query
- source_labels: [__name__]
regex: '(consul_raft_replication_heartbeat)_(.+)(_\w?)?'
replacement: '$${1}$${3}'
target_label: __name__
- source_labels: [__name__]
regex: '(consul_raft_replication_appendEntries_rpc)_(.+)(_\w?)?'
replacement: '$${2}'
target_label: query
- source_labels: [__name__]
regex: '(consul_raft_replication_appendEntries_rpc)_(.+)(_\w?)?'
replacement: '$${1}$${3}'
target_label: __name__
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'vault'
metrics_path: "/v1/sys/metrics"
scheme: "https"
tls_config:
insecure_skip_verify: true
params:
format: ['prometheus']
bearer_token: {{ env "VAULT_TOKEN" }}
static_configs:
- targets: ['active.vault.service.consul:8200']
# https://www.robustperception.io/extracting-labels-from-legacy-metric-names
metric_relabel_configs:
- source_labels: [__name__]
regex: '(vault_route)_(\w[^_]+)_(\w+)_count'
replacement: '$${2}'
target_label: method
- source_labels: [__name__]
regex: '(vault_route)_(\w[^_]+)_(\w+)_count'
replacement: '$${3}'
target_label: path
- source_labels: [__name__]
regex: '(vault_route)_(\w[^_]+)_(\w+)_count'
replacement: '$${1}_count'
target_label: __name__
EOH
}
driver = "docker"
# artifact {
# source = "https://raw.githubusercontent.com/GuyBarros/nomad_jobs/master/prometheus/prometheus.yml"
# destination = "/opt/prometheus/config"
# }
# docker run -p 9090:9090 -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml \prom/prometheus
config {
image = "prom/prometheus"
network_mode = "host"
args = [
"--web.external-url=${fabio_url}/prometheus",
"--web.route-prefix=/",
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.retention.size=150GB",
# # "--storage.tsdb.path=/opt/prometheus/data/"
]
volumes = [
"local/prometheus.yml:/etc/prometheus/prometheus.yml"
]
port_map {
prometheus = 9090
}
}
logs {
max_files = 5
max_file_size = 15
}
resources {
cpu = 500
memory = 512
network {
mbits = 10
port "prometheus" {
static = 9090
}
}
}
service {
name = "prometheus"
tags = ["urlprefix-/prometheus strip=/prometheus"]
port = "prometheus"
check {
name = "prometheus port alive"
type = "http"
path = "/-/healthy"
interval = "10s"
timeout = "2s"
}
}
}
task "grafana" {
driver = "docker"
meta {
FABIO_URL = "${fabio_srv}"
}
env {
"GF_SERVER_DOMAIN"="${fabio_srv}"
"GF_SERVER_ROOT_URL"="%(protocol)s://%(domain)s/grafana/"
"GF_DEFAULT_THEME"="light"
}
config {
image = "grafana/grafana"
network_mode = "host"
port_map {
http = 3000
}
}
logs {
max_files = 5
max_file_size = 15
}
resources {
cpu = 500
memory = 512
network {
mbits = 10
port "http" {
static = 3000
}
}
}
service {
name = "grafana"
tags = ["urlprefix-/grafana strip=/grafana"]
port = "http"
check {
type = "tcp"
interval = "10s"
timeout = "4s"
}
}
}
}
}