目标:
掌握ceilometer资源模型与主要表的表结构
目录:
1 进入数据库
2 event表
3 总结
1 进入数据库
cat /etc/ceilometer/ceilometer.conf |grep mongo
event_connection = mongodb://ceilometer:216MeiPY@mongodb.openstack.svc.cluster.local:27017/ceilometer
mongo
MongoDB shell version v3.4.10
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.10
> use ceilometer;
switched to db ceilometer
> db.auth('ceilometer', '216MeiPY');
1
> show collections;
event
2 event表
作用: 存储云平台的事件
表结构:
字段 属性 描述
_id ObjectID 主健,mongodb中唯一标识事件的ID
timestamp ISODate 事件发生时间
event_type string 事件类型
traits array 该事件的属性数组,数组中每个元素是一个字典,
每个字典形如:
{
"trait_type" : 1,
"trait_name" : "resource_id",
"trait_value" : "7fa004dd-d880-4928-8fe2-99d5928dcb9a"
}
其中: trait_type标识该属性的类型(字符串,整型还是其他等), trait_name表示事件属性名称, trait_value
表示该事件属性的值
查看该表的索引:
> db.event.getIndexes();
[
{
"v" : 2,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "ceilometer.event"
},
{
"v" : 2,
"key" : {
"timestamp" : -1
},
"name" : "index_timestamp",
"ns" : "ceilometer.event",
"background" : true
},
{
"v" : 2,
"key" : {
"timestamp" : -1,
"traits.trait_name" : 1,
"traits.trait_value" : 1
},
"name" : "index_by_trait_timestamp",
"ns" : "ceilometer.event",
"background" : true
},
{
"v" : 2,
"key" : {
"event_type" : 1,
"timestamp" : 1
},
"name" : "event_type_idx",
"ns" : "ceilometer.event"
}
]
样例: 以创建云主机事件为例
db.event.findOne({'event_type': 'compute.instance.create.end'});
{
"_id" : "bb7406c2-cddd-4692-ae22-92b724b6b1d2",
"raw" : {
},
"timestamp" : ISODate("2020-06-08T06:20:14.383Z"),
"event_type" : "compute.instance.create.end",
"traits" : [
{
"trait_type" : 2,
"trait_name" : "memory_mb",
"trait_value" : 512
},
{
"trait_type" : 1,
"trait_name" : "resource_id",
"trait_value" : "7fa004dd-d880-4928-8fe2-99d5928dcb9a"
},
{
"trait_type" : 2,
"trait_name" : "ephemeral_gb",
"trait_value" : 0
},
{
"trait_type" : 2,
"trait_name" : "instance_type_id",
"trait_value" : 211
},
{
"trait_type" : 1,
"trait_name" : "user_id",
"trait_value" : "8c49145bbbab409a90bbc7e570c61403"
},
{
"trait_type" : 1,
"trait_name" : "service",
"trait_value" : "compute"
},
{
"trait_type" : 1,
"trait_name" : "state",
"trait_value" : "active"
},
{
"trait_type" : 1,
"trait_name" : "project_id",
"trait_value" : "8a0ef29ca2a04af7bd39860d89016014"
},
{
"trait_type" : 4,
"trait_name" : "launched_at",
"trait_value" : ISODate("2020-06-08T06:20:14.153Z")
},
{
"trait_type" : 1,
"trait_name" : "resource_name",
"trait_value" : "instance-D6UTJS"
},
{
"trait_type" : 2,
"trait_name" : "disk_gb",
"trait_value" : 0
},
{
"trait_type" : 1,
"trait_name" : "host",
"trait_value" : "node-1.domain.tld"
},
{
"trait_type" : 2,
"trait_name" : "root_gb",
"trait_value" : 0
},
{
"trait_type" : 1,
"trait_name" : "tenant_id",
"trait_value" : "8a0ef29ca2a04af7bd39860d89016014"
},
{
"trait_type" : 4,
"trait_name" : "created_at",
"trait_value" : ISODate("2020-06-08T06:19:55Z")
},
{
"trait_type" : 1,
"trait_name" : "instance_id",
"trait_value" : "7fa004dd-d880-4928-8fe2-99d5928dcb9a"
},
{
"trait_type" : 1,
"trait_name" : "instance_type",
"trait_value" : "1C-0.5G"
},
{
"trait_type" : 2,
"trait_name" : "vcpus",
"trait_value" : 1
},
{
"trait_type" : 1,
"trait_name" : "request_id",
"trait_value" : "req-887f09af-38d8-4e49-b9de-56bda814d956"
},
{
"trait_type" : 1,
"trait_name" : "instance_flavor_id",
"trait_value" : "211"
}
]
}
3 总结
由于alarm表在aodh中,resource和metric表在gnocchi中,所以ceilometer中主要就剩event表。
参考:
N版本ceilometer代码