gnocchi: add two new resources

This change add instance_network_interface and instance_disk to
Gnocchi dispatcher.

It also adds some missing metadata to samples to build the Gnocchi
resource.

Change-Id: Ic7babe73befbe0fff741d0c0c764ded493dc8c8e
This commit is contained in:
Mehdi Abaakouk 2015-09-17 00:18:50 +02:00
parent 0c279d885b
commit ac5811d758
5 changed files with 30 additions and 11 deletions

View File

@ -174,6 +174,7 @@ class PerDeviceReadRequestsPollster(_Base):
unit='request',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -207,6 +208,7 @@ class PerDeviceReadBytesPollster(_Base):
unit='B',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -240,6 +242,7 @@ class PerDeviceWriteRequestsPollster(_Base):
unit='request',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -273,6 +276,7 @@ class PerDeviceWriteBytesPollster(_Base):
unit='B',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -379,6 +383,7 @@ class PerDeviceReadBytesRatePollster(_DiskRatesPollsterBase):
unit='B/s',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -411,6 +416,7 @@ class PerDeviceReadRequestsRatePollster(_DiskRatesPollsterBase):
unit='requests/s',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -443,6 +449,7 @@ class PerDeviceWriteBytesRatePollster(_DiskRatesPollsterBase):
unit='B/s',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -475,6 +482,7 @@ class PerDeviceWriteRequestsRatePollster(_DiskRatesPollsterBase):
unit='requests/s',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -557,7 +565,8 @@ class PerDeviceDiskLatencyPollster(_DiskLatencyPollsterBase):
type=sample.TYPE_GAUGE,
unit='ms',
volume=value / 1000,
resource_id="%s-%s" % (instance.id, disk)
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -638,7 +647,8 @@ class PerDeviceDiskIOPSPollster(_DiskIOPSPollsterBase):
type=sample.TYPE_GAUGE,
unit='count/s',
volume=value,
resource_id="%s-%s" % (instance.id, disk)
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -745,6 +755,7 @@ class PerDeviceCapacityPollster(_DiskInfoPollsterBase):
unit='B',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -777,6 +788,7 @@ class PerDeviceAllocationPollster(_DiskInfoPollsterBase):
unit='B',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples
@ -809,5 +821,6 @@ class PerDevicePhysicalPollster(_DiskInfoPollsterBase):
unit='B',
volume=value,
resource_id="%s-%s" % (instance.id, disk),
additional_metadata={'disk_name': disk},
))
return samples

View File

@ -48,9 +48,11 @@ class _Base(pollsters.BaseComputePollster):
if vnic_data.fref is not None:
rid = vnic_data.fref
resource_metadata['vnic_name'] = vnic_data.fref
else:
instance_name = util.instance_name(instance)
rid = "%s-%s-%s" % (instance_name, instance.id, vnic_data.name)
resource_metadata['vnic_name'] = vnic_data.name
return sample.Sample(
name=name,

View File

@ -37,6 +37,7 @@ def _get_metadata_from_object(instance):
metadata = {
'display_name': instance.name,
'name': getattr(instance, 'OS-EXT-SRV-ATTR:instance_name', u''),
'instance_id': instance.id,
'instance_type': instance_type,
'host': instance.hostId,
'flavor': instance.flavor,

View File

@ -49,6 +49,8 @@ class TestLocationMetadata(base.BaseTestCase):
# Mimics an instance returned from nova api call
self.INSTANCE_PROPERTIES = {'name': 'display name',
'id': ('234cbe81-4e09-4f64-9b2a-'
'714f6b9046e3'),
'OS-EXT-SRV-ATTR:instance_name':
'instance-000001',
'OS-EXT-AZ:availability_zone':
@ -89,6 +91,8 @@ class TestLocationMetadata(base.BaseTestCase):
prop = "host"
elif prop == 'OS-EXT-SRV-ATTR:instance_name':
prop = 'name'
elif prop == "id":
prop = "instance_id"
self.assertEqual(value, md[prop])
user_metadata = md['user_metadata']
expected = self.INSTANCE_PROPERTIES[

View File

@ -64,10 +64,7 @@ resources:
flavor_id: resource_metadata.(instance_flavor_id|(flavor.id))
server_group: resource_metadata.user_metadata.server_group
# NOTE(sileht): We are not able the create this resource yet
# The resource id looks like: instance-00000001-1880d27c-678f-45bf-98ce-12e21e52a1c7-tap5f58854d-9d
- resource_type: instance-network
ignore: true
- resource_type: instance_network_interface
metrics:
- 'network.outgoing.packets.rate'
- 'network.incoming.packets.rate'
@ -77,12 +74,11 @@ resources:
- 'network.incoming.bytes.rate'
- 'network.outgoing.bytes'
- 'network.incoming.bytes'
attributes:
name: resource_metadata.vnic_name
instance_id: resource_metadata.instance_id
# NOTE(sileht): We are not able the create this resource yet
# The resource id looks like: 1880d27c-678f-45bf-98ce-12e21e52a1c7-hdd
- resource_type: instance-disk
ignore: true
- resource_type: instance_disk
metrics:
- 'disk.device.read.requests'
- 'disk.device.read.requests.rate'
@ -97,6 +93,9 @@ resources:
- 'disk.device.capacity'
- 'disk.device.allocation'
- 'disk.device.usage'
attributes:
name: resource_metadata.disk_name
instance_id: resource_metadata.instance_id
- resource_type: image
metrics: