W3cubDocs

/Ansible

community.digitalocean.digital_ocean_monitoring_alerts – Programmatically retrieve metrics as well as configure alert policies based on these metrics

Note

This plugin is part of the community.digitalocean collection (version 1.11.0).

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.digitalocean.

To use it in a playbook, specify: community.digitalocean.digital_ocean_monitoring_alerts.

New in version 1.10.0: of community.digitalocean

Synopsis

  • The DigitalOcean Monitoring API makes it possible to programmatically retrieve metrics as well as configure alert policies based on these metrics.
  • The Monitoring API can help you gain insight into how your apps are performing and consuming resources.

Parameters

Parameter Choices/Defaults Comments
alerts
dictionary
Alert object, required for state=present
Supports email["email1", "email2", ...] and slack[{"channel1", "url1"}, {"channel2", "url2"}, ...]
compare
string
    Choices:
  • GreaterThan
  • LessThan
Alert comparison, required for state=present
description
string
Alert description, required for state=present
enabled
boolean
    Choices:
  • no
  • yes
Enabled or not, required for state=present
entities
list / elements=string
Alert entities, required for state=present
oauth_token
string / required
DigitalOcean OAuth token; can be specified in DO_API_KEY, DO_API_TOKEN, or DO_OAUTH_TOKEN environment variables

aliases: API_TOKEN
state
string
    Choices:
  • present
  • absent
The usual, present to create, absent to destroy
tags
list / elements=string
Alert tags, required for state=present
type
string
    Choices:
  • v1/insights/droplet/load_1
  • v1/insights/droplet/load_5
  • v1/insights/droplet/load_15
  • v1/insights/droplet/memory_utilization_percent
  • v1/insights/droplet/disk_utilization_percent
  • v1/insights/droplet/cpu
  • v1/insights/droplet/disk_read
  • v1/insights/droplet/disk_write
  • v1/insights/droplet/public_outbound_bandwidth
  • v1/insights/droplet/public_inbound_bandwidth
  • v1/insights/droplet/private_outbound_bandwidth
  • v1/insights/droplet/private_inbound_bandwidth
Alert type, required for state=present
uuid
string
Alert uuid, required for state=absent
value
float
Alert threshold, required for state=present
window
string
    Choices:
  • 5m
  • 10m
  • 30m
  • 1h
Alert window, required for state=present

Examples

- name: Create Droplet Monitoring alerts policy
  community.digitalocean.digital_ocean_monitoring_alerts:
    state: present
    oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}"
    alerts:
      email: ["[email protected]"]
      slack: []
    compare: GreaterThan
    description: Droplet load1 alert
    enabled: true
    entities: ["{{ droplet_id }}"]
    tags: ["my_alert_tag"]
    type: v1/insights/droplet/load_1
    value: 3.14159
    window: 5m
  register: monitoring_alert_policy

- name: Delete Droplet Monitoring alerts policy
  community.digitalocean.digital_ocean_monitoring_alerts:
    state: absent
    oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}"
    uuid: "{{ monitoring_alert_policy.data.uuid }}"

Return Values

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

Key Returned Description
data
dictionary
changed
A DigitalOcean Monitoring alerts policy

Sample:
{'alerts': {'email': ['[email protected]'], 'slack': []}, 'compare': 'GreaterThan', 'description': 'Droplet load1 alert', 'enabled': True, 'entities': ['262383737'], 'tags': ['my_alert_tag'], 'type': 'v1/insights/droplet/load_1', 'uuid': '9f988f00-4690-443d-b638-ed5a99bbad3b', 'value': 3.14159, 'window': '5m'}


Authors

  • Mark Mercado (@mamercad)

© 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/digitalocean/digital_ocean_monitoring_alerts_module.html