From f00a0458a1d508086ef871c637ae4dc4a221d44c Mon Sep 17 00:00:00 2001 From: Luka Peschke Date: Wed, 9 Oct 2019 17:23:39 +0200 Subject: [PATCH] Support cross-tenant metrics in monasca collector This allows metrics to be fetched from the current scope in the monasca collector, in case cross-metric tenant submission is enabled: https://github.com/openstack/monasca-agent/blob/master/docs/MonascaMetrics.md#cross-tenant-metric-submission. Story: 2006696 Task: 36999 Change-Id: Icd32a2d0be249efea0867d8a2966c156084e75bb --- cloudkitty/collector/monasca.py | 6 +++++- doc/source/admin/configuration/collector.rst | 4 +++- ...etric-submission-monasca-collector-508b495bc88910ca.yaml | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/support-cross-tenant-metric-submission-monasca-collector-508b495bc88910ca.yaml diff --git a/cloudkitty/collector/monasca.py b/cloudkitty/collector/monasca.py index 41fbca97..694e997f 100644 --- a/cloudkitty/collector/monasca.py +++ b/cloudkitty/collector/monasca.py @@ -179,7 +179,11 @@ class MonascaCollector(collector.BaseCollector): extra_args = self.conf[metric_name]['extra_args'] kwargs = {} if extra_args['forced_project_id']: - kwargs['tenant_id'] = extra_args['forced_project_id'] + if extra_args['forced_project_id'] == 'SCOPE_ID' and project_id: + kwargs['tenant_id'] = project_id + dimensions.pop(CONF.collect.scope_key, None) + else: + kwargs['tenant_id'] = extra_args['forced_project_id'] return self._conn.metrics.list_statistics( name=metric_name, diff --git a/doc/source/admin/configuration/collector.rst b/doc/source/admin/configuration/collector.rst index fe4bc3ba..a777c739 100644 --- a/doc/source/admin/configuration/collector.rst +++ b/doc/source/admin/configuration/collector.rst @@ -274,7 +274,9 @@ Monasca fetched from a specific tenant instead of the one cloudkitty is identified in. For example, if cloudkitty is identified in the ``service`` project, but needs to fetch a metric from the ``admin`` project, its ID should be - specified through this option. + specified through this option. If this option is set to ``SCOPE_ID``, + the metric will be fetched from the current project (this assumes that + scopes are configured to be projects/tenants). Prometheus ~~~~~~~~~~ diff --git a/releasenotes/notes/support-cross-tenant-metric-submission-monasca-collector-508b495bc88910ca.yaml b/releasenotes/notes/support-cross-tenant-metric-submission-monasca-collector-508b495bc88910ca.yaml new file mode 100644 index 00000000..f0778401 --- /dev/null +++ b/releasenotes/notes/support-cross-tenant-metric-submission-monasca-collector-508b495bc88910ca.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Cross-tenant metric submission is now supported in the monasca collector. + In order to a fetch metric from the scope that is currently being processed, + the ``forced_project_id`` option must be set to ``SCOPE_ID``.