Skip to content

Latest commit

 

History

History
227 lines (150 loc) · 15 KB

File metadata and controls

227 lines (150 loc) · 15 KB
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.

datadog_monitor (Resource)

Provides a Datadog monitor resource. This can be used to create and manage Datadog monitors.

Example Usage

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"]
}

Schema

Required

  • 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 unless validate is set to false.

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 are composite, 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.

Optional

  • 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 to false.
  • 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 to false.
  • include_tags (Boolean) A boolean indicating whether notifications from this monitor automatically insert its triggering tags into the title. Defaults to true.
  • locked (Boolean, Deprecated) A boolean indicating whether changes to this monitor should be restricted to the creator or admins. Defaults to false. Deprecated. Use restricted_roles.
  • monitor_threshold_windows (Block List, Max: 1) A mapping containing recovery_window and trigger_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. See new_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 set new_host_delay to zero for monitors grouped by host. Deprecated. Use new_group_delay except when setting new_host_delay to zero. Defaults to 300.
  • 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 are show_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 to false.
  • notify_by (Set of String) Controls what granularity a monitor alerts on. Only available for monitors with groupings. For instance, a monitor grouped by cluster, namespace, and pod can be configured to only notify on each new cluster violating the alert conditions by setting notify_by to ['cluster']. Tags mentioned in notify_by must be a subset of the grouping tags in the query. For example, a query grouped by cluster and namespace cannot notify on region. Setting notify_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 to false.
  • 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 using Count queries, an empty monitor evaluation is treated as 0 and is compared to the threshold conditions. For monitors using any query type other than Count, for example Gauge, Measure, or Rate, 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, and default.
  • 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 are alert, 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 to false 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 to true.
  • 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 the data.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 API
  • timeout_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 to false, skip the validation call done during plan.
  • variables (Block List, Max: 1) (see below for nested schema)

Read-Only

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

Nested Schema for monitor_threshold_windows

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.

Nested Schema for monitor_thresholds

Optional:

  • critical (String) The monitor CRITICAL threshold. Must be a number.
  • critical_recovery (String) The monitor CRITICAL recovery threshold. Must be a number.
  • ok (String) The monitor OK threshold. Only supported in monitor type service check. Must be a number.
  • unknown (String) The monitor UNKNOWN threshold. Only supported in monitor type service check. Must be a number.
  • warning (String) The monitor WARNING threshold. Must be a number.
  • warning_recovery (String) The monitor WARNING recovery threshold. Must be a number.

Nested Schema for scheduling_options

Optional:

  • custom_schedule (Block List, Max: 1) Configuration options for the custom schedules. If start 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. If hour_starts is set, no other fields may be set. Otherwise, day_starts and month_starts must be set together. (see below for nested schema)

Nested Schema for scheduling_options.custom_schedule

Required:

  • recurrence (Block List, Min: 1, Max: 1) A list of recurrence definitions. Length must be 1. (see below for nested schema)

Nested Schema for scheduling_options.custom_schedule.recurrence

Required:

  • rrule (String) Must be a valid rrule. See API docs for supported fields
  • timezone (String) 'tz database' format. Example: America/New_York or UTC

Optional:

  • start (String) Time to start recurrence cycle. Similar to DTSTART. Expected format 'YYYY-MM-DDThh:mm:ss'

Nested Schema for scheduling_options.evaluation_window

Optional:

  • day_starts (String) The time of the day at which a one day cumulative evaluation window starts. Must be defined in UTC time in HH: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.

Nested Schema for variables

Optional:

Nested Schema for variables.event_query

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 are rum, 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.

Nested Schema for variables.event_query.compute

Required:

  • aggregation (String) The aggregation methods for event platform queries. Valid values are count, 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.

Nested Schema for variables.event_query.search

Required:

  • query (String) The events search string.

Nested Schema for variables.event_query.group_by

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)

Nested Schema for variables.event_query.group_by.sort

Required:

  • aggregation (String) The aggregation methods for the event platform queries. Valid values are count, 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 are asc, desc.

Import

Import is supported using the following syntax:

terraform import datadog_monitor.bytes_received_localhost 2081