Ask Your Question
0

How to put constant value to ceilometer resource attribute

asked 2019-05-23 05:15:34 -0500

mozart89 gravatar image

Hello, community. I have openstack with several regions: US1, EU1. I have resource "instance_network_interface" with my custom attribute "region_id". My goal is to do "gnocchi measures aggregation ... --groupby project_id --groupby region_id". What is the correct way to put constant attribute "region_id" to my resource.

This is what I want:

gnocchi measures aggregation ... --groupby project_id --groupby region_id

+---------------------------------------------+---------------------------+-------------+-------------------+
| group                                       | timestamp                 | granularity |             value |
+---------------------------------------------+---------------------------+-------------+-------------------+
| project_id: 0bd784e2...223, region_id: EU1  | 2019-05-18T03:00:00+03:00 |     86400.0     |      5959712333.0 |
| project_id: 0bd784e2...223, region_id: US1  | 2019-05-19T03:00:00+03:00 |     86400.0 |      5908975265.0 |
| project_id: 752ef33b...656, region_id: EU1  | 2019-05-18T03:00:00+03:00 |     86400.0     |      5952152165.0 |
| project_id: 752ef33b...656, region_id: US1  | 2019-05-19T03:00:00+03:00 |     86400.0     |      5958534802.0 |
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-05-27 04:32:31 -0500

mozart89 gravatar image

Good news)))

ceilometer/publisher/gnocchi.py:

    def sample_attributes(self, sample):
    attrs = {}
    sample_dict = sample.as_dict()

    for name, definition in self._attributes.items():
        value = definition.parse(sample_dict)
        if value is not None:
            attrs[name] = value
    return attrs

sample.as_dict() -

{
'user_id': u'923...0f2',
'name': u'network.incoming.delta',
'resource_id': u'instance-00000027-a00...03b-tapb330714d-fb',
'timestamp': u'2019-05-27T09: 00: 57.684200',
'resource_metadata': {
    u'instance_host': u'os-host1',
    u'image': {
        u'id': u'e2b8...c47'
    },
    u'ephemeral_gb': 0,
    u'flavor': {
        u'name': u'basic1.xs',
        u'ram': 1024,
        u'ephemeral': 0,
        u'vcpus': 1,
        u'swap': 0,
        u'disk': 20,
        u'id': u'643...d2a'
    },
    u'memory_mb': 1024,
    u'display_name': u'deleteme4',
    u'parameters': {

    },
    u'state': u'running',
    u'status': u'active',
    u'disk_gb': 20,
    u'fref': None,
    u'mac': u'fa... 39',
    u'task_state': u'',
    u'image_ref_url': None,
    u'root_gb': 20,
    u'name': u'tapb330714d-fb',
    u'host': u'b86...332',
    u'vnic_name': u'tapb330714d-fb',
    u'instance_id': u'a0091...03b',
    u'instance_type': u'basic1.xs',
    u'vcpus': 1,
    u'image_ref': u'e2b...c47',
    u'architecture': u'x86_64',
    u'os_type': u'hvm'
},
'volume': 0,
'source': 'openstack',
'unit': u'B',
'project_id': u'107...0bf',
'type': 'delta',
'id': 'f38...621',
'monotonic_time': None

}

So I just set instance_host instead of region_id:

  - resource_type: instance_network_interface
...
attributes:
  name: resource_metadata.vnic_name
  instance_id: resource_metadata.instance_id
  instance_host: resource_metadata.instance_host

Not exactly what I want but it's better than nothing :)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2019-05-23 05:11:09 -0500

Seen: 34 times

Last updated: May 27