ceilometer命令行使用方法(下篇)

达芬奇密码2018-08-23 10:02

sample list

然后就是sample list的使用 -m 指定是哪个meter -q 查询 resource 指定刚才 meter-list里面查询出来的resource。

hzhuangzhexiao@10-180-2-112:~$ ceilometer sample-list -m  netease.cpu.rate  -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate" -l 10
+-------------------------------------------------------+------------------+-------+----------------+------+---------------------+
| Resource ID                                           | Name             | Type  | Volume         | Unit | Timestamp           |
+-------------------------------------------------------+------------------+-------+----------------+------+---------------------+
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.700466977985 | %    | 2016-03-16T08:34:12 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.4329004329   | %    | 2016-03-16T08:33:42 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.800266755585 | %    | 2016-03-16T08:33:12 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.532268795742 | %    | 2016-03-16T08:32:42 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.801068090788 | %    | 2016-03-16T08:32:12 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.435365036839 | %    | 2016-03-16T08:31:42 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.714528751276 | %    | 2016-03-16T08:31:12 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.456323337679 | %    | 2016-03-16T08:30:43 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.90331214453  | %    | 2016-03-16T08:30:12 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.366056572379 | %    | 2016-03-16T08:29:42 |
+-------------------------------------------------------+------------------+-------+----------------+------+---------------------+


ceilometer statistics

ceilometer statistics -m  netease.cpu.rate  -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate;timestamp<2016-03-16T08:34:37;timestamp>2016-03-15T01:34:37" 


hzhuangzhexiao@10-180-2-112:~$ ceilometer statistics -m  netease.cpu.rate  -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate;timestamp<2016-03-16T08:34:37;timestamp>2016-03-15T01:34:37" 

+--------+---------------------+---------------------+-------+----------------+---------------+-------------+-------+----------+---------------------+---------------------+
| Period | Period Start        | Period End          | Max   | Min            | Avg           | Sum         | Count | Duration | Duration Start      | Duration End        |
+--------+---------------------+---------------------+-------+----------------+---------------+-------------+-------+----------+---------------------+---------------------+
| 0      | 2016-03-16T06:35:59 | 2016-03-16T08:34:12 | 100.0 | 0.066467264872 | 10.0118438734 | 2372.806998 | 237   | 7093.0   | 2016-03-16T06:35:59 | 2016-03-16T08:34:12 |
+--------+---------------------+---------------------+-------+----------------+---------------+-------------+-------+----------+---------------------+---------------------+

加上 -p参数,设置时间的粒度

hzhuangzhexiao@10-180-2-112:~$ ceilometer statistics -m  netease.cpu.rate  -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate;timestamp<2016-03-16T08:34:37;timestamp>2016-03-16T08:24:37"  -p 60


hzhuangzhexiao@10-180-2-112:~$ ceilometer statistics -m  netease.cpu.rate  -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate;timestamp<2016-03-16T08:34:37;timestamp>2016-03-16T08:24:37"  -p 60
+--------+---------------------+---------------------+----------------+----------------+----------------+---------------+-------+----------+---------------------+---------------------+
| Period | Period Start        | Period End          | Max            | Min            | Avg            | Sum           | Count | Duration | Duration Start      | Duration End        |
+--------+---------------------+---------------------+----------------+----------------+----------------+---------------+-------+----------+---------------------+---------------------+
| 60     | 2016-03-16T08:24:37 | 2016-03-16T08:25:37 | 2.66933600267  | 0.800266755585 | 1.73480137913  | 3.46960275825 | 2     | 30.0     | 2016-03-16T08:24:42 | 2016-03-16T08:25:12 |
| 60     | 2016-03-16T08:25:37 | 2016-03-16T08:26:37 | 0.730654267685 | 0.5            | 0.615327133843 | 1.23065426769 | 2     | 30.0     | 2016-03-16T08:25:42 | 2016-03-16T08:26:12 |
| 60     | 2016-03-16T08:26:37 | 2016-03-16T08:27:37 | 0.866089273817 | 0.535833891494 | 0.700961582656 | 1.40192316531 | 2     | 30.0     | 2016-03-16T08:26:42 | 2016-03-16T08:27:12 |
| 60     | 2016-03-16T08:27:37 | 2016-03-16T08:28:37 | 0.867244829887 | 0.333333333333 | 0.60028908161  | 1.20057816322 | 2     | 30.0     | 2016-03-16T08:27:42 | 2016-03-16T08:28:12 |
| 60     | 2016-03-16T08:28:37 | 2016-03-16T08:29:37 | 0.733333333333 | 0.633544514838 | 0.683438924086 | 1.36687784817 | 2     | 30.0     | 2016-03-16T08:28:42 | 2016-03-16T08:29:12 |
| 60     | 2016-03-16T08:29:37 | 2016-03-16T08:30:37 | 0.90331214453  | 0.366056572379 | 0.634684358455 | 1.26936871691 | 2     | 30.0     | 2016-03-16T08:29:42 | 2016-03-16T08:30:12 |
| 60     | 2016-03-16T08:30:37 | 2016-03-16T08:31:37 | 0.714528751276 | 0.456323337679 | 0.585426044478 | 1.17085208896 | 2     | 29.0     | 2016-03-16T08:30:43 | 2016-03-16T08:31:12 |
| 60     | 2016-03-16T08:31:37 | 2016-03-16T08:32:37 | 0.801068090788 | 0.435365036839 | 0.618216563813 | 1.23643312763 | 2     | 30.0     | 2016-03-16T08:31:42 | 2016-03-16T08:32:12 |
| 60     | 2016-03-16T08:32:37 | 2016-03-16T08:33:37 | 0.800266755585 | 0.532268795742 | 0.666267775664 | 1.33253555133 | 2     | 30.0     | 2016-03-16T08:32:42 | 2016-03-16T08:33:12 |
| 60     | 2016-03-16T08:33:37 | 2016-03-16T08:34:37 | 0.700466977985 | 0.4329004329   | 0.566683705443 | 1.13336741089 | 2     | 30.0     | 2016-03-16T08:33:42 | 2016-03-16T08:34:12 |
+--------+---------------------+---------------------+----------------+----------------+----------------+---------------+-------+----------+---------------------+---------------------+
hzhuangzhexiao@10-180-2-112:~$


命令行参数指定 tips :

  1. -q中指定多个过滤条件的方法:用分号连接,各个过滤条件之间是与的关系。 若要用并关系或者按counter_volume取值查询,目前估计只能用query-sample 这个CLI

    ceilometer …… -q "resource=xxx ; timestamp<yyy"

  2. 目前只有在访问meter表的代码里用到get_meter方法中才支持通配, 即$ ceilometer meter-list -q resource=通配表达式其余的-q参数中虽然指定resource的值,但是最后没有落到get_meter方法来处理,还是无法通配。

  3. -q <QUERY>的后接参数不同命令支持的-q范围不一样,大抵因为访问的表不同。

  4. -q 后接参数中的resource=xxx,其中的xxx是uuid+维度名的形式

  5. -m 后接的meter_name,只是维度名,不含uuid

  6. statistics指定多个groupby参数作为分组依据的方法:

    ceilometer statistics …… -g "project_id" -g "user_id"

  1. statistics对于cardinality公式的参数给法示例: ceilometer statistics -m cpu -a 'cardinality<-project_id'
  2. query-samples 对于counter_volume(具体的采样值)的指定时,数值不能加双引号不能加双引号不能加双引号

  3. search_offset这个过滤参数的含义: 该参数指定了以分钟为单位的偏移值,必须和timestamp参数一起搭配使用,举例如

  ceilometer sample-list -q “timestamp<xxx;search\_offset=9"

那么就会把这个timestamp指定的时间之后的9分钟内的样本一起返回。

参考文档



相关阅读:ceilometer命令行使用方法(上篇)

网易云新用户大礼包:https://www.163yun.com/gift

本文来自网易实践者社区,经作者黄哲骁授权发布。