From af2704ea2fd528fa839f741dd218ccf15f298ea2 Mon Sep 17 00:00:00 2001 From: Gordon Chung Date: Fri, 26 Apr 2013 12:55:00 -0400 Subject: [PATCH] glance/cinder/quantum counter units are not accurate/consistent change floating ip counters to 'ip' unit change volume.size counters to 'GB' unit change image.[update/upload/delete] counters to 'image' unit Change-Id: Icdb92b3edf08d9cf9ea555b3bdfe7d452dd3ffff Fixes:bug1173287 --- ceilometer/image/notifications.py | 2 +- ceilometer/network/notifications.py | 8 +++++--- ceilometer/volume/notifications.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ceilometer/image/notifications.py b/ceilometer/image/notifications.py index b91bd5a32..baa46cb94 100644 --- a/ceilometer/image/notifications.py +++ b/ceilometer/image/notifications.py @@ -89,7 +89,7 @@ class ImageCRUD(ImageCRUDBase): counter.Counter( name=message['event_type'], type=counter.TYPE_DELTA, - unit='event', + unit='image', volume=1, resource_id=message['payload']['id'], user_id=None, diff --git a/ceilometer/network/notifications.py b/ceilometer/network/notifications.py index ac3cdc539..0a8892050 100644 --- a/ceilometer/network/notifications.py +++ b/ceilometer/network/notifications.py @@ -70,11 +70,12 @@ class NetworkNotificationBase(plugin.NotificationBase): LOG.info('network notification %r', message) message['payload'] = message['payload'][self.resource_name] metadata = self.notification_to_metadata(message) - counter_name = getattr(self, "counter_name", self.resource_name) + counter_name = getattr(self, 'counter_name', self.resource_name) + unit_value = getattr(self, 'unit', self.resource_name) yield counter.Counter(name=counter_name, type=counter.TYPE_GAUGE, - unit=self.resource_name, + unit=unit_value, volume=1, user_id=message['_context_user_id'], project_id=message['payload']['tenant_id'], @@ -88,7 +89,7 @@ class NetworkNotificationBase(plugin.NotificationBase): yield counter.Counter(name=counter_name + "." + event_type_split[1], type=counter.TYPE_DELTA, - unit=self.resource_name, + unit=unit_value, volume=1, user_id=message['_context_user_id'], project_id=message['payload']['tenant_id'], @@ -189,3 +190,4 @@ class FloatingIP(NetworkNotificationBase): resource_name = 'floatingip' counter_name = 'ip.floating' + unit = 'ip' diff --git a/ceilometer/volume/notifications.py b/ceilometer/volume/notifications.py index b58a81e3b..b5ccdcffe 100644 --- a/ceilometer/volume/notifications.py +++ b/ceilometer/volume/notifications.py @@ -88,7 +88,7 @@ class VolumeSize(_Base): return [ counter.Counter(name='volume.size', type=counter.TYPE_GAUGE, - unit='B', + unit='GB', volume=message['payload']['size'], user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'],