衡量云资源

衡量云资源

遥测技术用于OpenStack云资源。它收集了与计费相关的数据。目前,该计量服务只可通过: 命令: ‘ ceilometer ‘ 客户端命令行

对于模型数据,Telemetry使用如下抽象概念

计量

计量一种资源用量的特定指标,如运行中的实例数,或实时性能数据,如实例的CPU利用率。每种资源都有相应的计量。例如,每个实例都有其CPU利用率。一个计量项的生命周期与其关联的资源是相互独立的,资源销毁后其计量数据仍然存在。

计量器具有以下属性:

  • 字符串型变量name
  • 计量单位
  • 一种用以表明数值是否为单调递增的类型。可以被解释为与前一个值的变化(delta),或者是独立的,仅仅关联到当前时间间隔(gauge)
范例
一个与特定的表相关联的单个数据点。一个样本与相关联的表具有相同的属性,并添加了时间戳和值属性。值属性也被称为样本量的“”。
统计数值

一组聚集在连续时间段的数据。(相比而言,一个样例代表一个单一的数据点。)遥测服务采用了以下聚合函数:

  • count. 每个时期样例的数量
  • max. 每个时期样本量的最大值
  • min.每个时期样本量的最小值
  • avg.每个时期样本量的平均值
  • sum. 每个时期样本量的总和
警报
一组定义了监视器和当前状态并设置了目标状态阈值触发操作的规则。告警提供以用户为中心的监视即服务功能和供OpenStack使用的更加通用的功能。编排和自动伸缩是典型用例。告警有三种状态:ok, alarm, 和 insufficient data.对于传统的基于阈值的告警,状态变化是由一个静态的阈值和比较器来管理的。比较器将过去一定时间间隔内(可配置)的统计值与选定的计量项数值做比较。

该例中使用了:command:`openstack`客户端创建一个自动伸缩栈,使用:command:`ceilometer`客户端计量资源。

  1. Create an auto-scaling stack by running the following command. The -f option specifies the name of the stack template file, and the -P option specifies the KeyName parameter as heat_key:

    $ openstack stack create --template cfn/F17/AutoScalingCeilometer.yaml \
      --parameter "KeyName=heat_key" mystack
    
  2. 列出我们所创建的heat的资源

    $ openstack stack resource list mystack
    +---------------+--------------------------------------+------------------+-----------------+---------------------+
    | resource_name | physical_resource_id                 | resource_type    | resource_status | updated_time        |
    +---------------+--------------------------------------+------------------+-----------------+---------------------+
    | server        | 1b3a7c13-42be-4999-a2a1-8fbefd00062b | OS::Nova::Server | CREATE_COMPLETE | 2013-10-02T05:53:41Z |
    | ...           | ...                                  | ...              | ...             | ...                  |
    +---------------+--------------------------------------+------------------+-----------------+---------------------+
    
  3. 列出我们所设置的警报

    $ ceilometer alarm-list
    +--------------------------------------+------------------------------+-------------------+---------+------------+----------------------------------+
    | Alarm ID                             | Name                         | State             | Enabled | Continuous | Alarm condition                  |
    +--------------------------------------+------------------------------+-------------------+---------+------------+----------------------------------+
    | 4f896b40-0859-460b-9c6a-b0d329814496 | as-CPUAlarmLow-i6qqgkf2fubs  | insufficient data | True    | False      | cpu_util < 15.0 during 1x 60s |
    | 75d8ecf7-afc5-4bdc-95ff-19ed9ba22920 | as-CPUAlarmHigh-sf4muyfruy5m | insufficient data | True    | False      | cpu_util > 50.0 during 1x 60s |
    +--------------------------------------+------------------------------+-------------------+---------+------------+----------------------------------+
    
  4. 列出设置的计量:

    $ ceilometer meter-list
    +-------------+------------+----------+--------------------------------------+----------------------------------+----------------------------------+
    | Name        | Type       | Unit     | Resource ID                          | User ID                          | Project ID                       |
    +-------------+------------+----------+--------------------------------------+----------------------------------+----------------------------------+
    | cpu         | cumulative | ns       | 3965b41b-81b0-4386-bea5-6ec37c8841c1 | d1a2996d3b1f4e0e8645ba9650308011 | bf03bf32e3884d489004ac995ff7a61c |
    | cpu         | cumulative | ns       | 62520a83-73c7-4084-be54-275fe770ef2c | d1a2996d3b1f4e0e8645ba9650308011 | bf03bf32e3884d489004ac995ff7a61c |
    | cpu_util    | gauge      | %        | 3965b41b-81b0-4386-bea5-6ec37c8841c1 | d1a2996d3b1f4e0e8645ba9650308011 | bf03bf32e3884d489004ac995ff7a61c |
    +-------------+------------+----------+--------------------------------------+----------------------------------+----------------------------------+
    
  5. 列出示例

    $ ceilometer sample-list -m cpu_util
    +--------------------------------------+----------+-------+---------------+------+---------------------+
    | Resource ID                          | Name     | Type  | Volume        | Unit | Timestamp           |
    +--------------------------------------+----------+-------+---------------+------+---------------------+
    | 3965b41b-81b0-4386-bea5-6ec37c8841c1 | cpu_util | gauge | 3.98333333333 | %    | 2013-10-02T10:50:12 |
    +--------------------------------------+----------+-------+---------------+------+---------------------+
    
  6. 查看数据

    $ ceilometer statistics -m cpu_util
    +--------+---------------------+---------------------+-------+---------------+---------------+---------------+---------------+----------+---------------------+---------------------+
    | Period | Period Start        | Period End          | Count | Min           | Max           | Sum           | Avg           | Duration | Duration Start      | Duration End        |
    +--------+---------------------+---------------------+-------+---------------+---------------+---------------+---------------+----------+---------------------+---------------------+
    | 0      | 2013-10-02T10:50:12 | 2013-10-02T10:50:12 | 1     | 3.98333333333 | 3.98333333333 | 3.98333333333 | 3.98333333333 | 0.0      | 2013-10-02T10:50:12 | 2013-10-02T10:50:12 |
    +--------+---------------------+---------------------+-------+---------------+---------------+---------------+---------------+----------+---------------------+---------------------+
    
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.