community.general.datadog_downtime – Manages Datadog downtimes

Note

This plugin is part of the community.general collection (version 3.8.1).

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.

To use it in a playbook, specify: community.general.datadog_downtime.

New in version 2.0.0: of community.general

Synopsis

Requirements

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

  • datadog-api-client
  • Python 3.6+

Parameters

Parameter Choices/Defaults Comments
api_host
string
Default:
"https://api.datadoghq.com"
The URL to the Datadog API.
This value can also be set with the DATADOG_HOST environment variable.
api_key
string / required
Your Datadog API key.
app_key
string / required
Your Datadog app key.
downtime_message
string
A message to include with notifications for this downtime.
Email notifications can be sent to specific users by using the same "@username" notation as events.
end
integer
POSIX timestamp to end the downtime. If not provided, the downtime is in effect until you cancel it.
id
integer
The identifier of the downtime.
If empty, a new downtime gets created, otherwise it is either updated or deleted depending of the state.
To keep your playbook idempotent, you should save the identifier in a file and read it in a lookup.
monitor_id
integer
The ID of the monitor to mute. If not provided, the downtime applies to all monitors.
monitor_tags
list / elements=string
A list of monitor tags to which the downtime applies.
The resulting downtime applies to monitors that match ALL provided monitor tags.
rrule
string
The RRULE standard for defining recurring events.
For example, to have a recurring event on the first day of each month, select a type of rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1.
Most common rrule options from the iCalendar Spec are supported.
Attributes specifying the duration in RRULE are not supported (e.g. DTSTART, DTEND, DURATION).
scope
list / elements=string
A list of scopes to which the downtime applies.
The resulting downtime applies to sources that matches ALL provided scopes.
start
integer
POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.
state
string
    Choices:
  • present
  • absent
The designated state of the downtime.
timezone
string
The timezone for the downtime.

Examples

- name: Create a downtime
  register: downtime_var
  community.general.datadog_downtime:
    state: present
    monitor_tags:
      - "foo:bar"
    downtime_message: "Downtime for foo:bar"
    scope: "test"
    api_key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    app_key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    # Lookup the id in the file and ignore errors if the file doesn't exits, so downtime gets created
    id: "{{ lookup('file', inventory_hostname ~ '_downtime_id.txt', errors='ignore') }}"
- name: Save downtime id to file for later updates and idempotence
  delegate_to: localhost
  copy:
    content: "{{ downtime.downtime.id }}"
    dest: "{{ inventory_hostname ~ '_downtime_id.txt' }}"

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
downtime
dictionary
always
The downtime returned by the API.

Sample:
{'active': True, 'canceled': None, 'creator_id': 1445416, 'disabled': False, 'downtime_type': 2, 'end': None, 'id': 1055751000, 'message': 'Downtime for foo:bar', 'monitor_id': None, 'monitor_tags': ['foo:bar'], 'parent_id': None, 'recurrence': None, 'scope': ['test'], 'start': 1607015009, 'timezone': 'UTC', 'updater_id': None}


Authors

  • Datadog (@Datadog)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/datadog_downtime_module.html