prometheus-config-builder 0.0.28 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ffffe52a4d4c276bb808edb6bfdc76efac30d2e1503a6048fcb7cc2d68bd8c2c
|
4
|
+
data.tar.gz: 8bc6208fb0f46a981715a595816da650744c64aa11dbfb8404bfad5623b2a240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ca2e277c6570811ce734a5589133bcdd450c52f05fb95908ff7ecf4d3c056a88142a4933a30fe6933a3831d247b7e949aa5f1cb67133bb453e5e4f3cd83c9e8
|
7
|
+
data.tar.gz: 5ffc5edc2adf5ad56260258354e4e7b60d4a2ef35fd5ad3b13f50067f6185bb98c47962fac6a68aae340560830c6ea4c9bcb4a027e4f78133b0334f886214dd7
|
@@ -30,18 +30,26 @@ module PrometheusConfigBuilder
|
|
30
30
|
|
31
31
|
attr_reader :basename
|
32
32
|
attr_reader :source
|
33
|
+
attr_reader :owner
|
34
|
+
attr_reader :runbook_url
|
33
35
|
|
34
36
|
def open(filename)
|
35
37
|
@filename = File.expand_path(filename)
|
36
38
|
@source = "file://#{filename}"
|
37
39
|
@basename = File.basename(filename)
|
38
40
|
@data = YAML.load_file(filename)
|
41
|
+
|
42
|
+
@owner = @data['owner']
|
43
|
+
@runbook_url = @data['runbook_url']
|
39
44
|
end
|
40
45
|
|
41
46
|
def load(file)
|
42
47
|
@source = file[:source]
|
43
48
|
@basename = file[:filename]
|
44
49
|
@data = YAML.load(file[:contents])
|
50
|
+
|
51
|
+
@owner = @data['owner']
|
52
|
+
@runbook_url = @data['runbook_url']
|
45
53
|
end
|
46
54
|
|
47
55
|
def config_rules
|
@@ -110,6 +118,10 @@ module PrometheusConfigBuilder
|
|
110
118
|
bucket: bucket_name
|
111
119
|
})
|
112
120
|
|
121
|
+
if !file.key.end_with?(".yaml")
|
122
|
+
next
|
123
|
+
end
|
124
|
+
|
113
125
|
logger.debug("Found file \"#{file.key}\" from S3 bucket #{bucket_name}")
|
114
126
|
files << {
|
115
127
|
source: "s3://#{bucket_name}/#{file.key}",
|
@@ -180,13 +192,20 @@ module PrometheusConfigBuilder
|
|
180
192
|
|
181
193
|
errors = 0
|
182
194
|
@files.each do |file|
|
195
|
+
|
196
|
+
# Build labels for the $config_file_status metric.
|
197
|
+
labels = {
|
198
|
+
file: file.source
|
199
|
+
}
|
200
|
+
labels[:owner] = file.owner if file.owner
|
201
|
+
labels[:runbook_url] = file.runbook_url if file.runbook_url
|
183
202
|
begin
|
184
203
|
configs = file.get_scrape_configs(scrape_files_dir + "/" + File.basename(file.basename, ".*"))
|
185
204
|
data["scrape_configs"].push(*configs)
|
186
|
-
$config_file_status.observe(1,
|
205
|
+
$config_file_status.observe(1, labels)
|
187
206
|
rescue Exception => e
|
188
207
|
logger.error("Unable to get scrape configs correctly from file #{file.source}. Error: #{e}")
|
189
|
-
$config_file_status.observe(0,
|
208
|
+
$config_file_status.observe(0, labels)
|
190
209
|
errors += 1
|
191
210
|
end
|
192
211
|
end
|
@@ -19,7 +19,9 @@ module PrometheusConfigBuilder
|
|
19
19
|
if client == nil
|
20
20
|
logger.info("Creating default client: #{name} with region: #{region}")
|
21
21
|
client = Aws::ECS::Client.new({
|
22
|
-
region: region
|
22
|
+
region: region,
|
23
|
+
instance_profile_credentials_retries: 4,
|
24
|
+
instance_profile_credentials_timeout: 2,
|
23
25
|
})
|
24
26
|
@@ecs[name] = client
|
25
27
|
end
|
@@ -64,21 +66,33 @@ module PrometheusConfigBuilder
|
|
64
66
|
region = (config["region"] or "us-east-1")
|
65
67
|
assume_role = config["assume_role"]
|
66
68
|
|
69
|
+
retries = 5
|
67
70
|
begin
|
68
71
|
client = get_client(region, assume_role)
|
72
|
+
|
73
|
+
$VERBOSE = x
|
74
|
+
tasks = get_tasks(client, config["cluster"], config["service"])
|
75
|
+
endpoints = get_task_endpoints(client, config["cluster"], tasks, config["labels"], config["metrics_port"])
|
76
|
+
|
77
|
+
if !config["job_name"]
|
78
|
+
logger.warn("File #{basename}: the scrape_configs of type:ecs-tasks doesn't have \"job_name\" field set. Ignoring!")
|
79
|
+
return nil
|
80
|
+
end
|
81
|
+
|
82
|
+
rescue Aws::Errors::MissingCredentialsError => e
|
83
|
+
logger.warn("Got a Aws::Errors::MissingCredentialsError: #{e}")
|
84
|
+
if retries > 0
|
85
|
+
retries = retries - 1
|
86
|
+
logger.warn("Will try to retry")
|
87
|
+
sleep(5)
|
88
|
+
retry
|
89
|
+
end
|
90
|
+
raise e
|
69
91
|
rescue ArgumentError => e
|
70
92
|
logger.warn("File #{basename}: the scrape_configs of type:ecs-tasks had invalid arguments: #{e}")
|
71
93
|
return nil
|
72
94
|
end
|
73
95
|
|
74
|
-
$VERBOSE = x
|
75
|
-
tasks = get_tasks(client, config["cluster"], config["service"])
|
76
|
-
endpoints = get_task_endpoints(client, config["cluster"], tasks, config["labels"], config["metrics_port"])
|
77
|
-
|
78
|
-
if !config["job_name"]
|
79
|
-
logger.warn("File #{basename}: the scrape_configs of type:ecs-tasks doesn't have \"job_name\" field set. Ignoring!")
|
80
|
-
return nil
|
81
|
-
end
|
82
96
|
|
83
97
|
# Prometheus might notice that the scrape file is changed in the middle of the write. That's why we'll
|
84
98
|
# first write the new contents into a temp file and atomically replace the file with the temp file.
|
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.33
|
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: 2020-
|
11
|
+
date: 2020-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -136,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
|
140
|
-
rubygems_version: 2.5.2.3
|
139
|
+
rubygems_version: 3.0.3
|
141
140
|
signing_key:
|
142
141
|
specification_version: 4
|
143
142
|
summary: Template based config generation
|