diff --git a/bin/ceilometer-send-counter b/bin/ceilometer-send-counter index 7765709d..4bda103c 100755 --- a/bin/ceilometer-send-counter +++ b/bin/ceilometer-send-counter @@ -40,6 +40,10 @@ cfg.CONF.register_cli_opts([ help='counter type (gauge, delta, cumulative)', default='gauge', required=True), + cfg.StrOpt('counter-unit', + short='U', + help='counter unit', + default=None), cfg.IntOpt('counter-volume', short='l', help='counter volume value', @@ -77,6 +81,7 @@ root_logger.setLevel(logging.DEBUG) publish.publish_counter(context.get_admin_context(), counter.Counter(name=cfg.CONF.counter_name, type=cfg.CONF.counter_type, + unit=cfg.CONF.counter_unit, volume=cfg.CONF.counter_volume, user_id=cfg.CONF.counter_user, project_id=cfg.CONF.counter_project, diff --git a/ceilometer/api/controllers/v2.py b/ceilometer/api/controllers/v2.py index 63775501..a78c18b5 100644 --- a/ceilometer/api/controllers/v2.py +++ b/ceilometer/api/controllers/v2.py @@ -252,6 +252,7 @@ class Event(Base): source = text counter_name = text counter_type = text + counter_unit = text counter_volume = float user_id = text project_id = text diff --git a/ceilometer/collector/meter.py b/ceilometer/collector/meter.py index e622ffc5..c40ba178 100644 --- a/ceilometer/collector/meter.py +++ b/ceilometer/collector/meter.py @@ -88,6 +88,7 @@ def meter_message_from_counter(counter, secret, source): msg = {'source': source, 'counter_name': counter.name, 'counter_type': counter.type, + 'counter_unit': counter.unit, 'counter_volume': counter.volume, 'user_id': counter.user_id, 'project_id': counter.project_id, diff --git a/ceilometer/compute/notifications.py b/ceilometer/compute/notifications.py index 9dce5896..c651b40c 100644 --- a/ceilometer/compute/notifications.py +++ b/ceilometer/compute/notifications.py @@ -71,6 +71,7 @@ class Instance(_Base): return [ counter.Counter(name='instance', type=counter.TYPE_GAUGE, + unit='instance', volume=1, user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], @@ -88,6 +89,7 @@ class Memory(_Base): return [ counter.Counter(name='memory', type=counter.TYPE_GAUGE, + unit='B', volume=message['payload']['memory_mb'], user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], @@ -105,6 +107,7 @@ class VCpus(_Base): return [ counter.Counter(name='vcpus', type=counter.TYPE_GAUGE, + unit='vcpu', volume=message['payload']['vcpus'], user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], @@ -122,6 +125,7 @@ class RootDiskSize(_Base): return [ counter.Counter(name='disk.root.size', type=counter.TYPE_GAUGE, + unit='B', volume=message['payload']['root_gb'], user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], @@ -139,6 +143,7 @@ class EphemeralDiskSize(_Base): return [ counter.Counter(name='disk.ephemeral.size', type=counter.TYPE_GAUGE, + unit='B', volume=message['payload']['ephemeral_gb'], user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], @@ -160,6 +165,7 @@ class InstanceFlavor(_Base): counter.Counter( name='instance:%s' % instance_type, type=counter.TYPE_GAUGE, + unit='instance', volume=1, user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], diff --git a/ceilometer/compute/pollsters.py b/ceilometer/compute/pollsters.py index 3a38714b..158363af 100644 --- a/ceilometer/compute/pollsters.py +++ b/ceilometer/compute/pollsters.py @@ -35,10 +35,11 @@ def _instance_name(instance): return getattr(instance, 'OS-EXT-SRV-ATTR:instance_name', None) -def make_counter_from_instance(instance, name, type, volume): +def make_counter_from_instance(instance, name, type, unit, volume): return counter.Counter( name=name, type=type, + unit=unit, volume=volume, user_id=instance.user_id, project_id=instance.tenant_id, @@ -54,12 +55,14 @@ class InstancePollster(plugin.ComputePollster): yield make_counter_from_instance(instance, name='instance', type=counter.TYPE_GAUGE, + unit='instance', volume=1, ) yield make_counter_from_instance(instance, name='instance:%s' % instance.flavor['name'], type=counter.TYPE_GAUGE, + unit='instance', volume=1, ) @@ -96,21 +99,25 @@ class DiskIOPollster(plugin.ComputePollster): yield make_counter_from_instance(instance, name='disk.read.requests', type=counter.TYPE_CUMULATIVE, + unit='request', volume=r_requests, ) yield make_counter_from_instance(instance, name='disk.read.bytes', type=counter.TYPE_CUMULATIVE, + unit='B', volume=r_bytes, ) yield make_counter_from_instance(instance, name='disk.write.requests', type=counter.TYPE_CUMULATIVE, + unit='request', volume=w_requests, ) yield make_counter_from_instance(instance, name='disk.write.bytes', type=counter.TYPE_CUMULATIVE, + unit='B', volume=w_bytes, ) except Exception as err: @@ -160,11 +167,13 @@ class CPUPollster(plugin.ComputePollster): yield make_counter_from_instance(instance, name='cpu_util', type=counter.TYPE_GAUGE, + unit='%', volume=cpu_util, ) yield make_counter_from_instance(instance, name='cpu', type=counter.TYPE_CUMULATIVE, + unit='ns', volume=cpu_info.time, ) except Exception as err: @@ -181,7 +190,7 @@ class NetPollster(plugin.ComputePollster): "write-bytes=%d"]) @staticmethod - def make_vnic_counter(instance, name, type, volume, vnic_data): + def make_vnic_counter(instance, name, type, unit, volume, vnic_data): metadata = copy.copy(vnic_data) resource_metadata = dict(zip(metadata._fields, metadata)) resource_metadata['instance_id'] = instance.id @@ -191,6 +200,7 @@ class NetPollster(plugin.ComputePollster): return counter.Counter( name=name, type=type, + unit=unit, volume=volume, user_id=instance.user_id, project_id=instance.tenant_id, @@ -209,24 +219,28 @@ class NetPollster(plugin.ComputePollster): yield self.make_vnic_counter(instance, name='network.incoming.bytes', type=counter.TYPE_CUMULATIVE, + unit='B', volume=info.rx_bytes, vnic_data=vnic, ) yield self.make_vnic_counter(instance, name='network.outgoing.bytes', type=counter.TYPE_CUMULATIVE, + unit='B', volume=info.tx_bytes, vnic_data=vnic, ) yield self.make_vnic_counter(instance, name='network.incoming.packets', type=counter.TYPE_CUMULATIVE, + unit='packet', volume=info.rx_packets, vnic_data=vnic, ) yield self.make_vnic_counter(instance, name='network.outgoing.packets', type=counter.TYPE_CUMULATIVE, + unit='packet', volume=info.tx_packets, vnic_data=vnic, ) diff --git a/ceilometer/counter.py b/ceilometer/counter.py index 96a8a06c..3e874908 100644 --- a/ceilometer/counter.py +++ b/ceilometer/counter.py @@ -31,6 +31,7 @@ import collections # - cumulative: the value is incremented and never reset to 0 # - delta: the value is reset to 0 each time it is sent # - gauge: the value is an absolute value and is not a counter +# Unit: the unit of the counter # Volume: the counter value # User ID: the user ID # Project ID: the project ID @@ -41,6 +42,7 @@ Counter = collections.namedtuple('Counter', ' '.join([ 'name', 'type', + 'unit', 'volume', 'user_id', 'project_id', diff --git a/ceilometer/image/glance.py b/ceilometer/image/glance.py index 34a93471..f1aa5c2c 100644 --- a/ceilometer/image/glance.py +++ b/ceilometer/image/glance.py @@ -88,6 +88,7 @@ class ImagePollster(_Base): yield counter.Counter( name='image', type=counter.TYPE_GAUGE, + unit='image', volume=1, user_id=None, project_id=image.owner, @@ -104,6 +105,7 @@ class ImageSizePollster(_Base): yield counter.Counter( name='image.size', type=counter.TYPE_GAUGE, + unit='B', volume=image.size, user_id=None, project_id=image.owner, diff --git a/ceilometer/image/notifications.py b/ceilometer/image/notifications.py index 7d46c798..926d87fa 100644 --- a/ceilometer/image/notifications.py +++ b/ceilometer/image/notifications.py @@ -90,6 +90,7 @@ class ImageCRUD(ImageCRUDBase): counter.Counter( name=message['event_type'], type=counter.TYPE_DELTA, + unit='event', volume=1, resource_id=message['payload']['id'], user_id=None, @@ -108,6 +109,7 @@ class Image(ImageCRUDBase): counter.Counter( name='image', type=counter.TYPE_GAUGE, + unit='image', volume=1, resource_id=message['payload']['id'], user_id=None, @@ -126,6 +128,7 @@ class ImageSize(ImageCRUDBase): counter.Counter( name='image.size', type=counter.TYPE_GAUGE, + unit='B', volume=message['payload']['size'], resource_id=message['payload']['id'], user_id=None, @@ -153,6 +156,7 @@ class ImageDownload(ImageBase): counter.Counter( name='image.download', type=counter.TYPE_DELTA, + unit='B', volume=message['payload']['bytes_sent'], resource_id=message['payload']['image_id'], user_id=message['payload']['receiver_user_id'], @@ -181,6 +185,7 @@ class ImageServe(ImageBase): counter.Counter( name='image.serve', type=counter.TYPE_DELTA, + unit='B', volume=message['payload']['bytes_sent'], resource_id=message['payload']['image_id'], user_id=None, diff --git a/ceilometer/network/floatingip.py b/ceilometer/network/floatingip.py index 7bafb77b..8b148d6d 100644 --- a/ceilometer/network/floatingip.py +++ b/ceilometer/network/floatingip.py @@ -35,6 +35,7 @@ class FloatingIPPollster(plugin.CentralPollster): yield counter.Counter( name='ip.floating', type=counter.TYPE_GAUGE, + unit='ip', volume=1, user_id=None, project_id=ip.project_id, diff --git a/ceilometer/network/notifications.py b/ceilometer/network/notifications.py index c733c034..4c11aae6 100644 --- a/ceilometer/network/notifications.py +++ b/ceilometer/network/notifications.py @@ -75,6 +75,7 @@ class NetworkNotificationBase(plugin.NotificationBase): yield counter.Counter(name=counter_name, type=counter.TYPE_GAUGE, + unit=self.resource_name, volume=1, user_id=message['_context_user_id'], project_id=message['payload']['tenant_id'], @@ -88,6 +89,7 @@ class NetworkNotificationBase(plugin.NotificationBase): yield counter.Counter(name=counter_name + "." + event_type_split[1], type=counter.TYPE_DELTA, + unit=self.resource_name, volume=1, user_id=message['_context_user_id'], project_id=message['payload']['tenant_id'], diff --git a/ceilometer/objectstore/swift.py b/ceilometer/objectstore/swift.py index 2943648d..f0bff7f3 100644 --- a/ceilometer/objectstore/swift.py +++ b/ceilometer/objectstore/swift.py @@ -58,6 +58,7 @@ class _Base(plugin.PollsterBase): name='storage.objects', type=counter.TYPE_GAUGE, volume=int(account['x-account-object-count']), + unit='object', user_id=None, project_id=tenant, resource_id=tenant, @@ -68,6 +69,7 @@ class _Base(plugin.PollsterBase): name='storage.objects.size', type=counter.TYPE_GAUGE, volume=int(account['x-account-bytes-used']), + unit='B', user_id=None, project_id=tenant, resource_id=tenant, @@ -78,6 +80,7 @@ class _Base(plugin.PollsterBase): name='storage.objects.containers', type=counter.TYPE_GAUGE, volume=int(account['x-account-container-count']), + unit='container', user_id=None, project_id=tenant, resource_id=tenant, diff --git a/ceilometer/objectstore/swift_middleware.py b/ceilometer/objectstore/swift_middleware.py index 23532021..3b88b8ff 100644 --- a/ceilometer/objectstore/swift_middleware.py +++ b/ceilometer/objectstore/swift_middleware.py @@ -92,6 +92,7 @@ class CeilometerMiddleware(object): counter.Counter( name='storage.objects.incoming.bytes', type='delta', + unit='B', volume=bytes_received, user_id=env.get('HTTP_X_USER_ID'), project_id=env.get('HTTP_X_TENANT_ID'), @@ -113,6 +114,7 @@ class CeilometerMiddleware(object): counter.Counter( name='storage.objects.outgoing.bytes', type='delta', + unit='B', volume=bytes_sent, user_id=env.get('HTTP_X_USER_ID'), project_id=env.get('HTTP_X_TENANT_ID'), diff --git a/ceilometer/storage/base.py b/ceilometer/storage/base.py index 1bb80ced..ad37e801 100644 --- a/ceilometer/storage/base.py +++ b/ceilometer/storage/base.py @@ -109,6 +109,7 @@ class Connection(object): { 'name': name of the meter, 'type': type of the meter (guage, counter), + 'unit': unit of the meter, 'resource_id': UUID of the resource, 'project_id': UUID of project owning the resource, 'user_id': UUID of user owning the resource, diff --git a/ceilometer/storage/impl_mongodb.py b/ceilometer/storage/impl_mongodb.py index 84bc027d..9a872b50 100644 --- a/ceilometer/storage/impl_mongodb.py +++ b/ceilometer/storage/impl_mongodb.py @@ -55,7 +55,8 @@ class MongoDBStorage(base.StorageEngine): timestamp: datetime of last update user_id: uuid project_id: uuid - meter: [ array of {counter_name: string, counter_type: string} ] + meter: [ array of {counter_name: string, counter_type: string, + counter_unit: string} ] } """ @@ -272,6 +273,7 @@ class Connection(base.Connection): }, '$addToSet': {'meter': {'counter_name': data['counter_name'], 'counter_type': data['counter_type'], + 'counter_unit': data['counter_unit'], }, }, }, @@ -364,6 +366,7 @@ class Connection(base.Connection): { 'name': name of the meter, 'type': type of the meter (guage, counter), + 'unit': unit of the meter, 'resource_id': UUID of the resource, 'project_id': UUID of project owning the resource, 'user_id': UUID of user owning the resource, @@ -391,6 +394,7 @@ class Connection(base.Connection): m = {} m['name'] = r_meter['counter_name'] m['type'] = r_meter['counter_type'] + m['unit'] = r_meter['counter_unit'] m['resource_id'] = r['_id'] m['project_id'] = r['project_id'] m['user_id'] = r['user_id'] diff --git a/ceilometer/storage/impl_sqlalchemy.py b/ceilometer/storage/impl_sqlalchemy.py index 2581fd7b..99d8dbd9 100644 --- a/ceilometer/storage/impl_sqlalchemy.py +++ b/ceilometer/storage/impl_sqlalchemy.py @@ -50,6 +50,7 @@ class SQLAlchemyStorage(base.StorageEngine): resource_id: resource uuid (->resource.id) resource_metadata: metadata dictionaries counter_type: counter type + counter_unit: counter unit counter_volume: counter volume timestamp: datetime message_signature: message signature @@ -184,6 +185,7 @@ class Connection(base.Connection): # Record the raw data for the event. meter = Meter(counter_type=data['counter_type'], + counter_unit=data['counter_unit'], counter_name=data['counter_name'], resource=resource) self.session.add(meter) if not filter(lambda x: x.id == source.id, meter.sources): @@ -274,6 +276,7 @@ class Connection(base.Connection): { 'name': name of the meter, 'type': type of the meter (guage, counter), + 'unit': unit of the meter, 'resource_id': UUID of the resource, 'project_id': UUID of project owning the resource, 'user_id': UUID of user owning the resource, @@ -311,6 +314,7 @@ class Connection(base.Connection): m['user_id'] = resource.user_id m['name'] = meter.counter_name m['type'] = meter.counter_type + m['unit'] = meter.counter_unit yield m def get_raw_events(self, event_filter): diff --git a/ceilometer/storage/impl_test.py b/ceilometer/storage/impl_test.py index 5115268c..31e12544 100644 --- a/ceilometer/storage/impl_test.py +++ b/ceilometer/storage/impl_test.py @@ -55,7 +55,8 @@ class TestDBStorage(base.StorageEngine): timestamp: datetime of last update user_id: uuid project_id: uuid - meter: [ array of {counter_name: string, counter_type: string} ] + meter: [ array of {counter_name: string, counter_type: string, + counter_unit: string} ] } """ diff --git a/ceilometer/storage/sqlalchemy/migrate_repo/versions/004_add_counter_unit.py b/ceilometer/storage/sqlalchemy/migrate_repo/versions/004_add_counter_unit.py new file mode 100644 index 00000000..559db730 --- /dev/null +++ b/ceilometer/storage/sqlalchemy/migrate_repo/versions/004_add_counter_unit.py @@ -0,0 +1,33 @@ +# -*- encoding: utf-8 -*- +# +# Author: Guillaume Pernot +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from sqlalchemy import * + +meta = MetaData() + + +def upgrade(migrate_engine): + meta.bind = migrate_engine + meter = Table('meter', meta, autoload=True) + unit = Column('counter_unit', String(255)) + meter.create_column(unit) + + +def downgrade(migrate_engine): + meta.bind = migrate_engine + meter = Table('meter', meta, autoload=True) + unit = Column('counter_unit', String(255)) + meter.drop_column(unit) diff --git a/ceilometer/storage/sqlalchemy/models.py b/ceilometer/storage/sqlalchemy/models.py index 24b2416f..c1de1a44 100644 --- a/ceilometer/storage/sqlalchemy/models.py +++ b/ceilometer/storage/sqlalchemy/models.py @@ -103,6 +103,7 @@ class Meter(Base): resource_id = Column(String(255), ForeignKey('resource.id')) resource_metadata = Column(JSONEncodedDict) counter_type = Column(String(255)) + counter_unit = Column(String(255)) counter_volume = Column(Integer) timestamp = Column(DateTime, default=timeutils.utcnow) message_signature = Column(String) diff --git a/ceilometer/volume/notifications.py b/ceilometer/volume/notifications.py index b3742a87..f02155d5 100644 --- a/ceilometer/volume/notifications.py +++ b/ceilometer/volume/notifications.py @@ -71,6 +71,7 @@ class Volume(_Base): return [ counter.Counter(name='volume', type=counter.TYPE_GAUGE, + unit='volume', volume=1, user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], @@ -88,6 +89,7 @@ class VolumeSize(_Base): return [ counter.Counter(name='volume.size', type=counter.TYPE_GAUGE, + unit='B', volume=message['payload']['size'], user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], diff --git a/doc/source/measurements.rst b/doc/source/measurements.rst index 7b71d4e8..3e8e990d 100644 --- a/doc/source/measurements.rst +++ b/doc/source/measurements.rst @@ -34,90 +34,100 @@ Gauge Discrete items (floating IPs, image uploads) and fluctuating values Delta Changing over time (bandwidth) ========== ============================================================================== +Units should use common abbreviatons: + +============ ======== ============== ===== +Dimension Unit Abbreviations Note +============ ======== ============== ===== +None N/A Dimension-less variable +Volume byte B +Time seconds s + +Information units should be expressed in bits ('b') or bytes ('B'). Here are the meter types by components that are currently implemented: Compute (Nova) ============== -======================== ========== ======= ======== ======================================================= -Name Type Volume Resource Note -======================== ========== ======= ======== ======================================================= -instance Gauge 1 inst ID Duration of instance -instance: Gauge 1 inst ID Duration of instance (openstack types) -memory Gauge MB inst ID Volume of RAM in MB -cpu Cumulative ns inst ID CPU time used -vcpus Gauge vcpu inst ID Number of VCPUs -disk.root.size Gauge GB inst ID Size of root disk in GB -disk.ephemeral.size Gauge GB inst ID Size of ephemeral disk in GB -disk.io.requests Cumulative request inst ID Number of disk io requests -disk.io.bytes Cumulative bytes inst ID Volume of disk io in bytes -network.incoming.bytes Cumulative bytes iface ID number of incoming bytes on the network -network.outgoing.bytes Cumulative bytes iface ID number of outgoing bytes on the network -network.incoming.packets Cumulative packets iface ID number of incoming packets -network.outgoing.packets Cumulative packets iface ID number of outgoing packets -======================== ========== ======= ======== ======================================================= +======================== ========== ======== ======== ======================================================= +Name Type Unit Resource Note +======================== ========== ======== ======== ======================================================= +instance Gauge inst ID Duration of instance +instance: Gauge inst ID Duration of instance (openstack types) +memory Gauge B inst ID Volume of RAM in MB +cpu Cumulative ns inst ID CPU time used +vcpus Gauge vcpu inst ID Number of VCPUs +disk.root.size Gauge B inst ID Size of root disk in GB +disk.ephemeral.size Gauge B inst ID Size of ephemeral disk in GB +disk.io.requests Cumulative requests inst ID Number of disk io requests +disk.io.bytes Cumulative B inst ID Volume of disk io in bytes +network.incoming.bytes Cumulative B iface ID number of incoming bytes on the network +network.outgoing.bytes Cumulative B iface ID number of outgoing bytes on the network +network.incoming.packets Cumulative packets iface ID number of incoming packets +network.outgoing.packets Cumulative packets iface ID number of outgoing packets +======================== ========== ======== ======== ======================================================= Network (Quantum) ================= -======================== ========== ======= ======== ======================================================= -Name Type Volume Resource Note -======================== ========== ======= ======== ======================================================= -network Gauge 1 netw ID Duration of network -network.create Delta request netw ID Creation requests for this network -network.update Delta request netw ID Update requests for this network -subnet Gauge 1 subnt ID Duration of subnet -subnet.create Delta request subnt ID Creation requests for this subnet -subnet.update Delta request subnt ID Update requests for this subnet -port Gauge 1 port ID Duration of port -port.create Delta request port ID Creation requests for this port -port.update Delta request port ID Update requests for this port -router Gauge 1 rtr ID Duration of router -router.create Delta request rtr ID Creation requests for this router -router.update Delta request rtr ID Update requests for this router -ip.floating Gauge 1 ip ID Duration of floating ip -ip.floating.create Delta 1 ip ID Creation requests for this floating ip -ip.floating.update Delta 1 ip ID Update requests for this floating ip -======================== ========== ======= ======== ======================================================= +======================== ========== ======== ======== ====================================================== +Name Type Unit Resource Note +======================== ========== ======== ======== ====================================================== +network Gauge network netw ID Duration of network +network.create Delta network netw ID Creation requests for this network +network.update Delta network netw ID Update requests for this network +subnet Gauge subnet subnt ID Duration of subnet +subnet.create Delta subnet subnt ID Creation requests for this subnet +subnet.update Delta subnet subnt ID Update requests for this subnet +port Gauge port port ID Duration of port +port.create Delta port port ID Creation requests for this port +port.update Delta port port ID Update requests for this port +router Gauge router rtr ID Duration of router +router.create Delta router rtr ID Creation requests for this router +router.update Delta router rtr ID Update requests for this router +ip.floating Gauge ip ip ID Duration of floating ip +ip.floating.create Delta ip ip ID Creation requests for this floating ip +ip.floating.update Delta ip ip ID Update requests for this floating ip +======================== ========== ======== ======== ====================================================== Image (Glance) ============== ======================== ========== ======= ======== ======================================================= -Name Type Volume Resource Note +Name Type Unit Resource Note ======================== ========== ======= ======== ======================================================= -image Gauge 1 image ID Image polling -> it (still) exists -image.size Gauge bytes image ID Uploaded image size -image.update Delta reqs image ID Number of update on the image -image.upload Delta reqs image ID Number of upload of the image -image.delete Delta reqs image ID Number of delete on the image -image.download Delta bytes image ID Image is downloaded -image.serve Delta bytes image ID Image is served out +image Gauge image image ID Image polling -> it (still) exists +image.size Gauge B image ID Uploaded image size +image.update Delta image image ID Number of update on the image +image.upload Delta image image ID Number of upload of the image +image.delete Delta image image ID Number of delete on the image +image.download Delta B image ID Image is downloaded +image.serve Delta B image ID Image is served out ======================== ========== ======= ======== ======================================================= Volume (Cinder) =============== ======================== ========== ======= ======== ======================================================= -Name Type Volume Resource Note +Name Type Unit Resource Note ======================== ========== ======= ======== ======================================================= -volume Gauge 1 vol ID Duration of volune -volume.size Gauge GB vol ID Size of volume +volume Gauge volume vol ID Duration of volune +volume.size Gauge GiB vol ID Size of volume ======================== ========== ======= ======== ======================================================= Object Storage (Swift) ====================== -========================== ========== ========== ======== ================================================== +========================== ========== ========== ======== ============================================== Name Type Volume Resource Note -========================== ========== ========== ======== ================================================== +========================== ========== ========== ======== ============================================== storage.objects Gauge objects store ID Number of objects -storage.objects.size Gauge bytes store ID Total size of stored objects +storage.objects.size Gauge B store ID Total size of stored objects storage.objects.containers Gauge containers store ID Number of containers -storage.objects.incoming.bytes Delta bytes store ID Number of incoming bytes -storage.objects.outgoing.bytes Delta bytes store ID Number of outgoing bytes -============================== ========== ========== ======== ================================================== +storage.objects.incoming.bytes Delta B store ID Number of incoming bytes +storage.objects.outgoing.bytes Delta B store ID Number of outgoing bytes +============================== ========== ========== ======== ============================================== Dynamically retrieving the Meters via ceilometer client ======================================================= diff --git a/tests/api/v1/test_list_events.py b/tests/api/v1/test_list_events.py index bff8b9fd..42d73ff1 100644 --- a/tests/api/v1/test_list_events.py +++ b/tests/api/v1/test_list_events.py @@ -39,6 +39,7 @@ class TestListEvents(tests_api.TestBase): counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project1', @@ -51,6 +52,7 @@ class TestListEvents(tests_api.TestBase): counter.Counter( 'instance', 'cumulative', + '', 2, 'user-id', 'project1', @@ -63,6 +65,7 @@ class TestListEvents(tests_api.TestBase): counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project2', diff --git a/tests/api/v1/test_list_meters.py b/tests/api/v1/test_list_meters.py index 99a1f3ea..eb453501 100644 --- a/tests/api/v1/test_list_meters.py +++ b/tests/api/v1/test_list_meters.py @@ -47,6 +47,7 @@ class TestListMeters(tests_api.TestBase): counter.Counter( 'meter.test', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -58,6 +59,7 @@ class TestListMeters(tests_api.TestBase): counter.Counter( 'meter.test', 'cumulative', + '', 3, 'user-id', 'project-id', @@ -69,6 +71,7 @@ class TestListMeters(tests_api.TestBase): counter.Counter( 'meter.mine', 'gauge', + '', 1, 'user-id', 'project-id', @@ -80,6 +83,7 @@ class TestListMeters(tests_api.TestBase): counter.Counter( 'meter.test', 'cumulative', + '', 1, 'user-id2', 'project-id2', @@ -91,6 +95,7 @@ class TestListMeters(tests_api.TestBase): counter.Counter( 'meter.mine', 'gauge', + '', 1, 'user-id4', 'project-id2', diff --git a/tests/api/v1/test_list_projects.py b/tests/api/v1/test_list_projects.py index c09393f2..96c5fc98 100644 --- a/tests/api/v1/test_list_projects.py +++ b/tests/api/v1/test_list_projects.py @@ -45,6 +45,7 @@ class TestListProjects(tests_api.TestBase): counter1 = counter.Counter( 'instance', 'cumulative', + 'instance', 1, 'user-id', 'project-id', @@ -63,6 +64,7 @@ class TestListProjects(tests_api.TestBase): counter2 = counter.Counter( 'instance', 'cumulative', + 'instance', 1, 'user-id2', 'project-id2', diff --git a/tests/api/v1/test_list_resources.py b/tests/api/v1/test_list_resources.py index b623dda4..a4cbabcf 100644 --- a/tests/api/v1/test_list_resources.py +++ b/tests/api/v1/test_list_resources.py @@ -47,6 +47,7 @@ class TestListResources(tests_api.TestBase): counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -58,6 +59,7 @@ class TestListResources(tests_api.TestBase): counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -69,6 +71,7 @@ class TestListResources(tests_api.TestBase): counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project-id2', @@ -80,6 +83,7 @@ class TestListResources(tests_api.TestBase): counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', diff --git a/tests/api/v1/test_list_users.py b/tests/api/v1/test_list_users.py index 49676b2c..b01889f6 100644 --- a/tests/api/v1/test_list_users.py +++ b/tests/api/v1/test_list_users.py @@ -46,6 +46,7 @@ class TestListUsers(tests_api.TestBase): counter1 = counter.Counter( 'instance', 'cumulative', + 'instance', 1, 'user-id', 'project-id', @@ -64,6 +65,7 @@ class TestListUsers(tests_api.TestBase): counter2 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project-id', diff --git a/tests/api/v1/test_max_project_volume.py b/tests/api/v1/test_max_project_volume.py index 9b55cf23..7592b846 100644 --- a/tests/api/v1/test_max_project_volume.py +++ b/tests/api/v1/test_max_project_volume.py @@ -40,6 +40,7 @@ class TestMaxProjectVolume(tests_api.TestBase): c = counter.Counter( 'volume.size', 'gauge', + 'GiB', 5 + i, 'user-id', 'project1', diff --git a/tests/api/v1/test_max_resource_volume.py b/tests/api/v1/test_max_resource_volume.py index 9032cdeb..382a6164 100644 --- a/tests/api/v1/test_max_resource_volume.py +++ b/tests/api/v1/test_max_resource_volume.py @@ -39,6 +39,7 @@ class TestMaxResourceVolume(tests_api.TestBase): c = counter.Counter( 'volume.size', 'gauge', + 'GiB', 5 + i, 'user-id', 'project1', diff --git a/tests/api/v1/test_sum_project_volume.py b/tests/api/v1/test_sum_project_volume.py index c6e95d5b..556750ab 100644 --- a/tests/api/v1/test_sum_project_volume.py +++ b/tests/api/v1/test_sum_project_volume.py @@ -40,6 +40,7 @@ class TestSumProjectVolume(tests_api.TestBase): c = counter.Counter( 'volume.size', 'gauge', + 'GiB', 5 + i, 'user-id', 'project1', diff --git a/tests/api/v1/test_sum_resource_volume.py b/tests/api/v1/test_sum_resource_volume.py index 647d73fc..7832e893 100644 --- a/tests/api/v1/test_sum_resource_volume.py +++ b/tests/api/v1/test_sum_resource_volume.py @@ -40,6 +40,7 @@ class TestSumResourceVolume(tests_api.TestBase): c = counter.Counter( 'volume.size', 'gauge', + 'GiB', 5 + i, 'user-id', 'project1', diff --git a/tests/api/v2/test_list_events.py b/tests/api/v2/test_list_events.py index bb2a224e..0b3baa8c 100644 --- a/tests/api/v2/test_list_events.py +++ b/tests/api/v2/test_list_events.py @@ -37,6 +37,7 @@ class TestListEvents(FunctionalTest): self.counter1 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project1', @@ -57,6 +58,7 @@ class TestListEvents(FunctionalTest): self.counter2 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project2', diff --git a/tests/api/v2/test_list_meters.py b/tests/api/v2/test_list_meters.py index 2ec59f89..820f9635 100644 --- a/tests/api/v2/test_list_meters.py +++ b/tests/api/v2/test_list_meters.py @@ -46,6 +46,7 @@ class TestListMeters(FunctionalTest): counter.Counter( 'meter.test', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -57,6 +58,7 @@ class TestListMeters(FunctionalTest): counter.Counter( 'meter.test', 'cumulative', + '', 3, 'user-id', 'project-id', @@ -68,6 +70,7 @@ class TestListMeters(FunctionalTest): counter.Counter( 'meter.mine', 'gauge', + '', 1, 'user-id', 'project-id', @@ -79,6 +82,7 @@ class TestListMeters(FunctionalTest): counter.Counter( 'meter.test', 'cumulative', + '', 1, 'user-id2', 'project-id2', @@ -90,6 +94,7 @@ class TestListMeters(FunctionalTest): counter.Counter( 'meter.mine', 'gauge', + '', 1, 'user-id4', 'project-id2', diff --git a/tests/api/v2/test_list_projects.py b/tests/api/v2/test_list_projects.py index 240f9be1..df8c5449 100644 --- a/tests/api/v2/test_list_projects.py +++ b/tests/api/v2/test_list_projects.py @@ -41,6 +41,7 @@ class TestListProjects(FunctionalTest): counter1 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -59,6 +60,7 @@ class TestListProjects(FunctionalTest): counter2 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project-id2', @@ -81,6 +83,7 @@ class TestListProjects(FunctionalTest): counter1 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -99,6 +102,7 @@ class TestListProjects(FunctionalTest): counter2 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project-id2', diff --git a/tests/api/v2/test_list_resources.py b/tests/api/v2/test_list_resources.py index abea10cd..d2feaa36 100644 --- a/tests/api/v2/test_list_resources.py +++ b/tests/api/v2/test_list_resources.py @@ -42,6 +42,7 @@ class TestListResources(FunctionalTest): counter1 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -60,6 +61,7 @@ class TestListResources(FunctionalTest): counter2 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -82,6 +84,7 @@ class TestListResources(FunctionalTest): counter1 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -100,6 +103,7 @@ class TestListResources(FunctionalTest): counter2 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project-id', @@ -123,6 +127,7 @@ class TestListResources(FunctionalTest): counter1 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -141,6 +146,7 @@ class TestListResources(FunctionalTest): counter2 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project-id', @@ -164,6 +170,7 @@ class TestListResources(FunctionalTest): counter1 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -182,6 +189,7 @@ class TestListResources(FunctionalTest): counter2 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project-id2', @@ -205,6 +213,7 @@ class TestListResources(FunctionalTest): counter1 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', diff --git a/tests/api/v2/test_list_users.py b/tests/api/v2/test_list_users.py index 07f5b940..96d98810 100644 --- a/tests/api/v2/test_list_users.py +++ b/tests/api/v2/test_list_users.py @@ -43,6 +43,7 @@ class TestListUsers(FunctionalTest): counter1 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -61,6 +62,7 @@ class TestListUsers(FunctionalTest): counter2 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project-id', @@ -83,6 +85,7 @@ class TestListUsers(FunctionalTest): counter1 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id', 'project-id', @@ -101,6 +104,7 @@ class TestListUsers(FunctionalTest): counter2 = counter.Counter( 'instance', 'cumulative', + '', 1, 'user-id2', 'project-id', diff --git a/tests/api/v2/test_max_project_volume.py b/tests/api/v2/test_max_project_volume.py index 94b70ce1..1d48bd91 100644 --- a/tests/api/v2/test_max_project_volume.py +++ b/tests/api/v2/test_max_project_volume.py @@ -42,6 +42,7 @@ class TestMaxProjectVolume(FunctionalTest): c = counter.Counter( 'volume.size', 'gauge', + 'GiB', 5 + i, 'user-id', 'project1', diff --git a/tests/api/v2/test_max_resource_volume.py b/tests/api/v2/test_max_resource_volume.py index 941f8917..6c1827a6 100644 --- a/tests/api/v2/test_max_resource_volume.py +++ b/tests/api/v2/test_max_resource_volume.py @@ -41,6 +41,7 @@ class TestMaxResourceVolume(FunctionalTest): c = counter.Counter( 'volume.size', 'gauge', + 'GiB', 5 + i, 'user-id', 'project1', diff --git a/tests/api/v2/test_sum_project_volume.py b/tests/api/v2/test_sum_project_volume.py index 5f25e9dd..afac21a5 100644 --- a/tests/api/v2/test_sum_project_volume.py +++ b/tests/api/v2/test_sum_project_volume.py @@ -41,6 +41,7 @@ class TestSumProjectVolume(FunctionalTest): c = counter.Counter( 'volume.size', 'gauge', + 'GiB', 5 + i, 'user-id', 'project1', diff --git a/tests/api/v2/test_sum_resource_volume.py b/tests/api/v2/test_sum_resource_volume.py index 2bf2cdf3..4fb690e7 100644 --- a/tests/api/v2/test_sum_resource_volume.py +++ b/tests/api/v2/test_sum_resource_volume.py @@ -41,6 +41,7 @@ class TestSumResourceVolume(FunctionalTest): c = counter.Counter( 'volume.size', 'gauge', + 'GiB', 5 + i, 'user-id', 'project1', diff --git a/tests/collector/test_meter.py b/tests/collector/test_meter.py index dab0da15..f9c40c57 100644 --- a/tests/collector/test_meter.py +++ b/tests/collector/test_meter.py @@ -101,6 +101,7 @@ def test_verify_signature_nested(): TEST_COUNTER = counter.Counter(name='name', type='typ', + unit='', volume=1, user_id='user', project_id='project', @@ -160,6 +161,7 @@ def test_meter_message_from_counter_field(): 'src') name_map = {'name': 'counter_name', 'type': 'counter_type', + 'unit': 'counter_unit', 'volume': 'counter_volume', } for f in TEST_COUNTER._fields: diff --git a/tests/compute/test_manager.py b/tests/compute/test_manager.py index 84f4b30c..05a5848d 100644 --- a/tests/compute/test_manager.py +++ b/tests/compute/test_manager.py @@ -45,6 +45,7 @@ class TestRunTasks(base.TestCase): test_data = counter.Counter( name='test', type=counter.TYPE_CUMULATIVE, + unit='', volume=1, user_id='test', project_id='test', diff --git a/tests/compute/test_nova_notifier.py b/tests/compute/test_nova_notifier.py index 80be7fdb..81e65e87 100644 --- a/tests/compute/test_nova_notifier.py +++ b/tests/compute/test_nova_notifier.py @@ -59,6 +59,7 @@ class TestNovaNotifier(base.TestCase): test_data = counter.Counter( name='test', type=counter.TYPE_CUMULATIVE, + unit='', volume=1, user_id='test', project_id='test', diff --git a/tests/storage/test_impl_mongodb.py b/tests/storage/test_impl_mongodb.py index f034c125..71967fb9 100644 --- a/tests/storage/test_impl_mongodb.py +++ b/tests/storage/test_impl_mongodb.py @@ -73,6 +73,7 @@ class MongoDBEngineTestBase(unittest.TestCase): self.counter = counter.Counter( 'instance', counter.TYPE_CUMULATIVE, + '', 1, 'user-id', 'project-id', @@ -90,6 +91,7 @@ class MongoDBEngineTestBase(unittest.TestCase): self.counter2 = counter.Counter( 'instance', counter.TYPE_CUMULATIVE, + '', 1, 'user-id', 'project-id', @@ -107,6 +109,7 @@ class MongoDBEngineTestBase(unittest.TestCase): self.counter3 = counter.Counter( 'instance', counter.TYPE_CUMULATIVE, + '', 1, 'user-id-alternate', 'project-id', @@ -125,6 +128,7 @@ class MongoDBEngineTestBase(unittest.TestCase): c = counter.Counter( 'instance', counter.TYPE_CUMULATIVE, + '', 1, 'user-id-%s' % i, 'project-id-%s' % i, @@ -217,6 +221,7 @@ class ResourceTest(MongoDBEngineTestBase): assert 'meter' in resource assert resource['meter'] == [{'counter_name': 'instance', 'counter_type': 'cumulative', + 'counter_unit': '', }] def test_new_resource_metadata(self): @@ -235,6 +240,7 @@ class ResourceTest(MongoDBEngineTestBase): assert 'metadata' in resource assert resource['meter'] == [{'counter_name': 'instance', 'counter_type': 'cumulative', + 'counter_unit': '', }] break else: @@ -458,6 +464,7 @@ class TestGetEventInterval(MongoDBEngineTestBase): c = counter.Counter( name='instance', type=counter.TYPE_CUMULATIVE, + unit='', volume=1, user_id='user-id', project_id='project-id', diff --git a/tests/storage/test_impl_sqlalchemy.py b/tests/storage/test_impl_sqlalchemy.py index 78161d66..36d881be 100644 --- a/tests/storage/test_impl_sqlalchemy.py +++ b/tests/storage/test_impl_sqlalchemy.py @@ -97,6 +97,7 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase): self.counter = counter.Counter( 'instance', counter.TYPE_CUMULATIVE, + unit='', volume=1, user_id='user-id', project_id='project-id', @@ -115,6 +116,7 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase): self.counter2 = counter.Counter( 'instance', counter.TYPE_CUMULATIVE, + unit='', volume=1, user_id='user-id', project_id='project-id', @@ -133,6 +135,7 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase): self.counter3 = counter.Counter( 'instance', counter.TYPE_CUMULATIVE, + unit='', volume=1, user_id='user-id-alternate', project_id='project-id', @@ -152,10 +155,11 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase): c = counter.Counter( 'instance', counter.TYPE_CUMULATIVE, - 1, - 'user-id-%s' % i, - 'project-id-%s' % i, - 'resource-id-%s' % i, + unit='', + volume=1, + user_id='user-id-%s' % i, + project_id='project-id-%s' % i, + resource_id='resource-id-%s' % i, timestamp=datetime.datetime(2012, 7, 2, 10, 40 + i), resource_metadata={'display_name': 'test-server', 'tag': 'counter-%s' % i, @@ -466,6 +470,7 @@ class TestGetEventInterval(SQLAlchemyEngineTestBase): c = counter.Counter( 'instance', counter.TYPE_CUMULATIVE, + '', 1, '11', '1', @@ -584,6 +589,7 @@ class MaxProjectTest(SQLAlchemyEngineSubBase): c = counter.Counter( 'volume.size', 'gauge', + 'GiB', 5 + i, 'user-id', 'project1', @@ -662,6 +668,7 @@ class MaxResourceTest(SQLAlchemyEngineSubBase): c = counter.Counter( 'volume.size', 'gauge', + 'GiB', 5 + i, 'user-id', 'project1', diff --git a/tests/test_publish.py b/tests/test_publish.py index 90309581..a72196b6 100644 --- a/tests/test_publish.py +++ b/tests/test_publish.py @@ -32,6 +32,7 @@ class TestPublish(base.TestCase): test_data = counter.Counter( name='test', type=counter.TYPE_CUMULATIVE, + unit='', volume=1, user_id='test', project_id='test', diff --git a/tools/make_test_data.py b/tools/make_test_data.py index f06b634b..5b9a48de 100755 --- a/tools/make_test_data.py +++ b/tools/make_test_data.py @@ -60,6 +60,11 @@ def main(): default='gauge', help='counter type', ) + parser.add_argument( + '--unit', + default=None, + help='counter unit', + ) parser.add_argument( '--project', help='project id of owner', @@ -115,6 +120,7 @@ def main(): while timestamp <= end: c = counter.Counter(name=args.counter, type=args.type, + unit=args.unit, volume=args.volume, user_id=args.user, project_id=args.project,