prometheus-config-builder 0.0.15 → 0.0.21

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: 8afb279bd7ee0d2f9e233c0224bef803b9694054
4
- data.tar.gz: 4af2db65c94a80667f8125fd425d5132e627c550
3
+ metadata.gz: 4d84c84caac7f0380510bf269507555f04be391e
4
+ data.tar.gz: b9220355ba8986d22711ec49365f885cb374c8ae
5
5
  SHA512:
6
- metadata.gz: 87e8783a009b784505acaebbacc977b95d70b9785fa603e1d6acb9274743d1a07b1c166ae016863d13094b13e2fbe7f963cb21d8e2debfc3ae237ea53bd595eb
7
- data.tar.gz: c154ff88582bd2270e2f7bb7cbf91fea11c36e5383168580fd87d26d06d9127cfa1445b8889e25f6bf8744724dc735ef8380a069dc45360d20f3cfa8cdafc935
6
+ metadata.gz: 36fbaf95d4db081453a29f6aac99a26ece35e66501297664843bc4d9a88a697ab736da051d5ba4763d95d43515dc5bac74bf67b28906c39f9bb80b1cbefc795c
7
+ data.tar.gz: f599a9aebffb8d5ac632824590824abc812fb522640a6cb196e31a166bc8a6c49e89ddbe5427d1e3f27dcab5213588336efaee50d03b7a80cba44e9d6ef9fd0d
@@ -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 --dst_dir" if !config[:dst_dir]
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,6 +75,7 @@ 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
 
@@ -90,7 +91,9 @@ loop do
90
91
  starting = Time.now
91
92
  begin
92
93
  something_changed = builder.write_out()
94
+ config_has_errors.observe(0)
93
95
  rescue Exception => e
96
+ config_has_errors.observe(1)
94
97
  log.warn("Error while building config: #{e}")
95
98
  puts e.backtrace
96
99
  error_count.increment
@@ -104,10 +107,16 @@ loop do
104
107
  # Send a SIGHUP signal to Prometheus so that it knows to reload config files
105
108
  begin
106
109
  if something_changed && config[:pgrep] != nil
107
- pid = `pgrep -f "#{config[:pgrep]}"`.split("\n").first.to_i
108
- if pid
109
- log.info("Sending SIGHUP signal to Prometheus at pid #{pid}.")
110
- Process.kill "HUP", pid
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
111
120
  end
112
121
  end
113
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 #{files.length} files from path #{path}")
220
+ logger.info("Found #{found_files.length} files from path #{path}")
221
221
  files.push(*found_files)
222
222
  end
223
223
 
@@ -70,7 +70,7 @@ module PrometheusConfigBuilder
70
70
  tasks.push(*last_result.task_arns)
71
71
  end
72
72
  rescue Aws::ECS::Errors::ServiceError => e
73
- print "Error listing ecs tasks: #{e}"
73
+ print "Error listing ecs tasks for service #{service_name} in cluster #{cluster}: #{e}"
74
74
  sleep(1)
75
75
  next
76
76
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'prometheus-config-builder'
6
- s.version = '0.0.15'
6
+ s.version = '0.0.21'
7
7
  s.date = Time.now
8
8
 
9
9
  s.summary = %q{Template based config generation}
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.15
4
+ version: 0.0.21
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-09-11 00:00:00.000000000 Z
11
+ date: 2019-11-04 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