stackhpc.monasca_default_alarms

monasca-default-alarms

This role sets up a default configuration for Monasca alarms. It also includes Ansible modules for creating Monasca alarm definitions and notifications. You can find more information about alarm definitions in the Monasca API documentation.

Requirements

You need Ansible version 2.8 or higher to use features in this role, like document fragments. If you don't provide monasca_api_url, it is assumed that the Monasca service endpoint is correctly registered in Keystone.

Role Variables

These variables are required. If you have an equivalent OS_ENV environment variable on the control host, it will take priority over the default.

  • keystone_url (OS_AUTH_URL)
  • keystone_project (OS_PROJECT_NAME)

You also need either:

  • keystone_user (OS_USERNAME)
  • keystone_password (OS_PASSWORD)

or

  • keystone_token
  • monasca_api_url

By default, the configured alarm definitions will send email notifications to root@localhost. Change the notification_address variable to send notifications to a different email address. If you set notification_type to WEBHOOK or SLACK, the notification_address should specify the URL, like this:

notification_address: "https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZZ"
notification_name: "Default Slack Notification"
notification_type: "SLACK"

There are two optional variables that can control the created alarms:

  • skip_tasks (list)
  • custom_alarms (dict)

Check the example playbook for details on custom_alarms fields and refer to tasks/main.yml for skip_tasks options.

This role installs the python-monascaclient dependency inside a virtual environment. The default location for the virtual environment is /opt/python-monascaclient. Since this path usually needs elevated permissions, the role will use become: yes to create it. You can change the virtual environment directory using monasca_client_virtualenv_dir: /foo. You can disable privilege escalation with virtualenv_become: no.

Example Playbook

Add the following to a playbook file, replacing the keystone_ variables with those that fit your OpenStack setup. It’s a good idea to use ansible-vault or a similar tool to store keystone_password.

- name: Define default alarm notifications
  hosts: monitoring
  gather_facts: no
  vars:
    keystone_url: http://192.168.128.2:35357/v3/
    keystone_user: admin
    keystone_password: password
    keystone_project: monasca_control_plane
    skip_tasks: ["misc", "openstack", "monasca", "ceph"]
    custom_alarms:
      - name: "Host CPU System Percent"
        description: "Alarm triggers when System CPU % exceeds 80 (example custom alarm)"
        expression: "cpu.system_perc{hostname=host.domain.com} > 80"
        match_by: ['hostname']
  roles:
    - {role: stackhpc.monasca_default_alarms, tags: [alarms]}

Using Monasca Modules

There are two modules available: one for Monasca notifications and one for alarm definitions. For example:

- name: Setup root email notification method
  monasca_notification_method:
    name: "Email Root"
    type: 'EMAIL'
    address: 'root@localhost'
    keystone_url: "{{ keystone_url }}"
    keystone_user: "{{ keystone_user }}"
    keystone_password: "{{ keystone_password }}"
    keystone_project: "{{ keystone_project }}"
  register: default_notification
- name: Create System Alarm Definitions
  monasca_alarm_definition:
    name: "Host Alive Alarm"
    description: "Triggers when a host alive check fails"
    expression: "host_alive_status > 0"
    keystone_url: "{{ keystone_url }}"
    keystone_user: "{{ keystone_user }}"
    keystone_password: "{{ keystone_password }}"
    keystone_project: "{{ keystone_project }}"
    monasca_api_url: "{{ default_notification.monasca_api_url }}"
    severity: "HIGH"
    alarm_actions:
      - "{{ default_notification.notification_method_id }}"
    ok_actions:
      - "{{ default_notification.notification_method_id }}"
    undetermined_actions:
      - "{{ default_notification.notification_method_id }}"

For more detailed information, refer to the documentation that comes with the modules.

License

Apache

Author Information

Originally created by Tim Kuhlman and rewritten by Isaac Prior to support new Keystone authentication.

You can reach the Monasca Team on IRC at #openstack-monasca on freenode.net, or email at monasca@lists.launchpad.net.

Informazioni sul progetto

Sets up default alarm definitions for Monasca

Installa
ansible-galaxy install stackhpc.monasca_default_alarms
Licenza
apache-2.0
Download
324
Proprietario
StackHPC develops OpenStack capabilities for research computing use cases. Through extensive experience, we understand HPC and cloud.