Wednesday, May 4, 2016

Access Ceilometer From Mongodb

ceiloinmongo

How to access ceilometer metering data in mongodb

Login to mongo

mongo

in the mongo command line.

> show databases
ceilometer  0.203125GB
local   0.078125GB
test    (empty)

where ceilometer is the target database.

> use ceilometer
switched to db ceilometer

Now we can access meter by the following command line.

> db.meter.find({'counter_name': 'cpu_util'})
{ "_id" : ObjectId("572abb0d8899ecc4934ba0e3"), "counter_name" : "cpu_util", "user_id" : "5d20839a1f004184af00c0337ad465e6", "resource_id" : "89ab162e-c4c1-43b0-8fa1-f1d00c966670", "timestamp" : ISODate("2016-05-05T03:16:29Z"), "message_signature" : "e61807753e00f46f674e003654ea3890ff3e64dd11d531641b3c86d27a17f2ae", "message_id" : "c28d889a-126f-11e6-bb00-daee9837900f", "source" : "openstack", "counter_unit" : "%", "counter_volume" : 0.7963272120200334, "recorded_at" : ISODate("2016-05-05T03:16:29.619Z"), "project_id" : "d09a300d75be4449a6e6e17d2c958c16", "resource_metadata" : { "status" : "active", "cpu_number" : 1, "ephemeral_gb" : 0, "display_name" : "test1", "name" : "instance-00000001", "disk_gb" : 1, "kernel_id" : "2726d40f-59b7-434e-97c8-1fa696d36fcc", "image" : { "id" : "065979b0-9cf3-465c-ba6a-4a639c043f24", "links" : [    {   "href" : "http://172.16.235.128:8774/ed7875aa4a2c49fd9be1bec8b2831f5f/images/065979b0-9cf3-465c-ba6a-4a639c043f24",     "rel" : "bookmark" } ], "name" : "cirros-0.3.3-x86_64-uec" }, "ramdisk_id" : "05afa5f3-77bb-4cc0-9da3-d5a2fe08a8ca", "vcpus" : 1, "memory_mb" : 512, "instance_type" : "m1.tiny", "host" : "4b6ed7e550773a27812816bfa0587f1bd9bc8b40457a6210560d9889", "root_gb" : 1, "image_ref" : "065979b0-9cf3-465c-ba6a-4a639c043f24", "flavor" : { "name" : "m1.tiny", "links" : [    {   "href" : "http://172.16.235.128:8774/ed7875aa4a2c49fd9be1bec8b2831f5f/flavors/1",   "rel" : "bookmark" } ], "ram" : 512, "ephemeral" : 0, "vcpus" : 1, "disk" : 1, "id" : "1" }, "OS-EXT-AZ:availability_zone" : "nova", "image_ref_url" : "http://172.16.235.128:8774/ed7875aa4a2c49fd9be1bec8b2831f5f/images/065979b0-9cf3-465c-ba6a-4a639c043f24" }, "counter_type" : "gauge" }

or

> db.meter.find({'counter_name': 'disk.read.bytes'})
{ "_id" : ObjectId("572ab8b58899ecc4934ba09e"), "counter_name" : "disk.read.bytes", "user_id" : "5d20839a1f004184af00c0337ad465e6", "resource_id" : "89ab162e-c4c1-43b0-8fa1-f1d00c966670", "timestamp" : ISODate("2016-05-05T03:06:29Z"), "message_signature" : "6942720a12b800247ad62f160464bd4090732dec717aeeb7b199eaf0829e3874", "message_id" : "5d166a1e-126e-11e6-bb00-daee9837900f", "source" : "openstack", "counter_unit" : "B", "counter_volume" : 1025314, "recorded_at" : ISODate("2016-05-05T03:06:29.891Z"), "project_id" : "d09a300d75be4449a6e6e17d2c958c16", "resource_metadata" : { "status" : "active", "ephemeral_gb" : 0, "display_name" : "test1", "name" : "instance-00000001", "disk_gb" : 1, "kernel_id" : "2726d40f-59b7-434e-97c8-1fa696d36fcc", "image" : { "id" : "065979b0-9cf3-465c-ba6a-4a639c043f24", "links" : [  {   "href" : "http://172.16.235.128:8774/ed7875aa4a2c49fd9be1bec8b2831f5f/images/065979b0-9cf3-465c-ba6a-4a639c043f24",     "rel" : "bookmark" } ], "name" : "cirros-0.3.3-x86_64-uec" }, "ramdisk_id" : "05afa5f3-77bb-4cc0-9da3-d5a2fe08a8ca", "vcpus" : 1, "memory_mb" : 512, "instance_type" : "m1.tiny", "host" : "4b6ed7e550773a27812816bfa0587f1bd9bc8b40457a6210560d9889", "root_gb" : 1, "image_ref" : "065979b0-9cf3-465c-ba6a-4a639c043f24", "device" : [  "vda",  "hdd" ], "flavor" : { "name" : "m1.tiny", "links" : [     {   "href" : "http://172.16.235.128:8774/ed7875aa4a2c49fd9be1bec8b2831f5f/flavors/1",   "rel" : "bookmark" } ], "ram" : 512, "ephemeral" : 0, "vcpus" : 1, "disk" : 1, "id" : "1" }, "OS-EXT-AZ:availability_zone" : "nova", "image_ref_url" : "http://172.16.235.128:8774/ed7875aa4a2c49fd9be1bec8b2831f5f/images/065979b0-9cf3-465c-ba6a-4a639c043f24" }, "counter_type" : "cumulative" }

more option

one can use

db.meter.find({'counter_name': 'xxx.xxx.xxx'})

where xxx can be seen by horizon statistics such as * disk.read.bytes * disk.read.bytes.rate * netwrok.incoming.bytes

Timestamp related operation

> db.meter.find({'timestamp':{ $gte:ISODate("2016-05-05T04:55:00.501Z")}})

{ "_id" : ObjectId("572ad3778899ec0f0f190765"), "counter_name" : "vcpus", "user_id" : "5d20839a1f004184af00c0337ad465e6", "resource_id" : "c6e6f66b-2a81-4304-a6e7-d125f60ae39a", "timestamp" : ISODate("2016-05-05T05:00:37.169Z"), "message_signature" : "c86d6c5c5ad2a30fb2fcbc2e602ad91306ec1d753de0b4b09461e8a8bbf4a8e4", "message_id" : "4f4b248c-127e-11e6-9fea-000c29b23333", "source" : "openstack", "counter_unit" : "vcpu", "counter_volume" : 1, "recorded_at" : ISODate("2016-05-05T05:00:39.327Z"), "project_id" : "d09a300d75be4449a6e6e17d2c958c16", "resource_metadata" : { "state_description" : "", "event_type" : "compute.instance.exists", "availability_zone" : "nova", "terminated_at" : "", "ephemeral_gb" : 0, "instance_type_id" : 2, "bandwidth" : {  }, "deleted_at" : "", "reservation_id" : "r-ocbm818x", "instance_id" : "c6e6f66b-2a81-4304-a6e7-d125f60ae39a", "display_name" : "te2", "hostname" : "te2", "state" : "active", "progress" : "", "launched_at" : "2016-05-05T03:37:07.000000", "node" : "kiloceilomongo", "ramdisk_id" : "05afa5f3-77bb-4cc0-9da3-d5a2fe08a8ca", "access_ip_v6" : null, "disk_gb" : 1, "access_ip_v4" : null, "kernel_id" : "2726d40f-59b7-434e-97c8-1fa696d36fcc", "host" : "compute.kiloceilomongo", "user_id" : "5d20839a1f004184af00c0337ad465e6", "image_ref_url" : "http://172.16.235.128:9292/images/065979b0-9cf3-465c-ba6a-4a639c043f24", "cell_name" : "", "audit_period_beginning" : "2016-05-05 04:00:00", "root_gb" : 1, "tenant_id" : "d09a300d75be4449a6e6e17d2c958c16", "created_at" : "2016-05-05 03:37:01+00:00", "memory_mb" : 512, "instance_type" : "m1.tiny", "vcpus" : 1, "image_meta" : { "kernel_id" : "2726d40f-59b7-434e-97c8-1fa696d36fcc", "container_format" : "ami", "min_ram" : "0", "ramdisk_id" : "05afa5f3-77bb-4cc0-9da3-d5a2fe08a8ca", "disk_format" : "ami", "min_disk" : "1", "base_image_ref" : "065979b0-9cf3-465c-ba6a-4a639c043f24" }, "architecture" : null, "audit_period_ending" : "2016-05-05 05:00:00", "os_type" : null, "instance_flavor_id" : "1" }, "counter_type" : "gauge" }

multiple query

The following command shows the meter network.outgoing.packets.rate and greater than some timestamp.

db.meter.find({$and:[{'a':'b'},{'c':'d'}]})

The real one is

> db.meter.find( {$and: [{'timestamp':{ $gte:ISODate("2016-05-05T04:30:00.501Z")}},{"counter_name" : "network.outgoing.packets.rate"}]})

{ "_id" : ObjectId("572ad6948899ec0f0f190822"), "counter_name" : "network.outgoing.packets.rate", "user_id" : "5d20839a1f004184af00c0337ad465e6", "resource_id" : "instance-00000002-c6e6f66b-2a81-4304-a6e7-d125f60ae39a-tapa6fd8f75-94", "timestamp" : ISODate("2016-05-05T05:13:56Z"), "message_signature" : "c984c0f4ebafb7a69f5259bfd74ea404fb5de3954829de452795d7d33b1fd26b", "message_id" : "2adbb164-1280-11e6-9fea-000c29b23333", "source" : "openstack", "counter_unit" : "packet/s", "counter_volume" : 0, "recorded_at" : ISODate("2016-05-05T05:13:56.574Z"), "project_id" : "d09a300d75be4449a6e6e17d2c958c16", "resource_metadata" : { "name" : "tapa6fd8f75-94", "parameters" : {  }, "fref" : null, "instance_id" : "c6e6f66b-2a81-4304-a6e7-d125f60ae39a", "instance_type" : "1", "mac" : "fa:16:3e:96:65:4c" }, "counter_type" : "gauge" }
{ "_id" : ObjectId("572ad6948899ec0f0f190823"), "counter_name" : "network.outgoing.packets.rate", "user_id" : "5d20839a1f004184af00c0337ad465e6", "resource_id" : "instance-00000001-89ab162e-c4c1-43b0-8fa1-f1d00c966670-tapda6bc8d6-2a", "timestamp" : ISODate("2016-05-05T05:13:56Z"), "message_signature" : "1d40aa3babbdd0a13961e5859b2f9cb4eca36067ee9c365bfb2134c739094a8a", "message_id" : "2add22a6-1280-11e6-9fea-000c29b23333", "source" : "openstack", "counter_unit" : "packet/s", "counter_volume" : 0, "recorded_at" : ISODate("2016-05-05T05:13:56.577Z"), "project_id" : "d09a300d75be4449a6e6e17d2c958c16", "resource_metadata" : { "name" : "tapda6bc8d6-2a", "parameters" : {  }, "fref" : null, "instance_id" : "89ab162e-c4c1-43b0-8fa1-f1d00c966670", "instance_type" : "1", "mac" : "fa:16:3e:79:70:c3" }, "counter_type" : "gauge" }

No comments:

Post a Comment