checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA1:
3
- metadata.gz: 5f4e2a48b8c51c6a1cd8842fc8c680ef3b35f6bd
4
- data.tar.gz: 34110529a68b642088da2e5f455a85a2ec828fbc
3
+ metadata.gz: daa33b9a7067c200ddbd5f5cde644a7a9ad1bdc7
4
+ data.tar.gz: dd4dfce8285f5294c457658644f5b59f965c936a
5
5
SHA512:
6
- metadata.gz: d1896c842fa7ad5f84b4b9315cf4f2c7212f07637e14c09dbd2d3e1a2a16d1d3b51bdf730360e29f5a06baed4f465ca70cae9f11f4d60014f6ed6701ce8e61de
7
- data.tar.gz: e718e9a5407a624c0ba0ffb102aa689cf2a04ba6c4b34fb5c9e5cec5b63eaead3f56c0386533c0ffe5bbfa1d45dff474342ad232f9f60e6984afc0d6197b8f57
6
+ metadata.gz: 4d518806d7245738f537d182da910338e7f152b58293b652ac5598293873e8d0a95ae85ec0db42552f65cb921654d4aa748ad8c4767209e99a8bef42e53909ab
7
+ data.tar.gz: d08c53e941b3d28961373c2954d9263fec104d88245c8c3864a86697d4ecdabcbd2bd8cf5cd8b37033a970ef05d830f46f4e6d648307a681bc9159a634d013a8
data/lib/prometheus-config-builder/scrape_ecs.rb CHANGED
@@ -25,32 +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"],
48
- "file_sd_configs" => [
49
- "files" => [
50
- file
51
- ]
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"] = [
65
+ "files" => [
66
+ file
52
67
]
53
- }
68
+ ]
69
+
70
+ return settings
54
71
end
55
72
56
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.9'
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.9
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