From 48223fd268a1c4f4401efb889eaa477b51eae48f Mon Sep 17 00:00:00 2001 From: Paul Seiffert Date: Thu, 17 Mar 2016 20:08:55 +0100 Subject: [PATCH] Allow Datadog metric alerts to define multiple thresholds --- lib/ansible/modules/extras/monitoring/datadog_monitor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/extras/monitoring/datadog_monitor.py b/lib/ansible/modules/extras/monitoring/datadog_monitor.py index 71a17e18223..8dbbe646638 100644 --- a/lib/ansible/modules/extras/monitoring/datadog_monitor.py +++ b/lib/ansible/modules/extras/monitoring/datadog_monitor.py @@ -95,7 +95,7 @@ options: required: false default: False 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 default: {'ok': 1, 'critical': 1, 'warning': 1} ''' @@ -152,7 +152,7 @@ def main(): renotify_interval=dict(required=False, default=None), escalation_message=dict(required=False, default=None), 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": + 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'] monitor = _get_monitor(module)