Jump to: navigation, search

EfficientMetering/ConfigDrivenNotificationMonitoring

We should be able to create a configuration schema using an INI file (or set of INI files) to map notification messages from arbitrary exchanges to metering counter objects. For example, the notification translator for the instance counter is implemented as:


class Instance(_Base):

    @staticmethod
    def process_notification(message):
        metadata = instance.get_metadata_from_event(message)
        return [
            counter.Counter(source='?',
                            name='instance',
                            type='absolute',
                            volume=1,
                            user_id=message['payload']['user_id'],
                            project_id=message['payload']['tenant_id'],
                            resource_id=message['payload']['instance_id'],
                            timestamp=message['timestamp'],
                            duration=0,
                            resource_metadata=metadata,
                            ),
            ]


We just need a way to tell us where to get the counter fields, either using literal values (for something like source and name) or a notation that tells us to look inside the message for the payload/user_id value.

We should also be able to combine the values, so that the counter name, for example, could be set to something that combined a literal prefix like "instance:" with the instance type name from within the metadata for the resource.

Metadata is currently being processed by a resource-type-specific function (instance.get_metadata_from_event()). That function is a simple mapping, and we either need a way to reproduce it or a way to specify which metadata function should be used for a given message type.

I would like to be able to be able to create a file like /etc/ceilometer/notifications/compute.ini with contents like


[compute1]
events = compute.instance.create.end,compute.instance.exists,compute.instance.delete.start
source = ?
name = instance:$message.payload.instance_type
type = absolute
volume = 1
user_id = $message.payload.user_id
project_id = $message.payload.project_id
resource_id = $message.payload.instance_id
timestamp = $message.timestamp
resource_metadata_factory = instance