|
|
|
@ -48,6 +48,11 @@ options:
|
|
|
|
|
description: ["The designated state of the monitor."]
|
|
|
|
|
required: true
|
|
|
|
|
choices: ['present', 'absent', 'muted', 'unmuted']
|
|
|
|
|
tags:
|
|
|
|
|
description: ["A list of tags to associate with your monitor when creating or updating. This can help you categorize and filter monitors."]
|
|
|
|
|
required: false
|
|
|
|
|
default: None
|
|
|
|
|
version_added: 2.2
|
|
|
|
|
type:
|
|
|
|
|
description:
|
|
|
|
|
- "The type of the monitor."
|
|
|
|
@ -153,6 +158,7 @@ def main():
|
|
|
|
|
escalation_message=dict(required=False, default=None),
|
|
|
|
|
notify_audit=dict(required=False, default=False, type='bool'),
|
|
|
|
|
thresholds=dict(required=False, type='dict', default=None),
|
|
|
|
|
tags=dict(required=False, type='list', default=None)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -189,9 +195,12 @@ def _get_monitor(module):
|
|
|
|
|
|
|
|
|
|
def _post_monitor(module, options):
|
|
|
|
|
try:
|
|
|
|
|
msg = api.Monitor.create(type=module.params['type'], query=module.params['query'],
|
|
|
|
|
name=module.params['name'], message=_fix_template_vars(module.params['message']),
|
|
|
|
|
options=options)
|
|
|
|
|
kwargs = dict(type=module.params['type'], query=module.params['query'],
|
|
|
|
|
name=module.params['name'], message=_fix_template_vars(module.params['message']),
|
|
|
|
|
options=options)
|
|
|
|
|
if module.params['tags'] is not None:
|
|
|
|
|
kwargs['tags'] = module.params['tags']
|
|
|
|
|
msg = api.Monitor.create(**kwargs)
|
|
|
|
|
if 'errors' in msg:
|
|
|
|
|
module.fail_json(msg=str(msg['errors']))
|
|
|
|
|
else:
|
|
|
|
@ -206,9 +215,13 @@ def _equal_dicts(a, b, ignore_keys):
|
|
|
|
|
|
|
|
|
|
def _update_monitor(module, monitor, options):
|
|
|
|
|
try:
|
|
|
|
|
msg = api.Monitor.update(id=monitor['id'], query=module.params['query'],
|
|
|
|
|
name=module.params['name'], message=_fix_template_vars(module.params['message']),
|
|
|
|
|
options=options)
|
|
|
|
|
kwargs = dict(id=monitor['id'], query=module.params['query'],
|
|
|
|
|
name=module.params['name'], message=_fix_template_vars(module.params['message']),
|
|
|
|
|
options=options)
|
|
|
|
|
if module.params['tags'] is not None:
|
|
|
|
|
kwargs['tags'] = module.params['tags']
|
|
|
|
|
msg = api.Monitor.update(**kwargs)
|
|
|
|
|
|
|
|
|
|
if 'errors' in msg:
|
|
|
|
|
module.fail_json(msg=str(msg['errors']))
|
|
|
|
|
elif _equal_dicts(msg, monitor, ['creator', 'overall_state', 'modified']):
|
|
|
|
|