警告

NOTICE: THIS DOCUMENTATION SITE HAS BEEN SUPERSEDED.

For the current documentation site goto: http://docs.cloudstack.apache.org

事件通知

事件本质上是与云环境相关的虚拟和物理资源的状态显著或有意义的变化。事件用于监控系统,使用率和计费系统,或者是用于辨别模式和做出正确商业决定的其他任何事件驱动工作流系统。在 CloudStack 中的事件可以是虚拟或物理资源的状态变化,用户(操作事件)执行的操作,或基于策略的事件(警告)。

事件日志

这里有两种类型的事件记录在&PRODUCT;事件日志。标准事件记录一个事件的成功或失败,并且可以用于鉴别哪些是已经失败的任务或进程。这里也记录长时间运行任务事件。异步任务的制定,启动,完成这些事件都被记录。长时间运行的同步和异步事件日志可用于获取挂起任务更多的状态信息,也可以用来识别任务是被挂起或还未开始。以下各节提供有关这些事件的详细信息。

通知

Event notification framework provides a means for the Management Server components to publish and subscribe to CloudStack events. Event notification is achieved by implementing the concept of event bus abstraction in the Management Server.

状态变化,资源状态变化的新事件作为事件通知架构的一部分被引入。每个资源,例如用户VM,卷VM,网卡,网络,公共IP,快照以及模板,使用机器状态和常规事件被关联起来作为状态变化的一部分。这意味着,一个资源状态的变化产生了一个状态变化事件,并且该事件被公布到相应的状态事件总线。所有的 CloudStack 事件(报警,动作事件,使用事件)和 资源状态变化事件的附加条目将被公布到事件总线。

Implementations

An event bus is introduced in the Management Server that allows the CloudStack components and extension plug-ins to subscribe to the events by using the Advanced Message Queuing Protocol (AMQP) client. In CloudStack, a default implementation of event bus is provided as a plug-in that uses the RabbitMQ AMQP client. The AMQP client pushes the published events to a compatible AMQP server. Therefore all the CloudStack events are published to an exchange in the AMQP server.

Additionally, both an in-memory implementation and an Apache Kafka implementation are also available.

使用案例

以下是一些使用场景:

  • 使用率或计费引擎:第三方云使用的解决方案可以实现一个插件,它可以连接到 CloudStack 中订阅 CloudStack 中的事件并产生使用率数据。使用率数据是它们的使用的软件消耗。
  • AMQP的插件可以存放消息队列中的所有事件,然后一个AMQP消息代理可以提供基于主题的通知订阅者。
  • AMQP的插件可以存放所有事件在一个消息队列中,然后AMQP打乱的 发布和订阅通知服务可以作为一个可插拔的服务,在CloudStack中该服务可以为事件通知提供丰富的API集,如主题为标题的主题和通知。此外,可插拔服务可以处理多租户,认证,授权issues.age代理,并提供基于主题的订阅通知。

AMQP Configuration

作为一个 CloudStack 管理员,执行下列一次性配置启用事件通知框架。在运行时不能修改控件行为。

  1. Create the folder /etc/cloudstack/management/META-INF/cloudstack/core

  2. Inside that folder, open spring-event-bus-context.xml.

  3. 按照以下实例顶一个叫做 “ eventNotificationBus ” 的实体:

    • 名字:为实体指定一个名字。

    • 服务器: RabbitMQ AMQP 的名字或IP地址

    • 端口 : RabbitMQ服务器运行端口.

    • 用户名: 用户名关联访问 RabbitMQ 服务器的账号。

    • 密码: 密码关联访问 RabbitMQ 服务器账号的用户名。

    • 交流:其中 CloudStack 中事件发布的 RabbitMQ 的服务器上的交流名称。

      下面给出一个实体实例:

      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-3.0.xsd">
         <bean id="eventNotificationBus" class="org.apache.cloudstack.mom.rabbitmq.RabbitMQEventBus">
            <property name="name" value="eventNotificationBus"/>
            <property name="server" value="127.0.0.1"/>
            <property name="port" value="5672"/>
            <property name="username" value="guest"/>
            <property name="password" value="guest"/>
            <property name="exchange" value="cloudstack-events"/>
         </bean>
      </beans>
      

      The eventNotificationBus bean represents the org.apache.cloudstack.mom.rabbitmq.RabbitMQEventBus class.

      If you want to use encrypted values for the username and password, you have to include a bean to pass those as variables from a credentials file.

      A sample is given below

      <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:context="http://www.springframework.org/schema/context"
             xmlns:aop="http://www.springframework.org/schema/aop"
             xsi:schemaLocation="http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
              http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
              http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context-3.0.xsd"
      >
      
         <bean id="eventNotificationBus" class="org.apache.cloudstack.mom.rabbitmq.RabbitMQEventBus">
            <property name="name" value="eventNotificationBus"/>
            <property name="server" value="127.0.0.1"/>
            <property name="port" value="5672"/>
            <property name="username" value="${username}"/>
            <property name="password" value="${password}"/>
            <property name="exchange" value="cloudstack-events"/>
         </bean>
      
         <bean id="environmentVariablesConfiguration" class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
            <property name="algorithm" value="PBEWithMD5AndDES" />
            <property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" />
         </bean>
      
         <bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
            <property name="config" ref="environmentVariablesConfiguration" />
         </bean>
      
         <bean id="propertyConfigurer" class="org.jasypt.spring3.properties.EncryptablePropertyPlaceholderConfigurer">
            <constructor-arg ref="configurationEncryptor" />
            <property name="location" value="classpath:/cred.properties" />
         </bean>
      </beans>
      

      Create a new file in the same folder called cred.properties and the specify the values for username and password as jascrypt encrypted strings

      Sample, with guest as values for both fields:

      username=nh2XrM7jWHMG4VQK18iiBQ==
      password=nh2XrM7jWHMG4VQK18iiBQ==
      
  4. 重启管理服务器。

Kafka Configuration

作为一个 CloudStack 管理员,执行下列一次性配置启用事件通知框架。在运行时不能修改控件行为。

  1. Create an appropriate configuration file in /etc/cloudstack/management/kafka.producer.properties which contains valid kafka configuration properties as documented in http://kafka.apache.org/documentation.html#newproducerconfigs The properties may contain an additional topic property which if not provided will default to cloudstack. While key.serializer and value.serializer are usually required for a producer to correctly start, they may be omitted and will default to org.apache.kafka.common.serialization.StringSerializer.

  2. Create the folder /etc/cloudstack/management/META-INF/cloudstack/core

  3. Inside that folder, open spring-event-bus-context.xml.

  4. Define a bean named eventNotificationBus with a single name attribute, A sample bean is given below:

    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
                               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                               http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
                               http://www.springframework.org/schema/context
                               http://www.springframework.org/schema/context/spring-context-3.0.xsd">
       <bean id="eventNotificationBus" class="org.apache.cloudstack.mom.kafka.KafkaEventBus">
         <property name="name" value="eventNotificationBus"/>
       </bean>
     </beans>
    
  5. 重启管理服务器。

标准事件

事件日志记录三种类型的标准事件

  • 通知:当一个操作被成功执行产生事件。
  • 警告:以下状况产生该事件。
    • 监控模板下载的同时网络被断开
    • 模板下载被放弃
    • 当存储服务器上的问题会导致卷故障转移到镜像存储服务器。
  • 错误:当操作没有成功执行产生该事件

长事件运行任务事件

事件日志记录三种类型的标准事件

  • 通知:当一个操作被成功执行产生事件。
  • 警告:以下状况产生该事件。
    • 监控模板下载的同时网络被断开
    • 模板下载被放弃
    • 当存储服务器上的问题会导致卷故障转移到镜像存储服务器。
  • 错误:当操作没有成功执行产生该事件

事件记录查询

可以通过用户接口查询数据库日志。系统收集了以下列表事件:

  • 虚拟机创建,删除,以及持续管理操作
  • 虚拟路由器创建,删除,以及持续管理操作
  • 模板创建和删除
  • 网络/压力 负载规则创建和删除
  • 存储卷创建和和删除
  • 用户登录注销

删除和归档事件警告

CloudStack 提供你删除或归档那些再也不使用的现存警告和事件的能力。您可以定期删除或存档的任何那些您不能或不想从数据库来解决的警报或事件,

您可以通过快速查看或详情页面直接删除或归档个别警报或事件。如果你想同时删除多个警报或事件,您可以分别使用相应的快捷菜单。您可以按类别删除某个时期的警报或事件。例如,您可以选择诸如 ** USER.LOGOUT**,** VM.DESTROY**,** VM.AG.UPDATE**,** CONFIGURATION.VALUE.EDI** 等类别,依此类推。您还可以查看事件和警报归档或删除的数量。

为了支持删除或归档报警,增加了以下全局参数:

  • alert.purge.delay: The alerts older than specified number of days are purged. Set the value to 0 to never purge alerts automatically.
  • alert.purge.interval: The interval in seconds to wait before running the alert purge thread. The default is 86400 seconds (one day).

注解

不能同通过UI 或 API 来归档报警或者事件。它们都存放在数据库中用于升级或其他目的。

许可

参考以下几点:

  • root 管理 可以删除或归档一个或多个警告事件
  • 域关乎或终端用户可以删除或归档一个或多个警告事件

步骤

  1. 使用管理员登录到CloudStack管理界面。
  2. 在左侧导航栏中,点击事件。
  3. 请执行下列操作之一:
    • 归档事件,点击 归档事件,并指定事件类型和日期。
    • 归档事件,点击 删除事件,并指定事件类型和日期。
  4. 点击确定。