Skip to content

Commit

Permalink
Merge pull request #356 from sap-contributions/add-config-flag-to-dis…
Browse files Browse the repository at this point in the history
…able-prom_scraper

Add config flag to disable prom_scraper
  • Loading branch information
svkrieger authored Nov 17, 2023
2 parents 7aafa17 + 3ff4e0c commit 12dc182
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jobs/cloud_controller_ng/spec
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,10 @@ properties:
cc.public_tls.private_key:
description: "PEM-encoded key for secure TLS communication over external endpoints"

cc.prom_scraper.disabled:
description: "When set to true, the prom_scraper job won't scrape the Cloud Controller's metrics.
Use this if you have another scraper in place and to prevent scraping metrics twice."
default: false
cc.prom_scraper_tls.ca_cert:
description: "PEM-encoded CA certificate for secure, mutually authenticated TLS communication with prom_scraper"
cc.prom_scraper_tls.public_cert:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<% if p("cc.prom_scraper.disabled") != true -%>
port: <%= p("cc.prom_metrics_server_tls_port") %>
source_id: "cloud_controller_ng"
instance_id: <%= spec.id || spec.index.to_s %>
scheme: https
server_name: <%= p("cc.internal_service_hostname") %>
path: /internal/v4/metrics
<% end -%>
37 changes: 37 additions & 0 deletions spec/cloud_controller_ng/prom_scraper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

require 'rspec'
require 'bosh/template/test'

module Bosh
module Template
module Test
describe 'prom_scraper config template rendering' do
let(:release_path) { File.join(File.dirname(__FILE__), '../..') }
let(:release) { ReleaseDir.new(release_path) }
let(:job) { release.job('cloud_controller_ng') }

describe 'prom_scraper_config.yml' do
let(:template) { job.template('config/prom_scraper_config.yml') }
let(:manifest_properties) { {} }

before do
@rendered_file = template.render(manifest_properties, consumes: {})
end

it 'renders default values' do
expect(@rendered_file).to include('port: 9025')
end

context 'when prom_scraper is disabled' do
let(:manifest_properties) { { 'cc' => { 'prom_scraper' => { 'disabled' => true } } } }

it 'renders an empty file' do
expect(@rendered_file).not_to include('port: 9025')
end
end
end
end
end
end
end

0 comments on commit 12dc182

Please sign in to comment.