community / community.digitalocean / 1.26.0 / module / digital_ocean_monitoring_alerts Programmatically retrieve metrics as well as configure alert policies based on these metrics | "added in version" 1.10.0 of community.digitalocean" Authors: Mark Mercado (@mamercad)community.digitalocean.digital_ocean_monitoring_alerts (1.26.0) — module
Install with ansible-galaxy collection install community.digitalocean:==1.26.0
collections: - name: community.digitalocean version: 1.26.0
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.
- 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: ["alerts@example.com"] 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 }}"
tags: description: Alert tags, required for C(state=present) elements: str required: false type: list type: 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 description: - Alert type, required for C(state=present) - See U(https://docs.digitalocean.com/reference/api/api-reference/#operation/create_alert_policy) for valid types required: false type: str uuid: description: Alert uuid, required for C(state=absent) required: false type: str state: choices: - present - absent default: present description: - The usual, C(present) to create, C(absent) to destroy type: str value: description: Alert threshold, required for C(state=present) required: false type: float alerts: description: - Alert object, required for C(state=present) - Supports C(email["email1", "email2", ...]) and C(slack[{"channel1", "url1"}, {"channel2", "url2"}, ...]) required: false type: dict window: choices: - 5m - 10m - 30m - 1h description: Alert window, required for C(state=present) required: false type: str compare: choices: - GreaterThan - LessThan description: Alert comparison, required for C(state=present) required: false type: str enabled: description: Enabled or not, required for C(state=present) required: false type: bool entities: description: Alert entities, required for C(state=present) elements: str required: false type: list description: description: Alert description, required for C(state=present) required: false type: str oauth_token: aliases: - API_TOKEN description: - DigitalOcean OAuth token; can be specified in C(DO_API_KEY), C(DO_API_TOKEN), or C(DO_OAUTH_TOKEN) environment variables required: true type: str
data: description: A DigitalOcean Monitoring alerts policy returned: changed sample: alerts: email: - mamercad@gmail.com 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 type: dict