checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA1:
3
- metadata.gz: 1450c33e3caf21e8ae18e9771d079f406ec863c1
4
- data.tar.gz: 33098cdea5dc8099c03d8ececa7bf8fd2404f14a
3
+ metadata.gz: 7fe9956a29f5a926ed6c74b13e9d4df80d3bd5cc
4
+ data.tar.gz: b7102c01ff937851d01cde3153d82dd8b1468cb4
5
5
SHA512:
6
- metadata.gz: e1580e88918e206d3384c8ef13ff20fa434dc5c12b0555ba6ce3cff8f05f79b43940eb8838266277f57bdaa59a45143ef0afe1e48bf005d4694ea9dee9121832
7
- data.tar.gz: 9939efd37512ef1f3ad98acc5a0b9b32f42aef725fb2256cbdee338ddae66ffc0fa8d2f895f3d11c59b0e5ae42f354fd9ad0675257ca83a48c832f2793d06866
6
+ metadata.gz: 985ff159e7f1d2e3704cf646ce42fae8e71ab436fcff9971270650e499110c88ccafcb9fe6dd62080c11a3b3cc5df852cdf9e216ee4da00b6c6c3e7cd79ac84b
7
+ data.tar.gz: d135e9fe1acf9823784ff9d2a5a3deeec41f8e0f36d7e6ea9fe078cca4934df275fa5b64cf82d9dac208fb6810234fa9df96def218a786e6a816adbe644b1718
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ tmp
data/lib/prometheus-config-builder/logger.rb ADDED
@@ -0,0 +1,15 @@
1
+
2
+ module PrometheusConfigBuilderLogger
3
+ def logger
4
+ PrometheusConfigBuilderLogger.logger
5
+ end
6
+
7
+ def self.logger=(logger)
8
+ @logger = logger
9
+ end
10
+
11
+ def self.logger
12
+ @logger ||= Logger.new(STDOUT)
13
+ end
14
+
15
+ end
data/lib/prometheus-config-builder/prometheus-config-builder.rb CHANGED
@@ -164,6 +164,8 @@ module PrometheusConfigBuilder
164
164
data["scrape_configs"] = []
165
165
end
166
166
167
+ FileUtils.mkdir_p(scrape_files_dir) if !File.exist?(scrape_files_dir)
168
+
167
169
@files.each do |file|
168
170
configs = file.get_scrape_configs(scrape_files_dir + "/" + File.basename(file.basename, ".*"))
169
171
data["scrape_configs"].push(*configs)
data/lib/prometheus-config-builder/scrape_ecs.rb CHANGED
@@ -12,7 +12,15 @@ module PrometheusConfigBuilder
12
12
$VERBOSE = nil
13
13
require 'aws-sdk'
14
14
15
- @@ecs = Aws::ECS::Client.new
15
+ if !config["region"]
16
+ logger.warn("File #{basename}: the scrape_configs of type:ecs-tasks doesn't have \"region\" field set. Ignoring!")
17
+ return nil
18
+
19
+ end
20
+
21
+ @@ecs = Aws::ECS::Client.new({
22
+ region:config["region"]
23
+ })
16
24
$VERBOSE = x
17
25
tasks = get_tasks(config["cluster"], config["service"])
18
26
ips = get_task_ips(config["cluster"], tasks)
@@ -25,20 +33,23 @@ module PrometheusConfigBuilder
25
33
]
26
34
27
35
if !config["name"]
28
- logger.warn("File #{basename}: the scrape_configs of type:ecs-tasks doesn't have name field set. Ignoring!")
36
+ logger.warn("File #{basename}: the scrape_configs of type:ecs-tasks doesn't have \"name\" field set. Ignoring!")
29
37
return nil
30
38
end
31
39
32
- File.open(dst_prefix + "_" + config["name"] + ".json", "w") do |file|
40
+ file = File.expand_path(dst_prefix + "_" + config["name"] + ".json")
41
+ File.open(file, "w") do |file|
33
42
file.write(data.to_json)
34
43
end
35
44
36
45
return {
37
- "job_name" => config["job_name"],
46
+ "job_name" => config["name"],
38
47
"metrics_path" => config["metrics_path"],
39
- "files" => [
40
- config["file"]
41
- ]
48
+ "file_sd_configs" => {
49
+ "files" => [
50
+ file
51
+ ]
52
+ }
42
53
}
43
54
end
44
55
data/prometheus-config-builder.gemspec CHANGED
@@ -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.2'
6
+ s.version = '0.0.7'
7
7
s.date = Time.now
8
8
9
9
s.summary = %q{Template based config generation}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: prometheus-config-builder
3
3
version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.7
5
5
platform: ruby
6
6
authors:
7
7
- Juho Mäkinen juho.makinen@gmail.com
@@ -87,11 +87,13 @@ executables:
87
87
extensions: []
88
88
extra_rdoc_files: []
89
89
files:
90
+ - ".gitignore"
90
91
- Gemfile
91
92
- README.md
92
93
- Rakefile
93
94
- bin/prometheus-config-builder
94
95
- lib/prometheus-config-builder.rb
96
+ - lib/prometheus-config-builder/logger.rb
95
97
- lib/prometheus-config-builder/prometheus-config-builder.rb
96
98
- lib/prometheus-config-builder/scrape_ecs.rb
97
99
- lib/prometheus-config-builder/scrape_passthrough.rb