Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config flag to disable prom_scraper #356

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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