Skip to content

Commit 8e50d50

Browse files
nmueschzippolyte
andauthored
Add tfplugindocs scaffolding and generate monitor docs (#839)
* Add tfplugindocs scaffolding and generate monitor docs * Update examples/resources/datadog_monitor/resource.tf Co-authored-by: Hippolyte HENRY <[email protected]> * Cleanup and add docs guide generation Co-authored-by: Hippolyte HENRY <[email protected]>
1 parent e5e29b0 commit 8e50d50

File tree

17 files changed

+336
-199
lines changed

17 files changed

+336
-199
lines changed

datadog/resource_datadog_monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func resourceDatadogMonitor() *schema.Resource {
6565
},
6666
},
6767
"type": {
68-
Description: "The type of the monitor. The mapping from these types to the types found in the Datadog Web UI can be found in the Datadog API [documentation page](https://docs.datadoghq.com/api/v1/monitors/#create-a-monitor). The available options are below. Note: The monitor type cannot be changed after a monitor is created.",
68+
Description: "The type of the monitor. The mapping from these types to the types found in the Datadog Web UI can be found in the Datadog API [documentation page](https://docs.datadoghq.com/api/v1/monitors/#create-a-monitor). Note: The monitor type cannot be changed after a monitor is created.",
6969
Type: schema.TypeString,
7070
Required: true,
7171
ForceNew: true,

docs/data-sources/monitor.md

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,75 @@
11
---
2-
page_title: "datadog_monitor"
2+
page_title: "datadog_monitor Data Source - terraform-provider-datadog"
3+
subcategory: ""
4+
description: |-
5+
Use this data source to retrieve information about an existing monitor for use in other resources.
36
---
47

5-
# datadog_monitor Data Source
8+
# Data Source `datadog_monitor`
69

710
Use this data source to retrieve information about an existing monitor for use in other resources.
811

912
## Example Usage
1013

11-
```
14+
```terraform
1215
data "datadog_monitor" "test" {
1316
name_filter = "My awesome monitor"
1417
monitor_tags_filter = ["foo:bar"]
1518
}
1619
```
1720

18-
## Argument Reference
19-
20-
- `name_filter`: (Optional) A monitor name to limit the search.
21-
- `tags_filter`: (Optional) A list of tags to limit the search. This filters on the monitor scope.
22-
- `monitor_tags_filter`: (Optional) A list of monitor tags to limit the search. This filters on the tags set on the monitor itself.
23-
24-
~> **NOTE:** If more or less than a single match is returned by the search, Terraform will fail. Ensure that your search is specific enough to return a single monitor.
25-
26-
## Attributes Reference
27-
28-
- `id`: ID of the Datadog monitor
29-
- `name`: Name of the monitor.
30-
- `type`: Type of the monitor.
31-
- `query`: Query of the monitor.
32-
- `message`: Message included with notifications for this monitor.
33-
- `escalation_message`: Message included with a re-notification for this monitor.
34-
- `thresholds`: (Deprecated) Alert thresholds of the monitor. Use `monitor_thresholds` instead.
35-
- `monitor_thresholds`: Alert thresholds of the monitor. List of one element containing the threshold definitions.
36-
- `notify_no_data`: Whether or not this monitor notifies when data stops reporting.
37-
- `new_host_delay`: Time (in seconds) allowing a host to boot and applications to fully start before starting the evaluation of monitor results.
38-
- `evaluation_delay`: Time (in seconds) for which evaluation is delayed. This is only used by metric monitors.
39-
- `no_data_timeframe`: The number of minutes before the monitor notifies when data stops reporting.
40-
- `renotify_interval`: The number of minutes after the last notification before the monitor re-notifies on the current status.
41-
- `notify_audit`: Whether or not tagged users are notified on changes to the monitor.
42-
- `timeout_h`: Number of hours of the monitor not reporting data before it automatically resolves from a triggered state.
43-
- `include_tags`: Whether or not notifications from the monitor automatically inserts its triggering tags into the title.
44-
- `enable_logs_sample`: Whether or not a list of log values which triggered the alert is included. This is only used by log monitors.
45-
- `require_full_window`: Whether or not the monitor needs a full window of data before it is evaluated.
46-
- `locked`: Whether or not changes to the monitor are restricted to the creator or admins.
47-
- `tags`: List of tags associated with the monitor.
48-
- `threshold_windows`: (Deprecated) Mapping containing `recovery_window` and `trigger_window` values, e.g. `last_15m`. This is only used by anomaly monitors. Use `monitor_threshold_windows` instead.
49-
- `monitor_threshold_windows`: Mapping containing `recovery_window` and `trigger_window` values, e.g. `last_15m`. This is only used by anomaly monitors. List of one element containing the threshold window definitions.
21+
## Schema
22+
23+
### Optional
24+
25+
- **id** (String) The ID of this resource.
26+
- **monitor_tags_filter** (List of String) A list of monitor tags to limit the search. This filters on the tags set on the monitor itself.
27+
- **name_filter** (String) A monitor name to limit the search.
28+
- **tags_filter** (List of String) A list of tags to limit the search. This filters on the monitor scope.
29+
30+
### Read-only
31+
32+
- **enable_logs_sample** (Boolean) Whether or not a list of log values which triggered the alert is included. This is only used by log monitors.
33+
- **escalation_message** (String) Message included with a re-notification for this monitor.
34+
- **evaluation_delay** (Number) Time (in seconds) for which evaluation is delayed. This is only used by metric monitors.
35+
- **include_tags** (Boolean) Whether or not notifications from the monitor automatically inserts its triggering tags into the title.
36+
- **locked** (Boolean) Whether or not changes to the monitor are restricted to the creator or admins.
37+
- **message** (String) Message included with notifications for this monitor
38+
- **monitor_threshold_windows** (List of Object) Mapping containing `recovery_window` and `trigger_window` values, e.g. `last_15m`. This is only used by anomaly monitors. (see [below for nested schema](#nestedatt--monitor_threshold_windows))
39+
- **monitor_thresholds** (List of Object) Alert thresholds of the monitor. (see [below for nested schema](#nestedatt--monitor_thresholds))
40+
- **name** (String) Name of the monitor
41+
- **new_host_delay** (Number) Time (in seconds) allowing a host to boot and applications to fully start before starting the evaluation of monitor results.
42+
- **no_data_timeframe** (Number) The number of minutes before the monitor notifies when data stops reporting.
43+
- **notify_audit** (Boolean) Whether or not tagged users are notified on changes to the monitor.
44+
- **notify_no_data** (Boolean) Whether or not this monitor notifies when data stops reporting.
45+
- **query** (String) Query of the monitor.
46+
- **renotify_interval** (Number) The number of minutes after the last notification before the monitor re-notifies on the current status.
47+
- **require_full_window** (Boolean) Whether or not the monitor needs a full window of data before it is evaluated.
48+
- **tags** (Set of String) List of tags associated with the monitor.
49+
- **threshold_windows** (Map of String, Deprecated) Mapping containing `recovery_window` and `trigger_window` values, e.g. `last_15m`. This is only used by anomaly monitors.
50+
- **thresholds** (Map of String, Deprecated) Alert thresholds of the monitor.
51+
- **timeout_h** (Number) Number of hours of the monitor not reporting data before it automatically resolves from a triggered state.
52+
- **type** (String) Type of the monitor.
53+
54+
<a id="nestedatt--monitor_threshold_windows"></a>
55+
### Nested Schema for `monitor_threshold_windows`
56+
57+
Read-only:
58+
59+
- **recovery_window** (String)
60+
- **trigger_window** (String)
61+
62+
63+
<a id="nestedatt--monitor_thresholds"></a>
64+
### Nested Schema for `monitor_thresholds`
65+
66+
Read-only:
67+
68+
- **critical** (String)
69+
- **critical_recovery** (String)
70+
- **ok** (String)
71+
- **unknown** (String)
72+
- **warning** (String)
73+
- **warning_recovery** (String)
74+
75+

docs/guides/monitors.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
---
2-
page_title: "datadog_monitor Resource Examples"
2+
subcategory: ""
3+
page_title: "Monitor Resource Examples"
4+
description: |-
5+
Monitor Resource Examples
36
---
47

5-
## Monitor Resource Examples
8+
### Monitor Resource Examples
69

710
This page lists examples of how to create different Datadog monitor types within Terraform. This list is non exhaustive and will be updated over time to provide more examples.
811

9-
## Watchdog Monitors
12+
## Composite Monitors
13+
14+
You can compose monitors of all types in order to define more specific alert conditions (see the [doc](https://docs.datadoghq.com/monitors/monitor_types/composite/)). You just need to reuse the ID of your `datadog_monitor` resources. You can also compose any monitor with a `datadog_synthetics_test` by passing the computed `monitor_id` attribute in the query.
1015

16+
```terraform
17+
resource "datadog_monitor" "bar" {
18+
name = "Composite Monitor"
19+
type = "composite"
20+
message = "This is a message"
21+
query = "${datadog_monitor.foo.id} || ${datadog_synthetics_test.foo.monitor_id}"
22+
}
1123
```
24+
25+
## Watchdog Monitors
26+
27+
```terraform
1228
resource "datadog_monitor" "watchdog_monitor" {
1329
name = "Watchdog Monitor TF"
1430
type = "event alert"
@@ -30,7 +46,7 @@ resource "datadog_monitor" "watchdog_monitor" {
3046

3147
## Anomaly Monitors
3248

33-
```
49+
```terraform
3450
resource "datadog_monitor" "cpu_anomalous" {
3551
name = "Anomalous CPU usage"
3652
type = "query alert"
@@ -52,7 +68,7 @@ resource "datadog_monitor" "cpu_anomalous" {
5268

5369
## Process Monitors
5470

55-
```
71+
```terraform
5672
resource "datadog_monitor" "process_alert_example" {
5773
name = "Process Alert Monitor"
5874
type = "process alert"

0 commit comments

Comments
 (0)