prometheus-config-builder 0.0.14 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f53abe032d06ebd5bb1f7e3de65c857876deb2ee
|
4
|
+
data.tar.gz: 5e502f110bc4e81099f5ce7916db894a4326460a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52273db6b4f606ddd847992afd93900e67d373e3a40ca1bedf45e4ae9ebff96e42e23f4ab5e1e8781f31029e8ec1af4c93812aeb41f9d1143cf7e618c6e3c481
|
7
|
+
data.tar.gz: '099c08f29fd50c904cfebc3724df3a92f57581fb10f1bdf5584d6e687062e202b0f7a4e5d695bf55f7c7e6e04bee39ed63b4ad0aeb2a45f9068dc492cde1a5b9'
|
@@ -39,7 +39,7 @@ op = OptionParser.new do |o|
|
|
39
39
|
config[:verbose] = true
|
40
40
|
end
|
41
41
|
o.on('--every=[seconds]', 'Rerun every n seconds') do |seconds|
|
42
|
-
config[:every] = seconds
|
42
|
+
config[:every] = seconds.to_i
|
43
43
|
end
|
44
44
|
o.on('--pgrep=[string]', 'pgrep -f [string] for finding Prometheus process for SIGHUP') do |str|
|
45
45
|
config[:pgrep] = str
|
@@ -52,7 +52,7 @@ if config[:verbose]
|
|
52
52
|
end
|
53
53
|
|
54
54
|
abort "You need to set --prometheus-src" if !config[:prometheus_src]
|
55
|
-
abort "You need to set --
|
55
|
+
abort "You need to set --dst-dir" if !config[:dst_dir]
|
56
56
|
|
57
57
|
log = Logger.new(STDOUT)
|
58
58
|
log.level = config[:verbose] ? Logger::DEBUG : Logger::INFO
|
@@ -75,12 +75,14 @@ something_changed_count = PrometheusExporter::Client.default.register(:counter,
|
|
75
75
|
error_count = PrometheusExporter::Client.default.register(:counter, "prometheusconfigbuilder_errors_count", "Number of exceptions during evaluation.")
|
76
76
|
iteration_count = PrometheusExporter::Client.default.register(:counter, "prometheusconfigbuilder_iteration_count", "Number of times configuration has changed.")
|
77
77
|
iteration_duration = PrometheusExporter::Client.default.register(:gauge, "prometheusconfigbuilder_last_iteration_duration", "Duration (in seconds) of the last full config iteration")
|
78
|
+
config_has_errors = PrometheusExporter::Client.default.register(:gauge, "prometheusconfigbuilder_config_has_errors", "This value is 0 if the config has no errors.")
|
78
79
|
|
79
80
|
error_count.observe(0)
|
80
81
|
|
81
82
|
builder = PrometheusConfigBuilder::Builder.new(config[:prometheus_src], config[:dst_dir])
|
82
83
|
|
83
84
|
config[:paths].each do |path|
|
85
|
+
log.info("Adding path #{path} to config discovery list")
|
84
86
|
builder.add_path(path)
|
85
87
|
end
|
86
88
|
|
@@ -89,7 +91,9 @@ loop do
|
|
89
91
|
starting = Time.now
|
90
92
|
begin
|
91
93
|
something_changed = builder.write_out()
|
94
|
+
config_has_errors.observe(0)
|
92
95
|
rescue Exception => e
|
96
|
+
config_has_errors.observe(1)
|
93
97
|
log.warn("Error while building config: #{e}")
|
94
98
|
puts e.backtrace
|
95
99
|
error_count.increment
|
@@ -103,10 +107,16 @@ loop do
|
|
103
107
|
# Send a SIGHUP signal to Prometheus so that it knows to reload config files
|
104
108
|
begin
|
105
109
|
if something_changed && config[:pgrep] != nil
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
+
matches = `pgrep -a -f "#{config[:pgrep]}"`.split("\n")
|
111
|
+
match = matches.select {|e| !e.include?("prometheus-config-builder")}
|
112
|
+
if !match
|
113
|
+
log.warn("Unable to find Prometheus instance to send SIGHUP for. Matches object: #{matches}")
|
114
|
+
else
|
115
|
+
pid = match.first.split(" ").first.to_i
|
116
|
+
if pid
|
117
|
+
log.info("Sending SIGHUP signal to Prometheus at pid #{pid}.")
|
118
|
+
Process.kill "HUP", pid
|
119
|
+
end
|
110
120
|
end
|
111
121
|
end
|
112
122
|
rescue Exception => e
|
@@ -217,7 +217,7 @@ module PrometheusConfigBuilder
|
|
217
217
|
files = []
|
218
218
|
@paths.each do |path|
|
219
219
|
found_files = @discoverer.discover(path)
|
220
|
-
logger.info("Found #{
|
220
|
+
logger.info("Found #{found_files.length} files from path #{path}")
|
221
221
|
files.push(*found_files)
|
222
222
|
end
|
223
223
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-config-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juho Mäkinen juho.makinen@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.5.2
|
140
|
+
rubygems_version: 2.5.2.3
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Template based config generation
|