forked from ernestas-poskus/ansible-prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prometheus_parse_config.rb
92 lines (84 loc) · 2.88 KB
/
prometheus_parse_config.rb
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
input = <<eos
--config.file="prometheus.yml"
Prometheus configuration file path.
--web.listen-address="0.0.0.0:9090"
Address to listen on for UI, API, and
telemetry.
--web.read-timeout=5m Maximum duration before timing out read of the
request, and closing idle connections.
--web.max-connections=512 Maximum number of simultaneous connections.
--web.external-url=<URL> The URL under which Prometheus is externally
reachable (for example, if Prometheus is served
via a reverse proxy). Used for generating
relative and absolute links back to Prometheus
itself. If the URL has a path portion, it will
be used to prefix all HTTP endpoints served by
Prometheus. If omitted, relevant URL components
will be derived automatically.
--web.route-prefix=<path> Prefix for the internal routes of web
endpoints. Defaults to path of --web.external-url.
--web.user-assets=<path> Path to static asset directory, available at
/user.
--web.enable-lifecycle Enable shutdown and reload via HTTP request.
--web.enable-admin-api Enables API endpoints for admin control
actions.
--web.console.templates="consoles"
Path to the console template directory,
available at /consoles.
--web.console.libraries="console_libraries"
Path to the console library directory.
--storage.tsdb.path="data/"
Base path for metrics storage.
--storage.tsdb.retention=15d
How long to retain samples in the storage.
--storage.tsdb.no-lockfile
Do not create lockfile in data directory.
--alertmanager.notification-queue-capacity=10000
The capacity of the queue for pending alert
manager notifications.
--alertmanager.timeout=10s
Timeout for sending alerts to Alertmanager.
--query.lookback-delta=5m The delta difference allowed for retrieving
metrics during expression evaluations.
--query.timeout=2m Maximum time a query may take before being
aborted.
--query.max-concurrency=20
Maximum number of queries executed
concurrently.
--log.level=info Only log messages with the given severity or above. One of: [debug, info, warn, error]
eos
PREFIX = 'prometheus'
puts '############################################################'
puts '# Auto generated'
puts '############################################################'
buffer = []
flags = []
input.each_line do |line|
line = line.chomp
next if line.empty?
if line.start_with?('--')
argument = line[2..line.size-1].split[0]
k = argument.split('=')
key = k.first
value = k.last
boolean_flag = key == value
adjusted_key = "#{PREFIX}_#{key.gsub('.', '__').gsub('-', '_')}"
if boolean_flag
if line =~ /: enabled/
flags << " - '#{key}'"
else
flags << "# - '#{key}' # disabled by default"
end
else
buffer << %Q( - ['#{key}', "{{ #{adjusted_key} }}"])
end
else
# buffer << "# #{line}"
end
end
puts buffer.sort.join("\n")
puts '', '', ''
puts "#{PREFIX}____enabled_flags:"
flags.sort.each do |bool|
puts bool
end