From e416ba5d72b37ac8d770fbe3a2ca95a2be5263c5 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Tue, 5 Nov 2019 15:57:48 -0800 Subject: [PATCH] Allow ability to configure pipeline publishers This adds a template for managing the pipeline.yaml file which allows one to configure the pipeline publishers such as gnocchi or prometheus. The template file was taken from the latest Rocky tarball for ceilometer. Change-Id: I938219bfdcfa69a910cae4b72a40c19d5124d99e --- attributes/default.rb | 3 + recipes/agent-central.rb | 1 + recipes/agent-compute.rb | 1 + recipes/agent-notification.rb | 1 + recipes/common.rb | 10 +++ spec/agent-central_spec.rb | 3 + spec/agent-compute_spec.rb | 3 + spec/agent-notification_spec.rb | 3 + spec/common_spec.rb | 22 +++++++ templates/pipeline.yaml.erb | 107 ++++++++++++++++++++++++++++++++ 10 files changed, 154 insertions(+) create mode 100644 templates/pipeline.yaml.erb diff --git a/attributes/default.rb b/attributes/default.rb index fc3d19b..c977496 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -71,6 +71,9 @@ default['openstack']['aodh']['service_role'] = 'admin' default['openstack']['telemetry_metric']['gnocchi-upgrade-options'] = '' +# Configuration for /etc/ceilometer/pipeline.yaml +default['openstack']['telemetry']['pipeline']['publishers'] = ['gnocchi://'] + %w(telemetry telemetry_metric aodh).each do |ts| # specify whether to enable SSL for ceilometer API endpoint default['openstack'][ts]['ssl']['enabled'] = false diff --git a/recipes/agent-central.rb b/recipes/agent-central.rb index fc58631..8eef3d4 100644 --- a/recipes/agent-central.rb +++ b/recipes/agent-central.rb @@ -32,5 +32,6 @@ end service 'ceilometer-agent-central' do service_name platform['agent_central_service'] subscribes :restart, "template[#{node['openstack']['telemetry']['conf_file']}]" + subscribes :restart, "template[#{::File.join(node['openstack']['telemetry']['conf_dir'], 'pipeline.yaml')}]" action [:enable, :start] end diff --git a/recipes/agent-compute.rb b/recipes/agent-compute.rb index a44b0f3..10acb38 100644 --- a/recipes/agent-compute.rb +++ b/recipes/agent-compute.rb @@ -32,5 +32,6 @@ end service 'ceilometer-agent-compute' do service_name platform['agent_compute_service'] subscribes :restart, "template[#{node['openstack']['telemetry']['conf_file']}]" + subscribes :restart, "template[#{::File.join(node['openstack']['telemetry']['conf_dir'], 'pipeline.yaml')}]" action [:enable, :start] end diff --git a/recipes/agent-notification.rb b/recipes/agent-notification.rb index 51fe43a..465e5bd 100644 --- a/recipes/agent-notification.rb +++ b/recipes/agent-notification.rb @@ -31,5 +31,6 @@ end service 'ceilometer-agent-notification' do service_name platform['agent_notification_service'] subscribes :restart, "template[#{node['openstack']['telemetry']['conf_file']}]" + subscribes :restart, "template[#{::File.join(node['openstack']['telemetry']['conf_dir'], 'pipeline.yaml')}]" action [:enable, :start] end diff --git a/recipes/common.rb b/recipes/common.rb index 10dfd39..8a0bc54 100644 --- a/recipes/common.rb +++ b/recipes/common.rb @@ -103,3 +103,13 @@ template node['openstack']['telemetry']['conf_file'] do service_config: ceilometer_conf_options ) end + +template ::File.join(node['openstack']['telemetry']['conf_dir'], 'pipeline.yaml') do + source 'pipeline.yaml.erb' + owner node['openstack']['telemetry']['user'] + group node['openstack']['telemetry']['group'] + mode 0o0640 + variables( + publishers: node['openstack']['telemetry']['pipeline']['publishers'] + ) +end diff --git a/spec/agent-central_spec.rb b/spec/agent-central_spec.rb index 804a628..8e4d450 100644 --- a/spec/agent-central_spec.rb +++ b/spec/agent-central_spec.rb @@ -24,6 +24,9 @@ describe 'openstack-telemetry::agent-central' do it 'subscribes to its config file' do expect(chef_run.service('ceilometer-agent-central')).to subscribe_to('template[/etc/ceilometer/ceilometer.conf]').delayed end + it 'subscribes to /etc/ceilometer/pipeline.yaml' do + expect(chef_run.service('ceilometer-agent-central')).to subscribe_to('template[/etc/ceilometer/pipeline.yaml]').delayed + end end end end diff --git a/spec/agent-compute_spec.rb b/spec/agent-compute_spec.rb index 942f408..5f09196 100644 --- a/spec/agent-compute_spec.rb +++ b/spec/agent-compute_spec.rb @@ -24,6 +24,9 @@ describe 'openstack-telemetry::agent-compute' do it 'subscribes to its config file' do expect(chef_run.service('ceilometer-agent-compute')).to subscribe_to('template[/etc/ceilometer/ceilometer.conf]').delayed end + it 'subscribes to /etc/ceilometer/pipeline.yaml' do + expect(chef_run.service('ceilometer-agent-compute')).to subscribe_to('template[/etc/ceilometer/pipeline.yaml]').delayed + end end end end diff --git a/spec/agent-notification_spec.rb b/spec/agent-notification_spec.rb index 6cf76c0..0a0de38 100644 --- a/spec/agent-notification_spec.rb +++ b/spec/agent-notification_spec.rb @@ -24,6 +24,9 @@ describe 'openstack-telemetry::agent-notification' do it 'subscribes to its config file' do expect(chef_run.service('ceilometer-agent-notification')).to subscribe_to('template[/etc/ceilometer/ceilometer.conf]').delayed end + it 'subscribes to /etc/ceilometer/pipeline.yaml' do + expect(chef_run.service('ceilometer-agent-notification')).to subscribe_to('template[/etc/ceilometer/pipeline.yaml]').delayed + end end end end diff --git a/spec/common_spec.rb b/spec/common_spec.rb index e2266ea..28435d2 100644 --- a/spec/common_spec.rb +++ b/spec/common_spec.rb @@ -28,6 +28,28 @@ describe 'openstack-telemetry::common' do expect(chef_run).to upgrade_package 'ceilometer-common' end + describe '/etc/ceilometer/pipeline.yaml' do + pipeline_yaml = <<-EOL + publishers: + - gnocchi:// + +EOL + + it do + expect(chef_run).to create_template('/etc/ceilometer/pipeline.yaml') + .with( + source: 'pipeline.yaml.erb', + owner: 'ceilometer', + group: 'ceilometer', + mode: 0o0640 + ) + end + + it do + expect(chef_run).to render_file('/etc/ceilometer/pipeline.yaml').with_content(pipeline_yaml) + end + end + describe '/etc/ceilometer' do let(:dir) { chef_run.directory('/etc/ceilometer') } diff --git a/templates/pipeline.yaml.erb b/templates/pipeline.yaml.erb new file mode 100644 index 0000000..a9eef0e --- /dev/null +++ b/templates/pipeline.yaml.erb @@ -0,0 +1,107 @@ +<%= node['openstack']['common']['custom_template_banner'] %> +--- +sources: + - name: meter_source + meters: + - "*" + sinks: + - meter_sink + - name: cpu_source + meters: + - "cpu" + sinks: + - cpu_sink + - cpu_delta_sink + - name: disk_source + meters: + - "disk.read.bytes" + - "disk.read.requests" + - "disk.write.bytes" + - "disk.write.requests" + - "disk.device.read.bytes" + - "disk.device.read.requests" + - "disk.device.write.bytes" + - "disk.device.write.requests" + sinks: + - disk_sink + - name: network_source + meters: + - "network.incoming.bytes" + - "network.incoming.packets" + - "network.outgoing.bytes" + - "network.outgoing.packets" + sinks: + - network_sink +sinks: + - name: meter_sink + publishers: + <% @publishers.each do |publisher| %> + - <%= publisher %> + <% end -%> + + # All these transformers are deprecated, and will be removed in the future, don't use them. + - name: cpu_sink + transformers: + - name: "rate_of_change" + parameters: + target: + name: "cpu_util" + unit: "%" + type: "gauge" + max: 100 + scale: "100.0 / (10**9 * (resource_metadata.cpu_number or 1))" + publishers: + <% @publishers.each do |publisher| %> + - <%= publisher %> + <% end -%> + + # All these transformers are deprecated, and will be removed in the future, don't use them. + - name: cpu_delta_sink + transformers: + - name: "delta" + parameters: + target: + name: "cpu.delta" + growth_only: True + publishers: + <% @publishers.each do |publisher| %> + - <%= publisher %> + <% end -%> + + # All these transformers are deprecated, and will be removed in the future, don't use them. + - name: disk_sink + transformers: + - name: "rate_of_change" + parameters: + source: + map_from: + name: "(disk\\.device|disk)\\.(read|write)\\.(bytes|requests)" + unit: "(B|request)" + target: + map_to: + name: "\\1.\\2.\\3.rate" + unit: "\\1/s" + type: "gauge" + publishers: + <% @publishers.each do |publisher| %> + - <%= publisher %> + <% end -%> + + # All these transformers are deprecated, and will be removed in the future, don't use them. + - name: network_sink + transformers: + - name: "rate_of_change" + parameters: + source: + map_from: + name: "network\\.(incoming|outgoing)\\.(bytes|packets)" + unit: "(B|packet)" + target: + map_to: + name: "network.\\1.\\2.rate" + unit: "\\1/s" + type: "gauge" + publishers: + <% @publishers.each do |publisher| %> + - <%= publisher %> + <% end -%>