-
Notifications
You must be signed in to change notification settings - Fork 2
/
example-generator.py
56 lines (46 loc) · 1.4 KB
/
example-generator.py
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
#!/usr/bin/env python
import yaml
import promgen_k8s as g
from promgen_k8s.prom_dsl import *
CLUSTERS = [
g.Cluster('staging', jobs=[
g.NodesJob(),
g.IngressesJob(),
g.CadvisorJob(),
g.ServiceEndpointsJob(),
g.ServicesJob(additional_relabel_configs=[
# reverse.default.svc:443 should prompt for authentication in staging environment
replace(source_labels=['__param_target'],
regex='reverse.default.svc:443', replacement='https_401',
target_label='__param_module')
]),
g.PodsJob()
]),
g.Cluster('production', jobs=[
g.NodesJob(),
g.IngressesJob(),
g.CadvisorJob(),
g.ServiceEndpointsJob(),
g.ServicesJob(),
g.PodsJob()
]),
# The incluster property marks the cluster in which Prometheus in running
g.Cluster('operations', incluster=True, jobs=[
g.NodesJob(),
g.IngressesJob(),
g.CadvisorJob(),
g.ServiceEndpointsJob(),
g.ServicesJob(),
g.PodsJob(interval_map={'long': '1h'})
])
] # yapf: disable
def main() -> None:
# read in the stub config
with open('example-prometheus-stub.yml', 'r') as stub_file:
stub_prom_conf = yaml.load(stub_file, Loader=yaml.SafeLoader)
generator = g.Generator(CLUSTERS, initial_prom_conf=stub_prom_conf)
# write out merged result
with open('example-prometheus.yml', 'w') as final_file:
generator.dump(final_file)
if __name__ == "__main__":
main()