datadog_monitor - Manages Datadog monitors

New in version 2.0.

Synopsis

Requirements

The below requirements are needed on the host that executes this module.

  • datadog

Parameters

Parameter Choices/Defaults Comments
api_key
required
Your DataDog API key.
app_key
required
Your DataDog app key.
escalation_message Default:
None
A message to include with a re-notification. Supports the '@username' notification we allow elsewhere. Not applicable if renotify_interval is None
id
(added in 2.3)
Default:
None
The id of the alert. If set, will be used instead of the name to locate the alert.
locked
(added in 2.2)
Default:
no
A boolean indicating whether changes to this monitor should be restricted to the creator or admins.
message Default:
None
A message to include with notifications for this monitor. Email notifications can be sent to specific users by using the same '@username' notation as events. Monitor message template variables can be accessed by using double square brackets, i.e '[[' and ']]'.
name
required
The name of the alert.
new_host_delay
(added in 2.4)
Default:
None
A positive integer representing the number of seconds to wait before evaluating the monitor for new hosts. This gives the host time to fully initialize.
no_data_timeframe Default:
2x timeframe for metric, 2 minutes for service
The number of minutes before a monitor will notify when data stops reporting. Must be at least 2x the monitor timeframe for metric alerts or 2 minutes for service checks.
notify_audit Default:
no
A boolean indicating whether tagged users will be notified on changes to this monitor.
notify_no_data Default:
no
A boolean indicating whether this monitor will notify when data stops reporting..
query Default:
None
The monitor query to notify on with syntax varying depending on what type of monitor you are creating.
renotify_interval Default:
None
The number of minutes after the last notification before a monitor will re-notify on the current status. It will only re-notify if it's not resolved.
require_full_window
(added in 2.3)
Default:
None
A boolean indicating whether this monitor needs a full window of data before it's evaluated. We highly recommend you set this to False for sparse metrics, otherwise some evaluations will be skipped.
silenced Default:
Dictionary of scopes to timestamps or None. Each scope will be muted until the given POSIX timestamp or forever if the value is None.
state
required
    Choices:
  • present
  • absent
  • mute
  • unmute
The designated state of the monitor.
tags
(added in 2.2)
Default:
None
A list of tags to associate with your monitor when creating or updating. This can help you categorize and filter monitors.
thresholds Default:
{u'warning': 1, u'ok': 1, u'critical': 1}
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."]
timeout_h Default:
None
The number of hours of the monitor not reporting data before it will automatically resolve from a triggered state.
type
    Choices:
  • metric alert
  • service check
  • event alert
Default:
None
The type of the monitor.
The 'event alert'is available starting at Ansible 2.1

Examples

# Create a metric monitor
- datadog_monitor:
    type: "metric alert"
    name: "Test monitor"
    state: "present"
    query: "datadog.agent.up.over('host:host1').last(2).count_by_status()"
    message: "Host [[host.name]] with IP [[host.ip]] is failing to report to datadog."
    api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
    app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"

# Deletes a monitor
- datadog_monitor:
    name: "Test monitor"
    state: "absent"
    api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
    app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"

# Mutes a monitor
- datadog_monitor:
    name: "Test monitor"
    state: "mute"
    silenced: '{"*":None}'
    api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
    app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"

# Unmutes a monitor
- datadog_monitor:
    name: "Test monitor"
    state: "unmute"
    api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
    app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Author

  • Sebastian Kornehl (@skornehl)

Hint

If you notice any issues in this documentation you can edit this document to improve it.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.5/modules/datadog_monitor_module.html