forked from thanos-io/kube-thanos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
all.jsonnet
258 lines (241 loc) · 8.72 KB
/
all.jsonnet
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
248
249
250
251
252
253
254
255
256
257
258
local t = import 'kube-thanos/thanos.libsonnet';
// THIS IS MERELY AN EXAMPLE MEANT TO SHOW HOW TO USE ALL COMPONENTS!
// Neither this example nor its manifests in examples/all/manifests/ are meant to ever be run.
local commonConfig = {
local cfg = self,
namespace: 'thanos',
version: 'v0.22.0',
image: 'quay.io/thanos/thanos:' + cfg.version,
replicaLabels: ['prometheus_replica', 'rule_replica'],
objectStorageConfig: {
name: 'thanos-objectstorage',
key: 'thanos.yaml',
},
resources: {
requests: { cpu: 0.123, memory: '123Mi' },
limits: { cpu: 0.420, memory: '420Mi' },
},
volumeClaimTemplate: {
spec: {
accessModes: ['ReadWriteOnce'],
resources: {
requests: {
storage: '10Gi',
},
},
},
},
// This enables jaeger tracing for all components, as commonConfig is shared
tracing+: {
type: 'JAEGER',
config+: {
sampler_type: 'ratelimiting',
sampler_param: 2,
},
},
};
local b = t.bucket(commonConfig {
replicas: 1,
label: 'cluster_name',
refresh: '5m',
// Example on how to overwrite the tracing config on a per component basis
// tracing+: {
// config+: {
// service_name: 'awesome-thanos-bucket',
// },
// },
});
local br = t.bucketReplicate(commonConfig {
replicas: 1,
// Use the same object storage secret as an example.
// Need to use another one in real cases.
objectStorageToConfig: {
name: 'thanos-objectstorage',
key: 'thanos.yaml',
},
compactionLevels: [1, 2, 3],
resolutions: ['0s'],
});
local c = t.compact(commonConfig {
replicas: 1,
serviceMonitor: true,
disableDownsampling: true,
deduplicationReplicaLabels: super.replicaLabels, // reuse same labels for deduplication
});
local cs = t.compactShards(commonConfig {
shards: 3,
sourceLabels: ['cluster'],
replicas: 1,
serviceMonitor: true,
disableDownsampling: true,
});
local re = t.receive(commonConfig {
replicas: 1,
replicationFactor: 1,
serviceMonitor: true,
hashringConfigMapName: 'hashring',
});
local ru = t.rule(commonConfig {
replicas: 1,
rulesConfig: [{ name: 'test', key: 'test' }],
alertmanagersURLs: ['alertmanager:9093'],
reloaderImage: 'jimmidyson/configmap-reload:v0.5.0',
serviceMonitor: true,
});
local sc = t.sidecar(commonConfig {
// namespace: 'monitoring',
serviceMonitor: true,
// Labels of the Prometheus pods with a Thanos Sidecar container
podLabelSelector: {
// Here it is the default label given by the prometheus-operator
// to all Prometheus pods
app: 'prometheus',
},
});
local s = t.store(commonConfig {
replicas: 1,
serviceMonitor: true,
bucketCache: {
type: 'memcached',
config+: {
// NOTICE: <MEMCACHED_SERVICE> is a placeholder to generate examples.
// List of memcached addresses, that will get resolved with the DNS service discovery provider.
// For DNS service discovery reference https://thanos.io/service-discovery.md/#dns-service-discovery
addresses: ['dnssrv+_client._tcp.<MEMCACHED_SERVICE>.%s.svc.cluster.local' % commonConfig.namespace],
},
},
indexCache: {
type: 'memcached',
config+: {
// NOTICE: <MEMCACHED_SERVICE> is a placeholder to generate examples.
// List of memcached addresses, that will get resolved with the DNS service discovery provider.
// For DNS service discovery reference https://thanos.io/service-discovery.md/#dns-service-discovery
addresses: ['dnssrv+_client._tcp.<MEMCACHED_SERVICE>.%s.svc.cluster.local' % commonConfig.namespace],
},
},
});
local q = t.query(commonConfig {
name: 'thanos-query',
replicas: 1,
externalPrefix: '',
resources: {},
queryTimeout: '5m',
autoDownsampling: true,
lookbackDelta: '15m',
ports: {
grpc: 10901,
http: 9090,
},
serviceMonitor: true,
logLevel: 'debug',
});
local finalRu = t.rule(ru.config {
queriers: ['dnssrv+_http._tcp.%s.%s.svc.cluster.local' % [q.service.metadata.name, q.service.metadata.namespace]],
});
local qf = t.queryFrontend(commonConfig {
replicas: 1,
downstreamURL: 'http://%s.%s.svc.cluster.local.:%d' % [
q.service.metadata.name,
q.service.metadata.namespace,
q.service.spec.ports[1].port,
],
splitInterval: '12h',
maxRetries: 10,
logQueriesLongerThan: '10s',
serviceMonitor: true,
queryRangeCache: {
type: 'memcached',
config+: {
// NOTICE: <MEMCACHED_SERVICE> is a placeholder to generate examples.
// List of memcached addresses, that will get resolved with the DNS service discovery provider.
// For DNS service discovery reference https://thanos.io/service-discovery.md/#dns-service-discovery
addresses: ['dnssrv+_client._tcp.<MEMCACHED_SERVICE>.%s.svc.cluster.local' % commonConfig.namespace],
},
},
labelsCache: {
type: 'memcached',
config+: {
// NOTICE: <MEMCACHED_SERVICE> is a placeholder to generate examples.
// List of memcached addresses, that will get resolved with the DNS service discovery provider.
// For DNS service discovery reference https://thanos.io/service-discovery.md/#dns-service-discovery
addresses: ['dnssrv+_client._tcp.<MEMCACHED_SERVICE>.%s.svc.cluster.local' % commonConfig.namespace],
},
},
});
local rcvs = t.receiveHashrings(commonConfig {
hashrings: [
{
hashring: 'default',
tenants: [],
},
{
hashring: 'region-1',
tenants: [],
},
],
replicas: 3,
replicationFactor: 2,
serviceMonitor: true,
hashringConfigMapName: 'hashring',
});
local strs = t.storeShards(commonConfig {
shards: 3,
replicas: 1,
serviceMonitor: true,
bucketCache: {
type: 'memcached',
config+: {
// NOTICE: <MEMCACHED_SERVICE> is a placeholder to generate examples.
// List of memcached addresses, that will get resolved with the DNS service discovery provider.
// For DNS service discovery reference https://thanos.io/service-discovery.md/#dns-service-discovery
addresses: ['dnssrv+_client._tcp.<MEMCACHED_SERVICE>.%s.svc.cluster.local' % commonConfig.namespace],
},
},
indexCache: {
type: 'memcached',
config+: {
// NOTICE: <MEMCACHED_SERVICE> is a placeholder to generate examples.
// List of memcached addresses, that will get resolved with the DNS service discovery provider.
// For DNS service discovery reference https://thanos.io/service-discovery.md/#dns-service-discovery
addresses: ['dnssrv+_client._tcp.<MEMCACHED_SERVICE>.%s.svc.cluster.local' % commonConfig.namespace],
},
},
});
local finalQ = t.query(q.config {
stores: [
'dnssrv+_grpc._tcp.%s.%s.svc.cluster.local' % [service.metadata.name, service.metadata.namespace]
for service in [re.service, ru.service, sc.service, s.service] +
[rcvs.hashrings[hashring].service for hashring in std.objectFields(rcvs.hashrings)] +
[strs.shards[shard].service for shard in std.objectFields(strs.shards)]
],
});
{ ['thanos-bucket-' + name]: b[name] for name in std.objectFields(b) if b[name] != null } +
{ ['thanos-bucket-replicate-' + name]: br[name] for name in std.objectFields(br) if br[name] != null } +
{ ['thanos-compact-' + name]: c[name] for name in std.objectFields(c) if c[name] != null } +
{
['thanos-compact-' + shard + '-' + name]: cs.shards[shard][name]
for shard in std.objectFields(cs.shards)
for name in std.objectFields(cs.shards[shard])
if cs.shards[shard][name] != null
} +
{ ['thanos-receive-' + name]: re[name] for name in std.objectFields(re) if re[name] != null } +
{ ['thanos-rule-' + name]: finalRu[name] for name in std.objectFields(finalRu) if finalRu[name] != null } +
{ ['thanos-sidecar-' + name]: sc[name] for name in std.objectFields(sc) if sc[name] != null } +
{ ['thanos-store-' + name]: s[name] for name in std.objectFields(s) if s[name] != null } +
{ ['thanos-query-' + name]: finalQ[name] for name in std.objectFields(finalQ) if finalQ[name] != null } +
{ ['thanos-query-frontend-' + name]: qf[name] for name in std.objectFields(qf) if qf[name] != null } +
{
['thanos-receive-' + hashring + '-' + name]: rcvs.hashrings[hashring][name]
for hashring in std.objectFields(rcvs.hashrings)
for name in std.objectFields(rcvs.hashrings[hashring])
if rcvs.hashrings[hashring][name] != null
} +
{
['thanos-store-' + shard + '-' + name]: strs.shards[shard][name]
for shard in std.objectFields(strs.shards)
for name in std.objectFields(strs.shards[shard])
if strs.shards[shard][name] != null
} +
{ ['thanos-compact-shards-' + name]: cs[name] for name in std.objectFields(cs) if name != 'shards' && cs[name] != null } +
{ ['thanos-receive-hashrings-' + name]: rcvs[name] for name in std.objectFields(rcvs) if name != 'hashrings' && rcvs[name] != null } +
{ ['thanos-store-shards-' + name]: strs[name] for name in std.objectFields(strs) if name != 'shards' && strs[name] != null }