-
Notifications
You must be signed in to change notification settings - Fork 2
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
Expose wider collector configuration #31
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,117 @@ | ||
<%= | ||
metric_exporters = p('metric_exporters') | ||
unless metric_exporters.respond_to?(:keys) | ||
metric_exporters = YAML::load(metric_exporters) | ||
def config | ||
@config ||= begin | ||
cfg = retrieve_property('config') | ||
cfg = handle_old_properties(cfg) if cfg.empty? | ||
cfg | ||
end | ||
end | ||
|
||
trace_exporters = p('trace_exporters') | ||
unless trace_exporters.respond_to?(:keys) | ||
trace_exporters = YAML::load(trace_exporters) | ||
def check_for_new_and_old_properties! | ||
both_provided = !p('config').empty? && (!p('metric_exporters').empty? || !p('trace_exporters').empty?) | ||
return unless both_provided | ||
|
||
raise "Can not provide 'config' property when deprecated 'metric_exporters' or 'trace_exporters' properties are provided" | ||
end | ||
|
||
def retrieve_property(name) | ||
if p(name).respond_to?(:keys) | ||
p(name) | ||
else | ||
YAML.safe_load(p(name)) | ||
end | ||
end | ||
|
||
def handle_old_properties(cfg) | ||
metric_exporters = retrieve_property('metric_exporters') | ||
trace_exporters = retrieve_property('trace_exporters') | ||
raise 'Exporter names must be unique' unless (trace_exporters.keys - metric_exporters.keys) == trace_exporters.keys | ||
|
||
cfg['exporters'] = metric_exporters.merge(trace_exporters) | ||
cfg['service'] = { 'pipelines' => {} } | ||
|
||
if metric_exporters.any? | ||
cfg['service']['pipelines']['metrics'] = { | ||
'receivers' => ['otlp/cf-local'], | ||
'exporters' => metric_exporters.keys | ||
} | ||
end | ||
|
||
if trace_exporters.any? | ||
cfg['service']['pipelines']['traces'] = { | ||
'receivers' => ['otlp/cf-local'], | ||
'exporters' => trace_exporters.keys | ||
} | ||
end | ||
|
||
cfg | ||
end | ||
|
||
unless (trace_exporters.keys-metric_exporters.keys) == trace_exporters.keys | ||
raise "Exporter names must be unique" | ||
def check_for_no_exporters! | ||
raise 'Exporter configuration must be provided' unless config['exporters'] | ||
end | ||
|
||
if (metric_exporters.keys + trace_exporters.keys).any?{|k| k.include?('/cf-internal')} | ||
raise 'Exporters cannot be defined under cf-internal namespace' | ||
def check_for_no_service_config! | ||
raise 'Service configuration must be provided' unless config['service'] | ||
end | ||
|
||
if metric_exporters.any?{|k, v| k.start_with?('prometheus') && v['endpoint'] && v['endpoint'].end_with?(':8889')} | ||
raise 'Cannot define prometheus exporter listening on port 8889 (reserved for BBS API port)' | ||
def check_for_use_of_reserved_prefix! | ||
%w[exporters processors].each do |component| | ||
if config[component] && config[component].keys.any? { |k| k.include?('/cf-internal') } | ||
raise "#{component.capitalize} cannot be defined under cf-internal namespace" | ||
end | ||
end | ||
end | ||
|
||
config = { | ||
"receivers"=> { | ||
"otlp"=>{ | ||
"protocols"=>{ | ||
"grpc"=>{ | ||
"endpoint"=>"#{p('ingress.grpc.address')}:#{p('ingress.grpc.port')}", | ||
"tls"=>{ | ||
"client_ca_file"=>"/var/vcap/jobs/otel-collector-windows/config/certs/otel-collector-ca.crt", | ||
"cert_file"=>"/var/vcap/jobs/otel-collector-windows/config/certs/otel-collector.crt", | ||
"key_file"=>"/var/vcap/jobs/otel-collector-windows/config/certs/otel-collector.key", | ||
"min_version"=>"1.3" | ||
def check_for_use_of_reserved_bbs_api_port! | ||
if config['exporters'] && config['exporters'].any? do |k, v| | ||
k.start_with?('prometheus/') && v['endpoint'] && v['endpoint'].end_with?(':8889') | ||
end | ||
raise 'Cannot define prometheus exporter listening on port 8889 (reserved for BBS API port)' | ||
end | ||
end | ||
|
||
def set_internal_receiver_as_only_receiver | ||
config['receivers'] = { | ||
'otlp/cf-internal-local' => { | ||
'protocols' => { | ||
'grpc' => { | ||
'endpoint' => "#{p('ingress.grpc.address')}:#{p('ingress.grpc.port')}", | ||
'tls' => { | ||
'client_ca_file' => '/var/vcap/jobs/otel-collector-windows/config/certs/otel-collector-ca.crt', | ||
'cert_file' => '/var/vcap/jobs/otel-collector-windows/config/certs/otel-collector.crt', | ||
'key_file' => '/var/vcap/jobs/otel-collector-windows/config/certs/otel-collector.key', | ||
'min_version' => '1.3' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"exporters"=>metric_exporters.merge(trace_exporters), | ||
"service"=>{ | ||
"telemetry"=>{ | ||
"metrics"=>{ | ||
"level"=>p('telemetry.metrics.level'), | ||
"address"=>"127.0.0.1:#{p('telemetry.metrics.port')}" | ||
} | ||
}, | ||
"pipelines"=>{} | ||
} | ||
} | ||
end | ||
|
||
if metric_exporters.any? | ||
config['service']['pipelines']['metrics'] = {"receivers"=>["otlp"], "exporters"=>metric_exporters.keys} | ||
def set_internal_receiver_on_all_pipelines | ||
config['service']['pipelines'].each_value do |p| | ||
p['receivers'] = ['otlp/cf-internal-local'] | ||
end | ||
end | ||
|
||
if trace_exporters.any? | ||
config['service']['pipelines']['traces'] = {"receivers"=>["otlp"], "exporters"=>trace_exporters.keys} | ||
def expose_internal_telemetry | ||
config['service']['telemetry'] = { | ||
'metrics' => { | ||
'address' => "127.0.0.1:#{p('telemetry.metrics.port')}", | ||
'level' => p('telemetry.metrics.level') | ||
} | ||
} | ||
end | ||
|
||
YAML::dump(config) | ||
check_for_new_and_old_properties! | ||
check_for_no_exporters! | ||
check_for_no_service_config! | ||
check_for_use_of_reserved_prefix! | ||
check_for_use_of_reserved_bbs_api_port! | ||
set_internal_receiver_as_only_receiver | ||
set_internal_receiver_on_all_pipelines | ||
expose_internal_telemetry | ||
|
||
YAML.dump(config) | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @acrmp,
Generally I'm all in about this change, but I wonder if we should do it this way, that we practically embed the Otel Collector config in the spec or we provide provide a parameter which can define the path to the Otel collector config yaml file.
If we use some manager to manager the fleet of Otel collectors which we have based on OpAMP, they can push configuration to the clients (Otel collectors), it might be more clear, readable, practical for further processing (merge of local and remote config) if the configuration is in a separate file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chombium Can you expand on how you would see this working? Were you thinking of doing config merging outside of this release?
We're still exploring how we might want to distribute configuration. One option is that we could do something similar to what we do for the prom scraper and load configs that match a certain file name glob. A downside is that otel config changes would currently require BOSH to roll all the VMs.
We've looked into OpAMP a little. There still seem to be a few rough edges at the moment. For example see this recent issue we opened:
open-telemetry/opentelemetry-collector-contrib#33799
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @acrmp, @mkocher sorry for the late reply.... :-/
I was thinking of having the Otel collector config in a separate file for better separation, but it doesn't hurt if it's inside the job spec. At the end if we use an OpAMP server for managing the configuration, the sever would ping the Otel Collector that there is new config available and its up to the collector to decide when it will download and apply the new config. I'm not against your solution at all ;)