moira-alert.moira-trigger-role

moira-trigger-role

If you are new here, it's a good idea to read our main README.

This is an Ansible role that helps you create, update, and delete Moira triggers using the python-moira-client.

How to Use This Role

Installation

Configuration

Role Tasks

Installation

Ansible Galaxy

To install the role, run:

ansible-galaxy install moira-alert.moira-trigger-role

Ansible Role with Makefile

Add the following content from example into your Makefile. This will help you download the role from Ansible Galaxy and create a playbook to manage triggers with specific parameters in your vars files:

- name: manage moira triggers
  hosts: serviceName
  roles:
    - role: moira-alert.moira-trigger-role
      moira_api: http://localhost:8081/api
      moira_triggers: '{{ ServiceNameTriggers }}'
      delegate_to: 127.0.0.1
      run_once: True
      dry_run: False

Note: All tasks should be executed from your Ansible control machine.

Configuration

Define the following parameters in your vars files. You can find working examples here.

Authentication

Parameter Description Type Required Default Example
moira_api URL of Moira API String Yes N/A http://localhost/api/
moira_auth_custom Custom authorization headers Dictionary No None Authorization: apiKey
moira_auth_user Auth User (Basic Auth) String No None admin
moira_auth_pass Auth Password (Basic Auth) String No None pass
moira_auth_login Auth Login (Basic Auth) String No None admin

Note: If you are using additional authentication methods, use moira_auth_custom. Otherwise, use moira_auth_user, moira_auth_pass, and moira_auth_login for basic auth. The value for moira_auth_login should be included for the X-Webauth-User header.

Trigger State

Parameter Description Type Required Choices Default Example
state Desired state of a trigger String Yes present
absent
N/A present
id Trigger id String Yes N/A N/A trigger_1
name Trigger name String Yes N/A N/A Trigger 1
tags List of trigger tags List Yes N/A N/A - Project
- Service
targets List of trigger targets List Yes N/A N/A - prefix.*.postfix
warn_value Value to set WARN status Float No N/A None 300
error_value Value to set ERROR status Float No N/A None 600
trigger_type Type of a trigger String No rising
falling
expression
N/A rising
expression C-like expression String No N/A Empty string t1 >= 10 ? ERROR : (t1 >= 1 ? WARN : OK)
ttl Time until Moira switches state without metrics Int No N/A 600 600
ttl_state Trigger state after 'ttl' expires String No NODATA
DEL
ERROR
WARN
OK
NODATA WARN
is_remote Use remote storage (Deprecated) Bool No True
False
False False
trigger_source Specify trigger source, overrides is_remote String No graphite_local
graphite_remote
prometheus_remote
None graphite_local
cluster_id Specify cluster id String No N/A None default
desc Trigger description String No N/A Empty string trigger test description
mute_new_metrics If true, first NODATA → OK will be omitted Bool No True
False
False False
disabled_days Days trigger will be silent List No N/A Empty list - Mon
- Wed
timezone_offset Timezone offset (in minutes) Int No N/A 0 -180
start_hour Hour to start sending alerts Int No N/A 0 9
start_minute Minute to start sending alerts Int No N/A 0 0
end_hour Hour to stop sending alerts Int No N/A 23 17
end_minute Minute to stop sending alerts Int No N/A 59 0
alone_metrics Set some targets as single metrics Object No N/A {'t1': False, 't2': True,... 'tN': True} {'t1': False, 't2': False}

Role Tasks

Managing Dependencies

This task checks if the python-moira-client is installed via pip.

Managing Triggers

To create or edit existing triggers, set the state to 'present':

 - name: create trigger
   moira_trigger:
      ...
      state: present
      ...  

To delete existing triggers, set the state to 'absent':

 - name: remove trigger
   moira_trigger:
      ...
      state: absent
      ...  
Informazioni sul progetto

Ansible role to create, update and delete Moira triggers

Installa
ansible-galaxy install moira-alert.moira-trigger-role
Licenza
mit
Download
19.1k
Proprietario
Realtime alerting system based on Graphite data