|
| 1 | +# monitor_services_alert_definition |
| 2 | + |
| 3 | +Manage an alert definition for a specific service type. Akamai refers to these as user alerts. You need read_only access to the scope for the selected serviceType. |
| 4 | + |
| 5 | +- [Minimum Required Fields](#minimum-required-fields) |
| 6 | +- [Examples](#examples) |
| 7 | +- [Parameters](#parameters) |
| 8 | +- [Return Values](#return-values) |
| 9 | + |
| 10 | +## Minimum Required Fields |
| 11 | +| Field | Type | Required | Description | |
| 12 | +|-------------|-------|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 13 | +| `api_token` | `str` | **Required** | The Linode account personal access token. It is necessary to run the module. <br/>It can be exposed by the environment variable `LINODE_API_TOKEN` instead. <br/>See details in [Usage](https://github.com/linode/ansible_linode?tab=readme-ov-file#usage). | |
| 14 | + |
| 15 | +## Examples |
| 16 | + |
| 17 | +```yaml |
| 18 | +- name: Create an alert definition for a service type (dbaas) |
| 19 | + linode.cloud.monitor_services_alert_definition: |
| 20 | + service_type: 'dbaas' |
| 21 | + description: 'An alert definition for ansible test.' |
| 22 | + label: 'ansible-test' |
| 23 | + severity: 1 |
| 24 | + rule_criteria: |
| 25 | + rules: |
| 26 | + - aggregate_function: 'avg' |
| 27 | + dimension_filters: |
| 28 | + - dimension_label: 'node_type' |
| 29 | + label: 'Node Type' |
| 30 | + operator: 'eq' |
| 31 | + value: 'primary' |
| 32 | + label: 'Memory Usage' |
| 33 | + metric: 'memory_usage' |
| 34 | + operator: 'gt' |
| 35 | + threshold: 90 |
| 36 | + unit: 'percent' |
| 37 | + trigger_conditions: |
| 38 | + criteria_condition: 'ALL' |
| 39 | + evaluation_period_seconds: 300 |
| 40 | + polling_interval_seconds: 300 |
| 41 | + trigger_occurrences: 1 |
| 42 | + channel_ids: '{{ alert_channels }}' |
| 43 | + state: present |
| 44 | +``` |
| 45 | +
|
| 46 | +```yaml |
| 47 | +- name: Delete alert definition |
| 48 | + linode.cloud.monitor_services_alert_definition: |
| 49 | + service_type: 'dbaas' |
| 50 | + id: 123 |
| 51 | + state: absent |
| 52 | + register: delete |
| 53 | +``` |
| 54 | +
|
| 55 | +
|
| 56 | +## Parameters |
| 57 | +
|
| 58 | +| Field | Type | Required | Description | |
| 59 | +|-----------|------|----------|------------------------------------------------------------------------------| |
| 60 | +| `service_type` | <center>`str`</center> | <center>**Required**</center> | The Akamai Cloud Computing service being monitored. | |
| 61 | +| `channel_ids` | <center>`list`</center> | <center>**Required**</center> | The identifiers for the alert channels to use for the alert. Run the List alert channels operation and store the id for the applicable channels. **(Updatable)** | |
| 62 | +| `label` | <center>`str`</center> | <center>**Required**</center> | The name of the alert definition. This is used for display purposes in Akamai Cloud Manager. **(Updatable)** | |
| 63 | +| [`rule_criteria` (sub-options)](#rule_criteria) | <center>`dict`</center> | <center>**Required**</center> | Details for the rules required to trigger the alert. **(Updatable)** | |
| 64 | +| `severity` | <center>`int`</center> | <center>**Required**</center> | The severity of the alert. Supported values include 3 for info, 2 for low, 1 for medium, and 0 for severe. **(Choices: `0`, `1`, `2`, `3`; Updatable)** | |
| 65 | +| [`trigger_conditions` (sub-options)](#trigger_conditions) | <center>`dict`</center> | <center>**Required**</center> | The conditions that need to be met to send a notification for the alert. **(Updatable)** | |
| 66 | +| `state` | <center>`str`</center> | <center>**Required**</center> | The desired state of the target. **(Choices: `present`, `absent`)** | |
| 67 | +| `description` | <center>`str`</center> | <center>Optional</center> | An additional description for the alert definition. **(Updatable)** | |
| 68 | +| `entity_ids` | <center>`list`</center> | <center>Optional</center> | The id for each individual entity from a service_type. Get this value by running the list operation for the appropriate entity. For example, if your entity is one of your PostgreSQL databases, run the List PostgreSQL Managed Databases operation and store the id for the appropriate database from the response. You also need read_only access to the scope for the service_type for each of the entity_ids. **(Updatable)** | |
| 69 | +| `id` | <center>`int`</center> | <center>Optional</center> | The unique identifier assigned to the alert definition. Run the List alert definitions operation and store the id for the applicable alert definition. Required for updating. | |
| 70 | +| `status` | <center>`str`</center> | <center>Optional</center> | The current status of the alert. **(Choices: `enabled`, `disabled`; Updatable)** | |
| 71 | +| `wait` | <center>`bool`</center> | <center>Optional</center> | Wait for the alert definition ready (not in progress). **(Default: `False`)** | |
| 72 | +| `wait_timeout` | <center>`int`</center> | <center>Optional</center> | The amount of time, in seconds, to wait for the alert definition. **(Default: `600`)** | |
| 73 | + |
| 74 | +### rule_criteria |
| 75 | + |
| 76 | +| Field | Type | Required | Description | |
| 77 | +|-----------|------|----------|------------------------------------------------------------------------------| |
| 78 | +| [`rules` (sub-options)](#rules) | <center>`list`</center> | <center>Optional</center> | The individual rules that make up the alert definition. | |
| 79 | + |
| 80 | +### rules |
| 81 | + |
| 82 | +| Field | Type | Required | Description | |
| 83 | +|-----------|------|----------|------------------------------------------------------------------------------| |
| 84 | +| `aggregate_function` | <center>`str`</center> | <center>Optional</center> | The aggregation function applied to the metric. **(Choices: `avg`, `sum`, `min`, `max`)** | |
| 85 | +| [`dimension_filters` (sub-options)](#dimension_filters) | <center>`list`</center> | <center>Optional</center> | Individual objects that define dimension filters for the rule. | |
| 86 | +| `metric` | <center>`str`</center> | <center>Optional</center> | The metric to query. | |
| 87 | +| `operator` | <center>`str`</center> | <center>Optional</center> | The operator to apply to the metric. Available values are eq for equal, gt for greater than, lt for less than, gte for greater than or equal, and lte for less than or equal. **(Choices: `eq`, `gt`, `lt`, `gte`, `lte`)** | |
| 88 | +| `threshold` | <center>`float`</center> | <center>Optional</center> | The predefined value or condition that triggers an alert when met or exceeded. | |
| 89 | + |
| 90 | +### dimension_filters |
| 91 | + |
| 92 | +| Field | Type | Required | Description | |
| 93 | +|-----------|------|----------|------------------------------------------------------------------------------| |
| 94 | +| `dimension_label` | <center>`str`</center> | <center>Optional</center> | The name of the dimension to be used in the filter. | |
| 95 | +| `operator` | <center>`str`</center> | <center>Optional</center> | The operator to apply to the dimension filter. Available values are eq for equal, neq for not equal, startswith, and endswith. **(Choices: `eq`, `neq`, `startswith`, `endswith`)** | |
| 96 | +| `value` | <center>`str`</center> | <center>Optional</center> | The value to compare the dimension_label against. | |
| 97 | + |
| 98 | +### trigger_conditions |
| 99 | + |
| 100 | +| Field | Type | Required | Description | |
| 101 | +|-----------|------|----------|------------------------------------------------------------------------------| |
| 102 | +| `criteria_condition` | <center>`str`</center> | <center>Optional</center> | Signifies the logical operation applied when multiple metrics are set for an alert definition. For example, if you wanted to apply both cpu_usage > 90 and memory_usage > 80, ALL is the criteria_condition. Currently, only ALL is supported. **(Choices: `ALL`)** | |
| 103 | +| `evaluation_period_seconds` | <center>`int`</center> | <center>Optional</center> | The time period over which data is collected before evaluating whether the alert definition's threshold has been met or exceeded. | |
| 104 | +| `polling_interval_seconds` | <center>`int`</center> | <center>Optional</center> | The frequency at which the metric is checked for a change in state. For example, with cpu_usage set as your metric and this set to 300, your cpu_usage is checked every 5 minutes for some change in its state. | |
| 105 | +| `trigger_occurrences` | <center>`int`</center> | <center>Optional</center> | The minimum number of consecutive polling_interval_seconds periods that the threshold needs to be breached to trigger the alert. | |
| 106 | + |
| 107 | +## Return Values |
| 108 | + |
| 109 | +- `alert_definition` - The alert definition in JSON serialized form. |
| 110 | + |
| 111 | + - Sample Response: |
| 112 | + ```json |
| 113 | + { |
| 114 | + "alert_channels": [ |
| 115 | + { |
| 116 | + "id": 10000, |
| 117 | + "label": "Read-Write Channel", |
| 118 | + "type": "alert-channels", |
| 119 | + "url": "/monitor/alert-channels/10000" |
| 120 | + } |
| 121 | + ], |
| 122 | + "class": "dedicated", |
| 123 | + "created": "2025-03-20T01:42:11", |
| 124 | + "created_by": "system", |
| 125 | + "description": "Alert triggers when dedicated plan nodes consistently reach critical memory usage, risking application performance degradation.", |
| 126 | + "entity_ids": [ |
| 127 | + "126905", |
| 128 | + "126906", |
| 129 | + "137435", |
| 130 | + "141496", |
| 131 | + "190003", |
| 132 | + "257625", |
| 133 | + "257626" |
| 134 | + ], |
| 135 | + "has_more_resources": false, |
| 136 | + "id": 10000, |
| 137 | + "label": "High Memory Usage Plan Dedicated", |
| 138 | + "rule_criteria": { |
| 139 | + "rules": [ |
| 140 | + { |
| 141 | + "aggregate_function": "avg", |
| 142 | + "dimension_filters": [ |
| 143 | + { |
| 144 | + "dimension_label": "node_type", |
| 145 | + "label": "Node Type", |
| 146 | + "operator": "eq", |
| 147 | + "value": "primary" |
| 148 | + } |
| 149 | + ], |
| 150 | + "label": "Memory Usage", |
| 151 | + "metric": "memory_usage", |
| 152 | + "operator": "gt", |
| 153 | + "threshold": 95, |
| 154 | + "unit": "percent" |
| 155 | + } |
| 156 | + ] |
| 157 | + }, |
| 158 | + "service_type": "dbaas", |
| 159 | + "severity": 2, |
| 160 | + "status": "enabled", |
| 161 | + "trigger_conditions": { |
| 162 | + "criteria_condition": "ALL", |
| 163 | + "evaluation_period_seconds": 300, |
| 164 | + "polling_interval_seconds": 300, |
| 165 | + "trigger_occurrences": 3 |
| 166 | + }, |
| 167 | + "type": "system", |
| 168 | + "updated": "2025-03-20T01:42:11", |
| 169 | + "updated_by": "system" |
| 170 | + } |
| 171 | + ``` |
| 172 | + - See the [Linode API response documentation](https://techdocs.akamai.com/linode-api/reference/get-alert-definition) for a list of returned fields |
| 173 | + |
| 174 | + |
0 commit comments