From 740cac6571a1a27f0c84fc8567e2a36e09d9aefe Mon Sep 17 00:00:00 2001 From: Rodrigo Barbieri Date: Fri, 26 Jun 2020 12:05:19 -0300 Subject: [PATCH] Add polling-batch-size config option Samples collected can be batched together, consequently increasing or reducing the amount of API calls and body data sent to the configured publisher. This config is available since Rocky, adding the config option to allow its tuning. Change-Id: I0e3f756aa0305d3a96e21c7498d6a56208c51007 Closes-bug: #1885190 --- config.yaml | 7 +++ lib/ceilometer_contexts.py | 1 + templates/rocky/ceilometer.conf | 78 ++++++++++++++++++++++++++ unit_tests/test_ceilometer_contexts.py | 4 ++ 4 files changed, 90 insertions(+) create mode 100644 templates/rocky/ceilometer.conf diff --git a/config.yaml b/config.yaml index 8a4876c..537c026 100644 --- a/config.yaml +++ b/config.yaml @@ -278,3 +278,10 @@ options: From Pike onwards, the default ceilometer pollster collection runs a limited set of pollsters. Enable this to run all the available pollsters. This setting only takes effect from Queens onwards. + polling-batch-size: + type: int + default: 50 + description: | + The number of measures from same pollster to batch together for sending + to the notification agent and then to the publisher. Set to 0 to disable. + This config is only effective for OpenStack release Rocky or newer. diff --git a/lib/ceilometer_contexts.py b/lib/ceilometer_contexts.py index 80799f2..4216c4e 100644 --- a/lib/ceilometer_contexts.py +++ b/lib/ceilometer_contexts.py @@ -112,6 +112,7 @@ class CeilometerContext(OSContextGenerator): 'event_time_to_live': int(config('event-time-to-live')), 'polling_interval': int(config('polling-interval')), 'enable_all_pollsters': config('enable-all-pollsters'), + 'polling_batch_size': config('polling-batch-size'), } return ctxt diff --git a/templates/rocky/ceilometer.conf b/templates/rocky/ceilometer.conf new file mode 100644 index 0000000..a3dbd9f --- /dev/null +++ b/templates/rocky/ceilometer.conf @@ -0,0 +1,78 @@ +# rocky +############################################################################### +# [ WARNING ] +# ceilometer configuration file maintained by Juju +# local changes may be overwritten. +############################################################################### +[DEFAULT] +debug = {{ debug }} +verbose = {{ verbose }} +use_syslog = {{ use_syslog }} +event_pipeline_cfg_file = /etc/ceilometer/event_pipeline.yaml + +{% if gnocchi_url -%} +meter_dispatchers = gnocchi +event_dispatchers = gnocchi +{% elif db_host or db_mongo_servers -%} +meter_dispatchers = database +{%- endif %} + +{% if transport_url -%} +transport_url = {{ transport_url }} +{%- endif %} + +[notification] +workers = {{ workers }} +{% if messaging_urls -%} +{% for item in messaging_urls -%} +messaging_urls = {{ item }} +{% endfor %} +{% endif %} + +[polling] +batch_size = {{ polling_batch_size }} + +{% if service_host -%} +[service_credentials] +auth_url = {{ service_protocol }}://{{ service_host }}:{{ service_port }} +project_name = {{ admin_tenant_name }} +username = {{ admin_user }} +password = {{ admin_password }} +{% if api_version == "3" -%} +project_domain_name = {{ admin_domain_name }} +user_domain_name = {{ admin_domain_name }} +{% else -%} +project_domain_name = default +user_domain_name = default +{% endif -%} +auth_type = password +{% if use_internal_endpoints -%} +interface = internalURL +{%- endif %} +{% endif -%} + +{% if db_host or db_mongo_servers -%} +[database] +{% if db_replset: -%} +connection = mongodb://{{ db_mongo_servers }}/{{ db_name }}?readPreference=primaryPreferred&replicaSet={{ db_replset }} +mongodb_replica_set = {{ db_replset }} +{% else -%} +connection = mongodb://{{ db_host }}:{{ db_port }}/{{ db_name }} +{% endif %} +metering_time_to_live = {{ metering_time_to_live }} +event_time_to_live = {{ event_time_to_live }} +{%- endif %} + +[publisher] +telemetry_secret = {{ metering_secret }} + +{% if gnocchi_url -%} +[dispatcher_gnocchi] +filter_service_activity = False +archive_policy = {{ archive_policy }} +url = {{ gnocchi_url }} +{%- endif %} + +{% include "section-keystone-authtoken-mitaka" %} + +{% include "section-oslo-messaging-rabbit-ocata" %} diff --git a/unit_tests/test_ceilometer_contexts.py b/unit_tests/test_ceilometer_contexts.py index 4eb319c..882bbc4 100644 --- a/unit_tests/test_ceilometer_contexts.py +++ b/unit_tests/test_ceilometer_contexts.py @@ -133,6 +133,7 @@ class CeilometerContextsTest(CharmTestCase): 'event_time_to_live': -1, 'polling_interval': 300, 'enable_all_pollsters': False, + 'polling_batch_size': 50, }) @patch.object(utils, 'get_shared_secret') @@ -148,6 +149,7 @@ class CeilometerContextsTest(CharmTestCase): 'event_time_to_live': 7776000, 'polling_interval': 300, 'enable_all_pollsters': False, + 'polling_batch_size': 50, }) self.assertTrue(type(context['metering_time_to_live']) is int) self.assertTrue(type(context['event_time_to_live']) is int) @@ -164,6 +166,7 @@ class CeilometerContextsTest(CharmTestCase): 'event_time_to_live': -1, 'polling_interval': 300, 'enable_all_pollsters': True, + 'polling_batch_size': 50, }) @patch.object(utils, 'get_shared_secret') @@ -178,6 +181,7 @@ class CeilometerContextsTest(CharmTestCase): 'event_time_to_live': -1, 'polling_interval': 900, 'enable_all_pollsters': False, + 'polling_batch_size': 50, }) def test_ceilometer_service_context(self):