community.general.datadog_monitor module – Manages Datadog monitors
Note
This module is part of the community.general collection (version 8.6.8).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.datadog_monitor
.
Synopsis
Manages monitors within Datadog.
Options as described on https://docs.datadoghq.com/api/.
Aliases: monitoring.datadog.datadog_monitor
Requirements
The below requirements are needed on the host that executes this module.
datadog
Parameters
Parameter |
Comments |
---|---|
The URL to the Datadog API. Default value is This value can also be set with the |
|
Your Datadog API key. |
|
Your Datadog app key. |
|
A message to include with a re-notification. Supports the ‘@username’ notification we allow elsewhere. Not applicable if |
|
Time to delay evaluation (in seconds). Effective for sparse values. |
|
The ID of the alert. If set, will be used instead of the name to locate the alert. |
|
Whether notifications from this monitor automatically inserts its triggering tags into the title. Choices:
|
|
Whether changes to this monitor should be restricted to the creator or admins. Choices:
|
|
The name of the alert. |
|
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. |
|
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. If not specified, it defaults to 2x timeframe for metric, 2 minutes for service. |
|
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 ‘]]’. |
|
Toggles the display of additional content sent in the monitor notification. Choices:
|
|
Whether tagged users will be notified on changes to this monitor. Choices:
|
|
Whether this monitor will notify when data stops reporting. Choices:
|
|
Integer from 1 (high) to 5 (low) indicating alert severity. |
|
The monitor query to notify on. Syntax varies depending on what type of monitor you are creating. |
|
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 is not resolved. |
|
The number of times re-notification messages should be sent on the current status at the provided re-notification interval. |
|
The types of monitor statuses for which re-notification messages are sent. Choices:
|
|
Whether this monitor needs a full window of data before it gets evaluated. We highly recommend you set this to False for sparse metrics, otherwise some evaluations will be skipped. Choices:
|
|
Dictionary of scopes to silence, with timestamps or None. Each scope will be muted until the given POSIX timestamp or forever if the value is None. |
|
The designated state of the monitor. Choices:
|
|
A list of tags to associate with your monitor when creating or updating. This can help you categorize and filter monitors. |
|
A dictionary of thresholds by status. Only available for service checks and metric alerts. Because each of them can have multiple thresholds, we do not define them directly in the query. If not specified, it defaults to: |
|
The number of hours of the monitor not reporting data before it will automatically resolve from a triggered state. |
|
The type of the monitor. The types The type The type Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: none |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Create a metric monitor
community.general.datadog_monitor:
type: "metric alert"
name: "Test monitor"
state: "present"
renotify_interval: 30
renotify_occurrences: 1
renotify_statuses: ["warn"]
notification_preset_name: "show_all"
query: "datadog.agent.up.over('host:host1').last(2).count_by_status()"
notification_message: "Host [[host.name]] with IP [[host.ip]] is failing to report to datadog."
api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"
- name: Deletes a monitor
community.general.datadog_monitor:
name: "Test monitor"
state: "absent"
api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"
- name: Mutes a monitor
community.general.datadog_monitor:
name: "Test monitor"
state: "mute"
silenced: '{"*":None}'
api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"
- name: Unmutes a monitor
community.general.datadog_monitor:
name: "Test monitor"
state: "unmute"
api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"
- name: Use datadoghq.eu platform instead of datadoghq.com
community.general.datadog_monitor:
name: "Test monitor"
state: "absent"
api_host: https://api.datadoghq.eu
api_key: "9775a026f1ca7d1c6c5af9d94d9595a4"
app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff"