1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Allow Datadog metric alerts to define multiple thresholds

This commit is contained in:
Paul Seiffert 2016-03-17 20:08:55 +01:00 committed by Matt Clay
parent 33d3616bab
commit 48223fd268

View file

@ -95,7 +95,7 @@ options:
required: false required: false
default: False default: False
thresholds: thresholds:
description: ["A dictionary of thresholds by status. Because service checks can have multiple thresholds, we don't define them directly in the query."] description: ["A dictionary of thresholds by status. This option is only available for service checks and metric alerts. Because each of them can have multiple thresholds, we don't define them directly in the query."]
required: false required: false
default: {'ok': 1, 'critical': 1, 'warning': 1} default: {'ok': 1, 'critical': 1, 'warning': 1}
''' '''
@ -152,7 +152,7 @@ def main():
renotify_interval=dict(required=False, default=None), renotify_interval=dict(required=False, default=None),
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={'ok': 1, 'critical': 1, 'warning': 1}), thresholds=dict(required=False, type='dict', default=None),
) )
) )
@ -228,6 +228,8 @@ def install_monitor(module):
} }
if module.params['type'] == "service check": if module.params['type'] == "service check":
options["thresholds"] = module.params['thresholds'] or {'ok': 1, 'critical': 1, 'warning': 1}
if module.params['type'] == "metric alert" and module.params['thresholds'] is not None:
options["thresholds"] = module.params['thresholds'] options["thresholds"] = module.params['thresholds']
monitor = _get_monitor(module) monitor = _get_monitor(module)