Add datadog_monitor param for datadog tags (#2541)
* Add datadog_monitor param for datadog tags * Rename tags, add version_added
This commit is contained in:
parent
2886d3d9ec
commit
195bedee56
1 changed files with 20 additions and 7 deletions
|
@ -34,7 +34,7 @@ description:
|
||||||
- "Manages monitors within Datadog"
|
- "Manages monitors within Datadog"
|
||||||
- "Options like described on http://docs.datadoghq.com/api/"
|
- "Options like described on http://docs.datadoghq.com/api/"
|
||||||
version_added: "2.0"
|
version_added: "2.0"
|
||||||
author: "Sebastian Kornehl (@skornehl)"
|
author: "Sebastian Kornehl (@skornehl)"
|
||||||
notes: []
|
notes: []
|
||||||
requirements: [datadog]
|
requirements: [datadog]
|
||||||
options:
|
options:
|
||||||
|
@ -48,6 +48,11 @@ options:
|
||||||
description: ["The designated state of the monitor."]
|
description: ["The designated state of the monitor."]
|
||||||
required: true
|
required: true
|
||||||
choices: ['present', 'absent', 'muted', 'unmuted']
|
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:
|
type:
|
||||||
description:
|
description:
|
||||||
- "The type of the monitor."
|
- "The type of the monitor."
|
||||||
|
@ -153,6 +158,7 @@ def main():
|
||||||
escalation_message=dict(required=False, default=None),
|
escalation_message=dict(required=False, default=None),
|
||||||
notify_audit=dict(required=False, default=False, type='bool'),
|
notify_audit=dict(required=False, default=False, type='bool'),
|
||||||
thresholds=dict(required=False, type='dict', default=None),
|
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):
|
def _post_monitor(module, options):
|
||||||
try:
|
try:
|
||||||
msg = api.Monitor.create(type=module.params['type'], query=module.params['query'],
|
kwargs = dict(type=module.params['type'], query=module.params['query'],
|
||||||
name=module.params['name'], message=_fix_template_vars(module.params['message']),
|
name=module.params['name'], message=_fix_template_vars(module.params['message']),
|
||||||
options=options)
|
options=options)
|
||||||
|
if module.params['tags'] is not None:
|
||||||
|
kwargs['tags'] = module.params['tags']
|
||||||
|
msg = api.Monitor.create(**kwargs)
|
||||||
if 'errors' in msg:
|
if 'errors' in msg:
|
||||||
module.fail_json(msg=str(msg['errors']))
|
module.fail_json(msg=str(msg['errors']))
|
||||||
else:
|
else:
|
||||||
|
@ -206,9 +215,13 @@ def _equal_dicts(a, b, ignore_keys):
|
||||||
|
|
||||||
def _update_monitor(module, monitor, options):
|
def _update_monitor(module, monitor, options):
|
||||||
try:
|
try:
|
||||||
msg = api.Monitor.update(id=monitor['id'], query=module.params['query'],
|
kwargs = dict(id=monitor['id'], query=module.params['query'],
|
||||||
name=module.params['name'], message=_fix_template_vars(module.params['message']),
|
name=module.params['name'], message=_fix_template_vars(module.params['message']),
|
||||||
options=options)
|
options=options)
|
||||||
|
if module.params['tags'] is not None:
|
||||||
|
kwargs['tags'] = module.params['tags']
|
||||||
|
msg = api.Monitor.update(**kwargs)
|
||||||
|
|
||||||
if 'errors' in msg:
|
if 'errors' in msg:
|
||||||
module.fail_json(msg=str(msg['errors']))
|
module.fail_json(msg=str(msg['errors']))
|
||||||
elif _equal_dicts(msg, monitor, ['creator', 'overall_state', 'modified']):
|
elif _equal_dicts(msg, monitor, ['creator', 'overall_state', 'modified']):
|
||||||
|
|
Loading…
Reference in a new issue