page_title | subcategory | description |
---|---|---|
datadog_monitor Resource - terraform-provider-datadog |
Provides a Datadog monitor resource. This can be used to create and manage Datadog monitors. |
Provides a Datadog monitor resource. This can be used to create and manage Datadog monitors.
resource "datadog_monitor" "foo" {
name = "Name for monitor foo"
type = "metric alert"
message = "Monitor triggered. Notify: @hipchat-channel"
escalation_message = "Escalation message @pagerduty"
query = "avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 4"
monitor_thresholds {
warning = 2
critical = 4
}
include_tags = true
tags = ["foo:bar", "team:fooBar"]
}
message
(String) A message to include with notifications for this monitor.
Email notifications can be sent to specific users by using the same @username
notation as events.
name
(String) Name of Datadog monitor.query
(String) The monitor query to notify on. Note this is not the same query you see in the UI and the syntax is different depending on the monitor type, please see the API Reference for details.terraform plan
will validate query contents unlessvalidate
is set tofalse
.
Note: APM latency data is now available as Distribution Metrics. Existing monitors have been migrated automatically but all terraformed monitors can still use the existing metrics. We strongly recommend updating monitor definitions to query the new metrics. To learn more, or to see examples of how to update your terraform definitions to utilize the new distribution metrics, see the detailed doc.
type
(String) 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. Note: The monitor type cannot be changed after a monitor is created. Valid values arecomposite
,event alert
,log alert
,metric alert
,process alert
,query alert
,rum alert
,service check
,synthetics alert
,trace-analytics alert
,slo alert
,event-v2 alert
,audit alert
,ci-pipelines alert
,ci-tests alert
,error-tracking alert
,database-monitoring alert
.
enable_logs_sample
(Boolean) A boolean indicating whether or not to include a list of log values which triggered the alert. This is only used by log monitors. Defaults tofalse
.escalation_message
(String) A message to include with a re-notification. Supports the@username
notification allowed elsewhere.evaluation_delay
(Number) (Only applies to metric alert) Time (in seconds) to delay evaluation, as a non-negative integer.
For example, if the value is set to 300
(5min), the timeframe
is set to last_5m
and the time is 7:00, the monitor will evaluate data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor will always have data during evaluation.
force_delete
(Boolean) A boolean indicating whether this monitor can be deleted even if it’s referenced by other resources (e.g. SLO, composite monitor).group_retention_duration
(String) The time span after which groups with missing data are dropped from the monitor state. The minimum value is one hour, and the maximum value is 72 hours. Example values are: 60m, 1h, and 2d. This option is only available for APM Trace Analytics, Audit Trail, CI, Error Tracking, Event, Logs, and RUM monitors.groupby_simple_monitor
(Boolean) Whether or not to trigger one alert if any source breaches a threshold. This is only used by log monitors. Defaults tofalse
.include_tags
(Boolean) A boolean indicating whether notifications from this monitor automatically insert its triggering tags into the title. Defaults totrue
.locked
(Boolean, Deprecated) A boolean indicating whether changes to this monitor should be restricted to the creator or admins. Defaults tofalse
. Deprecated. Userestricted_roles
.monitor_threshold_windows
(Block List, Max: 1) A mapping containingrecovery_window
andtrigger_window
values, e.g.last_15m
. Can only be used for, and are required for, anomaly monitors. (see below for nested schema)monitor_thresholds
(Block List, Max: 1) Alert thresholds of the monitor. (see below for nested schema)new_group_delay
(Number) The time (in seconds) to skip evaluations for new groups.
new_group_delay
overrides new_host_delay
if it is set to a nonzero value.
new_host_delay
(Number, Deprecated) Deprecated. Seenew_group_delay
. Time (in seconds) to allow a host to boot and applications to fully start before starting the evaluation of monitor results. Should be a non-negative integer. This value is ignored for simple monitors and monitors not grouped by host. The only case when this should be used is to override the default and setnew_host_delay
to zero for monitors grouped by host. Deprecated. Usenew_group_delay
except when settingnew_host_delay
to zero. Defaults to300
.no_data_timeframe
(Number) The number of minutes before a monitor will notify when data stops reporting.
We recommend at least 2x the monitor timeframe for metric alerts or 2 minutes for service checks. Defaults to 10
.
notification_preset_name
(String) Toggles the display of additional content sent in the monitor notification. Valid values areshow_all
,hide_query
,hide_handles
,hide_all
.notify_audit
(Boolean) A boolean indicating whether tagged users will be notified on changes to this monitor. Defaults tofalse
.notify_by
(Set of String) Controls what granularity a monitor alerts on. Only available for monitors with groupings. For instance, a monitor grouped bycluster
,namespace
, andpod
can be configured to only notify on each newcluster
violating the alert conditions by settingnotify_by
to['cluster']
. Tags mentioned innotify_by
must be a subset of the grouping tags in the query. For example, a query grouped bycluster
andnamespace
cannot notify onregion
. Settingnotify_by
to[*]
configures the monitor to notify as a simple-alert.notify_no_data
(Boolean) A boolean indicating whether this monitor will notify when data stops reporting. Defaults tofalse
.on_missing_data
(String) Controls how groups or monitors are treated if an evaluation does not return any data points. The default option results in different behavior depending on the monitor query type. For monitors usingCount
queries, an empty monitor evaluation is treated as 0 and is compared to the threshold conditions. For monitors using any query type other thanCount
, for exampleGauge
,Measure
, orRate
, the monitor shows the last known status. This option is only available for APM Trace Analytics, Audit Trail, CI, Error Tracking, Event, Logs, and RUM monitors. Valid values are:show_no_data
,show_and_notify_no_data
,resolve
, anddefault
.priority
(Number) Integer from 1 (high) to 5 (low) indicating alert severity.renotify_interval
(Number) The number of minutes after the last notification before a monitor will re-notify on the current status. It will only re-notify if it's not resolved.renotify_occurrences
(Number) The number of re-notification messages that should be sent on the current status.renotify_statuses
(Set of String) The types of statuses for which re-notification messages should be sent. Valid values arealert
,warn
,no data
.require_full_window
(Boolean) A boolean indicating whether this monitor needs a full window of data before it's evaluated. Datadog strongly recommends you set this tofalse
for sparse metrics, otherwise some evaluations may be skipped. If there's a custom_schedule set,require_full_window
must be false and will be ignored. Defaults totrue
.restricted_roles
(Set of String) A list of unique role identifiers to define which roles are allowed to edit the monitor. Editing a monitor includes any updates to the monitor configuration, monitor deletion, and muting of the monitor for any amount of time. Roles unique identifiers can be pulled from the Roles API in thedata.id
field.scheduling_options
(Block List, Max: 1) Configuration options for scheduling. (see below for nested schema)tags
(Set of String) A list of tags to associate with your monitor. This can help you categorize and filter monitors in the manage monitors page of the UI. Note: it's not currently possible to filter by these tags when querying via the APItimeout_h
(Number) The number of hours of the monitor not reporting data before it automatically resolves from a triggered state. The minimum allowed value is 0 hours. The maximum allowed value is 24 hours.validate
(Boolean) If set tofalse
, skip the validation call done during plan.variables
(Block List, Max: 1) (see below for nested schema)
enable_samples
(Boolean) Whether or not a list of samples which triggered the alert is included. This is only used by CI Test and Pipeline monitors.id
(String) The ID of this resource.
Optional:
recovery_window
(String) Describes how long an anomalous metric must be normal before the alert recovers.trigger_window
(String) Describes how long a metric must be anomalous before an alert triggers.
Optional:
critical
(String) The monitorCRITICAL
threshold. Must be a number.critical_recovery
(String) The monitorCRITICAL
recovery threshold. Must be a number.ok
(String) The monitorOK
threshold. Only supported in monitor typeservice check
. Must be a number.unknown
(String) The monitorUNKNOWN
threshold. Only supported in monitor typeservice check
. Must be a number.warning
(String) The monitorWARNING
threshold. Must be a number.warning_recovery
(String) The monitorWARNING
recovery threshold. Must be a number.
Optional:
custom_schedule
(Block List, Max: 1) Configuration options for the custom schedules. Ifstart
is omitted, the monitor creation time will be used. (see below for nested schema)evaluation_window
(Block List, Max: 1) Configuration options for the evaluation window. Ifhour_starts
is set, no other fields may be set. Otherwise,day_starts
andmonth_starts
must be set together. (see below for nested schema)
Required:
recurrence
(Block List, Min: 1, Max: 1) A list of recurrence definitions. Length must be 1. (see below for nested schema)
Required:
rrule
(String) Must be a validrrule
. See API docs for supported fieldstimezone
(String) 'tz database' format. Example:America/New_York
orUTC
Optional:
start
(String) Time to start recurrence cycle. Similar to DTSTART. Expected format 'YYYY-MM-DDThh:mm:ss'
Optional:
day_starts
(String) The time of the day at which a one day cumulative evaluation window starts. Must be defined in UTC time inHH:mm
format.hour_starts
(Number) The minute of the hour at which a one hour cumulative evaluation window starts. Must be between 0 and 59.month_starts
(Number) The day of the month at which a one month cumulative evaluation window starts. Must be a value of 1.
Optional:
event_query
(Block List) A timeseries formula and functions events query. (see below for nested schema)
Required:
compute
(Block List, Min: 1) The compute options. (see below for nested schema)data_source
(String) The data source for event platform-based queries. Valid values arerum
,ci_pipelines
,ci_tests
,audit
,events
,logs
,spans
,database_queries
.name
(String) The name of query for use in formulas.search
(Block List, Min: 1, Max: 1) The search options. (see below for nested schema)
Optional:
group_by
(Block List) Group by options. (see below for nested schema)indexes
(List of String) An array of index names to query in the stream.
Required:
aggregation
(String) The aggregation methods for event platform queries. Valid values arecount
,cardinality
,median
,pc75
,pc90
,pc95
,pc98
,pc99
,sum
,min
,max
,avg
.
Optional:
interval
(Number) A time interval in milliseconds.metric
(String) The measurable attribute to compute.
Required:
query
(String) The events search string.
Required:
facet
(String) The event facet.
Optional:
limit
(Number) The number of groups to return.sort
(Block List, Max: 1) The options for sorting group by results. (see below for nested schema)
Required:
aggregation
(String) The aggregation methods for the event platform queries. Valid values arecount
,cardinality
,median
,pc75
,pc90
,pc95
,pc98
,pc99
,sum
,min
,max
,avg
.
Optional:
metric
(String) The metric used for sorting group by results.order
(String) Direction of sort. Valid values areasc
,desc
.
Import is supported using the following syntax:
terraform import datadog_monitor.bytes_received_localhost 2081