beautiful printing for curl
add | python -m json.tool
to check which meters that ceilometer supported.
http://zqfan.github.io/assets/doc/ceilometer-havana-api-v2.html
to show whole system disk write byte using a statistics
curl -H 'X-Auth-Token: 90872f53cf534bf98292693ffe31c1ac' -H 'Content-Type: application/json' http://localhost:8777/v2/meters/disk.write.bytes/statistics
you can change disk.write.bytes to
http://www.openstack.cn/p861.html
such as cpu_util …..
take avg or sum
curl -H 'X-Auth-Token: 90872f53cf534bf98292693ffe31c1ac' -H 'Content-Type: application/json' http://localhost:8777/v2/meters/cpu_util/statistics?aggregate.func=avg
get resource information
curl -H 'X-Auth-Token: 90872f53cf534bf98292693ffe31c1ac' -H 'Content-Type: application/json' http://localhost:8777/v2/resources/f8a524a1-11c2-4620-bffa-bcc8f5014793
will show tenant_id ……
get project cpu_util information
curl -H 'X-Auth-Token: 90872f53cf534bf98292693ffe31c1ac' -H 'Content-Type: application/json' "http://localhost:8777/v2/meters/cpu_util/statistics?q.field=timestamp&q.op=ge&q.value=2014-08-20T13:34:17&q.field=project_id&q.op=eq&q.value=9aff044df2d44839bd36ee98e08ffa88"
query for a instance
curl -H 'X-Auth-Token: 90872f53cf534bf98292693ffe31c1ac' -H 'Content-Type: application/json' "http://localhost:8777/v2/meters/cpu_util/statistics?q.field=timestamp&q.op=ge&q.value=2014-08-20T13:34:17&q.field=resource_id&q.op=eq&q.value=664615f2-c9b2-4c5b-b3df-68e9f5616a1b"
An example for query filter need “ ”
curl -X GET -H 'X-Auth-Token: 90872f53cf534bf98292693ffe31c1ac' "http://localhost:8777/v2/meters/instance?q.field=metadata.event_type&q.value=compute.instance.exists"
curl -H 'X-Auth-Token: 90872f53cf534bf98292693ffe31c1ac' -H 'Content-Type: application/json' "http://localhost:8777/v2/meters/cpu_util/statistics?q.field=timestamp&q.op=ge&q.value=2014-08-20T13:34:17"
for multiple query:
curl -H 'X-Auth-Token: 90872f53cf534bf98292693ffe31c1ac' -H 'Content-Type: application/json' "http://localhost:8777/v2/meters/cpu_util/statistics?q.field=timestamp&q.op=ge&q.value=2014-08-20T13:34:17&q.field=timestamp&q.op=le&q.value=2014-08-30T13:00:00"
simple test in bash
token='90872f53cf534bf98292693ffe31c1ac'
curl -H "X-Auth-Token: $token" -H 'Content-Type: application/json' http://localhost:8777/v2/meters/network.incoming.packets/statistics
python code to provide you a billing method for a given tenant including statistics of diskio and networkio and cpu usage.
from six.moves.urllib import parse |