Ask Your Question
0

How to parse rabbitmq output

asked 2015-07-13 03:00:47 -0500

anonymous user

Anonymous

updated 2015-07-13 03:02:14 -0500

This is my rabbitmq logs using python pika

js={'oslo.message': '{"_context_domain": null, "_context_roles": ["admin"], "_context_quota_class": null, "event_type": "compute.instance.power_off.start", "_context_request_id": "req-8bb9db00-548f-4280-974c-f7f3d2c342e7", "_context_service_catalog": [{"endpoints": [{"adminURL": "http://172.168.2.34:8776/v2/c660dc50982c4d1da63fd1499b1ec459", "region": "RegionOne", "internalURL": "http://172.168.2.34:8776/v2/c660dc50982c4d1da63fd1499b1ec459", "publicURL": "http://172.168.2.34:8776/v2/c660dc50982c4d1da63fd1499b1ec459"}], "type": "volumev2", "name": "cinderv2"}, {"endpoints": [{"adminURL": "http://172.168.2.34:8776/v1/c660dc50982c4d1da63fd1499b1ec459", "region": "RegionOne", "internalURL": "http://172.168.2.34:8776/v1/c660dc50982c4d1da63fd1499b1ec459", "publicURL": "http://172.168.2.34:8776/v1/c660dc50982c4d1da63fd1499b1ec459"}], "type": "volume", "name": "cinder"}], "timestamp": "2015-07-13 07:48:47.252630", "_context_user": "475a8860971f46a4965132e98be1f162", "_unique_id": "4fb380229e8645eb8960234edd38c881", "_context_resource_uuid": null, "_context_instance_lock_checked": false, "_context_user_id": "475a8860971f46a4965132e98be1f162", "payload": {"state_description": "powering-off", "availability_zone": "nova", "terminated_at": "", "ephemeral_gb": 0, "instance_type_id": 5, "deleted_at": "", "reservation_id": "r-yicw9x1t", "instance_id": "1168675f-175b-40a5-b53a-2e77379c6606", "display_name": "vm-2", "hostname": "vm-2", "state": "active", "progress": "", "launched_at": "2015-07-04T13:06:07.000000", "metadata": {}, "node": "horizon-VirtualBox", "ramdisk_id": "8a18f462-479b-4c5a-a776-005b23e2fa3d", "access_ip_v6": null, "disk_gb": 20, "access_ip_v4": null, "kernel_id": "3703cd2c-0b04-4429-bec9-4dbe057a6774", "host": "horizon-VirtualBox", "user_id": "475a8860971f46a4965132e98be1f162", "image_ref_url": "http://172.168.2.34:9292/images/55f53c81-cfa1-471d-91c7-d0bf1e826ebb", "cell_name": "", "root_gb": 20, "tenant_id": "c660dc50982c4d1da63fd1499b1ec459", "created_at": "2015-07-04 13:05:43+00:00", "memory_mb": 2048, "instance_type": "m1.small", "vcpus": 1, "image_meta": {"kernel_id": "3703cd2c-0b04-4429-bec9-4dbe057a6774", "container_format": "ami", "min_ram": "0", "ramdisk_id": "8a18f462-479b-4c5a-a776-005b23e2fa3d", "disk_format": "ami", "min_disk": "20", "base_image_ref": "55f53c81-cfa1-471d-91c7-d0bf1e826ebb"}, "architecture": null, "os_type": null, "instance_flavor_id": "2"}, "_context_project_name": "admin", "_context_read_deleted": "no", "_context_user_identity": "475a8860971f46a4965132e98be1f162 c660dc50982c4d1da63fd1499b1ec459 - - -", "_context_auth_token": "5062d29cd3bb42109a39a2bf00e4e9fb", "_context_show_deleted": false, "_context_tenant": "c660dc50982c4d1da63fd1499b1ec459", "priority": "INFO", "_context_read_only": false, "_context_is_admin": true, "_context_project_id": "c660dc50982c4d1da63fd1499b1ec459", "_context_project_domain": null, "_context_timestamp": "2015-07-13T07:48:45.991953", "_context_user_domain": null, "_context_user_name": "admin", "publisher_id": "compute.horizon-VirtualBox", "message_id": "33580bff-e53e-406f-bc89-6136c6e25299", "_context_remote_address": "172.168.2.34"}', 'oslo.version': '2.0'}

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-07-14 10:30:20 -0500

Ranjit gravatar image
   >>> import json

>>> js={'oslo.message': '{"_context_domain": null, "_context_roles": ["admin"], "_context_quota_class": null, "event_type": "compute.instance.power_off.start", "_context_request_id": "req-8bb9db00-548f-4280-974c-f7f3d2c342e7", "_context_service_catalog": [{"endpoints": [{"adminURL": "http://172.168.2.34:8776/v2/c660dc50982c4d1da63fd1499b1ec459", "region": "RegionOne", "internalURL": "http://172.168.2.34:8776/v2/c660dc50982c4d1da63fd1499b1ec459", "publicURL": "http://172.168.2.34:8776/v2/c660dc50982c4d1da63fd1499b1ec459"}], "type": "volumev2", "name": "cinderv2"}, {"endpoints": [{"adminURL": "http://172.168.2.34:8776/v1/c660dc50982c4d1da63fd1499b1ec459", "region": "RegionOne", "internalURL": "http://172.168.2.34:8776/v1/c660dc50982c4d1da63fd1499b1ec459", "publicURL": "http://172.168.2.34:8776/v1/c660dc50982c4d1da63fd1499b1ec459"}], "type": "volume", "name": "cinder"}], "timestamp": "2015-07-13 07:48:47.252630", "_context_user": "475a8860971f46a4965132e98be1f162", "_unique_id": "4fb380229e8645eb8960234edd38c881", "_context_resource_uuid": null, "_context_instance_lock_checked": false, "_context_user_id": "475a8860971f46a4965132e98be1f162", "payload": {"state_description": "powering-off", "availability_zone": "nova", "terminated_at": "", "ephemeral_gb": 0, "instance_type_id": 5, "deleted_at": "", "reservation_id": "r-yicw9x1t", "instance_id": "1168675f-175b-40a5-b53a-2e77379c6606", "display_name": "vm-2", "hostname": "vm-2", "state": "active", "progress": "", "launched_at": "2015-07-04T13:06:07.000000", "metadata": {}, "node": "horizon-VirtualBox", "ramdisk_id": "8a18f462-479b-4c5a-a776-005b23e2fa3d", "access_ip_v6": null, "disk_gb": 20, "access_ip_v4": null, "kernel_id": "3703cd2c-0b04-4429-bec9-4dbe057a6774", "host": "horizon-VirtualBox", "user_id": "475a8860971f46a4965132e98be1f162", "image_ref_url": "http://172.168.2.34:9292/images/55f53c81-cfa1-471d-91c7-d0bf1e826ebb", "cell_name": "", "root_gb": 20, "tenant_id": "c660dc50982c4d1da63fd1499b1ec459", "created_at": "2015-07-04 13:05:43+00:00", "memory_mb": 2048, "instance_type": "m1.small", "vcpus": 1, "image_meta": {"kernel_id": "3703cd2c-0b04-4429-bec9-4dbe057a6774", "container_format": "ami", "min_ram": "0", "ramdisk_id": "8a18f462-479b-4c5a-a776-005b23e2fa3d", "disk_format": "ami", "min_disk": "20", "base_image_ref": "55f53c81-cfa1-471d-91c7-d0bf1e826ebb"}, "architecture": null, "os_type": null, "instance_flavor_id": "2"}, "_context_project_name": "admin", "_context_read_deleted": "no", "_context_user_identity": "475a8860971f46a4965132e98be1f162 c660dc50982c4d1da63fd1499b1ec459 - - -", "_context_auth_token": "5062d29cd3bb42109a39a2bf00e4e9fb", "_context_show_deleted": false, "_context_tenant": "c660dc50982c4d1da63fd1499b1ec459", "priority": "INFO", "_context_read_only": false, "_context_is_admin": true, "_context_project_id": "c660dc50982c4d1da63fd1499b1ec459", "_context_project_domain": null, "_context_timestamp": "2015-07-13T07:48:45.991953", "_context_user_domain": null, "_context_user_name": "admin", "publisher_id": "compute.horizon-VirtualBox", "message_id": "33580bff-e53e-406f-bc89-6136c6e25299", "_context_remote_address": "172.168.2.34"}', 'oslo.version': '2.0'}



>>> parsed_json = json.loads(js['oslo.message'])



>>> print parsed_json['_context_service_catalog']
[{u'endpoints': [{u'adminURL': u'http://172.168.2.34:8776/v2/c660dc50982c4d1da63fd1499b1ec459', u'region': u'RegionOne', u'internalURL': u'
/172.168.2.34:8776/v2/c660dc50982c4d1da63fd1499b1ec459', u'publicURL': u'http://172.168.2.34:8776/v2/c660dc50982c4d1da63fd1499b1ec459'}], u
: u'volumev2', u'name': u'cinderv2'}, {u'endpoints': [{u'adminURL': u'http://172.168.2.34:8776/v1/c660dc50982c4d1da63fd1499b1ec459', u'regi
'RegionOne', u'internalURL': u'http://172.168.2.34:8776/v1/c660dc50982c4d1da63fd1499b1ec459', u'publicURL': u'http://172.168.2.34:8776/v1/c
0982c4d1da63fd1499b1ec459'}], u'type': u'volume', u'name': u'cinder'}]**

http://docs.python-guide.org/en/lates...

edit flag offensive delete link more

Comments

use the corresponding api if you want to do in script.

Ranjit gravatar imageRanjit ( 2015-07-14 10:32:55 -0500 )edit

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: 2015-07-13 03:00:47 -0500

Seen: 568 times

Last updated: Jul 14 '15