Skip to content

Commit 0b510c7

Browse files
authored
Merge pull request #364 from bosh-dep-forks/master
Allow cert contents in prometheus scrape config tls config
2 parents d98263a + b19fefd commit 0b510c7

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

jobs/prometheus2/spec

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ packages:
55
- prometheus2
66

77
templates:
8+
bin/pre-start.erb: bin/pre-start
89
bin/prometheus_ctl: bin/prometheus_ctl
910
config/prometheus.yml: config/prometheus.yml
1011
config/custom.rules.yml: config/custom.rules.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
<% if_p("prometheus.scrape_configs") do |scrape_configs| %>
4+
<% scrape_configs.each do |scrape_config| %>
5+
<% if scrape_config['tls_config'] %>
6+
<% if scrape_config['tls_config']['cert_contents'] %>
7+
mkdir -p $(dirname <%= scrape_config['tls_config']['cert_file'] %>)
8+
echo "<%= scrape_config['tls_config']['cert_contents'] %>" > <%= scrape_config['tls_config']['cert_file'] %>
9+
<% end %>
10+
<% if scrape_config['tls_config']['key_contents'] %>
11+
mkdir -p $(dirname <%= scrape_config['tls_config']['key_file'] %>)
12+
echo "<%= scrape_config['tls_config']['key_contents'] %>" > <%= scrape_config['tls_config']['key_file'] %>
13+
<% end %>
14+
<% if scrape_config['tls_config']['ca_contents'] %>
15+
mkdir -p $(dirname <%= scrape_config['tls_config']['ca_file'] %>)
16+
echo "<%= scrape_config['tls_config']['ca_contents'] %>" > <%= scrape_config['tls_config']['ca_file'] %>
17+
<% end %>
18+
<% end %>
19+
<% end %>
20+
<% end %>

jobs/prometheus2/templates/config/prometheus.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ global:
2222
rule_files: <%= p('prometheus.rule_files', []).push('/var/vcap/jobs/prometheus2/config/custom.rules.yml').to_json %>
2323

2424
# A list of scrape configurations.
25-
scrape_configs: <%= p('prometheus.scrape_configs', []).to_json %>
25+
<% scrape_configs = p('prometheus.scrape_configs', []).map do |scrape_config|
26+
27+
scrape_config = scrape_config.clone
28+
scrape_config['tls_config'] = scrape_config['tls_config'].clone
29+
['ca_contents', 'cert_contents', 'key_contents'].each { |key| scrape_config['tls_config'].delete(key) } if scrape_config['tls_config']
30+
scrape_config
31+
end %>
32+
33+
scrape_configs: <%= scrape_configs.to_json %>
2634

2735
# Alerting specifies settings related to the Alertmanager.
2836
alerting:

0 commit comments

Comments
 (0)