checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA1:
3
- metadata.gz: 28ec94a10f052a70bf318fa278d0db94f1b61bd7
4
- data.tar.gz: 8bf37321c60625e248baf3ae1ad87f43a6bfa490
3
+ metadata.gz: daa33b9a7067c200ddbd5f5cde644a7a9ad1bdc7
4
+ data.tar.gz: dd4dfce8285f5294c457658644f5b59f965c936a
5
5
SHA512:
6
- metadata.gz: 8a45f2851cc4a39b0eda17440bf8150d267f0e386e315a220297a5e1fd7340867dfeee6c90fca4208275ea4d61d9ff169eaed0053729e78f5626f2e8bd6e21be
7
- data.tar.gz: 41c1a3a58953002e3ab8b7894b111b0da6a3f6053292da17c33c4e5e1bc080087d1bc6bce00ebde5a8c47da3d809bf9e69d13cbdc07d98912ff48da889c9e491
6
+ metadata.gz: 4d518806d7245738f537d182da910338e7f152b58293b652ac5598293873e8d0a95ae85ec0db42552f65cb921654d4aa748ad8c4767209e99a8bef42e53909ab
7
+ data.tar.gz: d08c53e941b3d28961373c2954d9263fec104d88245c8c3864a86697d4ecdabcbd2bd8cf5cd8b37033a970ef05d830f46f4e6d648307a681bc9159a634d013a8
data/lib/prometheus-config-builder/prometheus-config-builder.rb CHANGED
@@ -176,7 +176,7 @@ module PrometheusConfigBuilder
176
176
end
177
177
178
178
if @rules_dir != nil && !data["rule_files"].include?(@rules_dir)
179
- data["rule_files"] << File.expand_path(@rules_dir)
179
+ data["rule_files"] << File.expand_path(@rules_dir) + "/*.yaml"
180
180
end
181
181
182
182
File.open(destination, "w") do |file|
data/lib/prometheus-config-builder/scrape_ecs.rb CHANGED
@@ -25,30 +25,49 @@ module PrometheusConfigBuilder
25
25
tasks = get_tasks(config["cluster"], config["service"])
26
26
ips = get_task_ips(config["cluster"], tasks)
27
27
28
+ targets = []
29
+ ips.each do |ip|
30
+ if config["metrics_port"]
31
+ targets << ip + ":" + config["metrics_port"].to_s
32
+ else
33
+ targets << ip
34
+ end
35
+ end
36
+
28
37
data = [
29
38
{
30
- "targets" => ips,
39
+ "targets" => targets,
31
40
"labels" => config["labels"]
32
41
}
33
42
]
34
43
35
- if !config["name"]
36
- logger.warn("File #{basename}: the scrape_configs of type:ecs-tasks doesn't have \"name\" field set. Ignoring!")
44
+ if !config["job_name"]
45
+ logger.warn("File #{basename}: the scrape_configs of type:ecs-tasks doesn't have \"job_name\" field set. Ignoring!")
37
46
return nil
38
47
end
39
48
40
- file = File.expand_path(dst_prefix + "_" + config["name"] + ".json")
49
+ file = File.expand_path(dst_prefix + "_" + config["job_name"] + ".json")
41
50
File.open(file, "w") do |file|
42
51
file.write(data.to_json)
43
52
end
44
53
45
- return {
46
- "job_name" => config["name"],
47
- "metrics_path" => config["metrics_path"],
54
+ # Make copy of the settings and remove our custom properties from it.
55
+ # The rest user can set just as he wants according to the Prometheus schema.
56
+ # See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
57
+ settings = config.clone
58
+ settings.delete("type")
59
+ settings.delete("cluster")
60
+ settings.delete("service")
61
+ settings.delete("metrics_port")
62
+ settings.delete("labels")
63
+ settings.delete("region")
64
+ settings["file_sd_configs"] = [
48
65
"files" => [
49
66
file
50
67
]
51
- }
68
+ ]
69
+
70
+ return settings
52
71
end
53
72
54
73
def self.get_tasks(cluster, service_name)
data/lib/prometheus-config-builder/scrape_passthrough.rb CHANGED
@@ -2,7 +2,9 @@ module PrometheusConfigBuilder
2
2
3
3
class ScrapeConfigPassthrough
4
4
def self.handle(config)
5
- return config["config"]
5
+ settings = config.clone
6
+ settings.delete("type")
7
+ return settings
6
8
end
7
9
end
8
10
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.5'
6
+ s.version = '0.0.10'
7
7
s.date = Time.now
8
8
9
9
s.summary = %q{Template based config generation}
data/test/data/test1.yaml CHANGED
@@ -1,9 +1,8 @@
1
1
scrape_configs:
2
2
- type: passthrough
3
- config:
4
- job_name: discovery 1
5
- static_configs:
3
+ job_name: discovery 1
4
+ static_configs:
5
+ - targets: ['localhost:9090']
6
- - targets: ['localhost:9090']
7
6
8
7
9
8
config_rules:
data/test/data/test2.yaml CHANGED
@@ -1,9 +1,8 @@
1
1
scrape_configs:
2
2
- type: passthrough
3
- config:
4
- job_name: discovery 2
5
- static_configs:
3
+ job_name: discovery 2
4
+ static_configs:
5
+ - targets: ['localhost:9090']
6
- - targets: ['localhost:9090']
7
6
8
7
9
8
config_rules:
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.5
4
+ version: 0.0.10
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-09 00:00:00.000000000 Z
11
+ date: 2019-09-10 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: aws-sdk