Monitors

Monitors

Monitors allow you to watch a metric or check that you care about and notifies your team when a defined threshold has exceeded.

For more information, see Creating Monitors.

POST https://api.datadoghq.eu/v1/monitor/unmute_allhttps://api.ddog-gov.com/v1/monitor/unmute_allhttps://api.datadoghq.com/v1/monitor/unmute_allhttps://api.us3.datadoghq.com/v1/monitor/unmute_allhttps://api.us5.datadoghq.com/v1/monitor/unmute_all

Overview

Disables muting all monitors. Throws an error if mute all was not enabled previously.

Response

OK

Bad Request

Authentication error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/v1/monitor/unmute_all" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"

POST https://api.datadoghq.eu/api/v1/monitor/{monitor_id}/mutehttps://api.ddog-gov.com/api/v1/monitor/{monitor_id}/mutehttps://api.datadoghq.com/api/v1/monitor/{monitor_id}/mutehttps://api.us3.datadoghq.com/api/v1/monitor/{monitor_id}/mutehttps://api.us5.datadoghq.com/api/v1/monitor/{monitor_id}/mute

Overview

Mute the specified monitor.

Arguments

Path Parameters

Name

Type

Description

monitor_id [required]

integer

The id of the monitor

Query Strings

Name

Type

Description

scope

string

The scope to apply the mute to. For example, if your alert is grouped by {host}, you might mute host:app1.

end

integer

A POSIX timestamp for when the mute should end.

Response

OK

Object describing a monitor.

Expand All

Field

Type

Description

created

date-time

Timestamp of the monitor creation.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

deleted

date-time

Whether or not the monitor is deleted. (Always null)

id

int64

ID of this monitor.

message

string

A message to include with notifications for this monitor.

modified

date-time

Last timestamp when the monitor was edited.

multi

boolean

Whether or not the monitor is broken down on different groups.

name

string

The monitor name.

options

object

List of options associated with your monitor.

aggregation

object

Type of aggregation performed in the monitor query.

group_by

string

Group to break down the monitor on.

metric

string

Metric name used in the monitor.

type

string

Metric type used in the monitor.

device_ids

[string]

DEPRECATED: IDs of the device the Synthetics monitor is running on.

enable_logs_sample

boolean

Whether or not to send a log sample when the log monitor triggers.

escalation_message

string

We recommend using the is_renotify, block in the original message instead. A message to include with a re-notification. Supports the @username notification we allow elsewhere. Not applicable if renotify_interval is None.

evaluation_delay

int64

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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.

groupby_simple_monitor

boolean

Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.

include_tags

boolean

A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.

Examples

  • If True, [Triggered on {host:h1}] Monitor Title
  • If False, [Triggered] Monitor Title

locked

boolean

Whether or not the monitor is locked (only editable by creator and admins).

min_failure_duration

int64

How long the test should be in failure before alerting (integer, number of seconds, max 7200).

min_location_failed

int64

The minimum number of locations in failure at the same time during at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration are part of the advanced alerting rules - integer, >= 1).

new_group_delay

int64

Time (in seconds) to skip evaluations for new groups.

For example, this option can be used to skip evaluations for new hosts while they initialize.

Must be a non negative integer.

new_host_delay

int64

DEPRECATED: 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.

Use new_group_delay instead.

no_data_timeframe

int64

The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.

notify_audit

boolean

A Boolean indicating whether tagged users is notified on changes to this monitor.

notify_no_data

boolean

A Boolean indicating whether this monitor notifies when data stops reporting.

renotify_interval

int64

The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.

renotify_occurrences

int64

The number of times re-notification messages should be sent on the current status at the provided re-notification interval.

renotify_statuses

[string]

The types of monitor statuses for which re-notification messages are sent.

require_full_window

boolean

A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to false for sparse metrics, otherwise some evaluations are skipped. Default is false.

silenced

object

DEPRECATED: Information about the downtime applied to the monitor.

<any-key>

int64

ID of the downtime applied to the monitor.

synthetics_check_id

string

DEPRECATED: ID of the corresponding Synthetic check.

threshold_windows

object

Alerting time window options.

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.

thresholds

object

List of the different monitor threshold available.

critical

double

The monitor CRITICAL threshold.

critical_recovery

double

The monitor CRITICAL recovery threshold.

ok

double

The monitor OK threshold.

unknown

double

The monitor UNKNOWN threshold.

warning

double

The monitor WARNING threshold.

warning_recovery

double

The monitor WARNING recovery threshold.

timeout_h

int64

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.

overall_state

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

priority

int64

Integer from 1 (high) to 5 (low) indicating alert severity.

query [required]

string

The monitor query.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API. Cannot be used with locked option.

state

object

Wrapper object with the different monitor states.

groups

object

Dictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.

<any-key>

object

Monitor state for a single group.

last_nodata_ts

int64

Latest timestamp the monitor was in NO_DATA state.

last_notified_ts

int64

Latest timestamp of the notification sent for this monitor group.

last_resolved_ts

int64

Latest timestamp the monitor group was resolved.

last_triggered_ts

int64

Latest timestamp the monitor group triggered.

name

string

The name of the monitor.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

tags

[string]

Tags associated to your monitor.

type [required]

enum

The type of the monitor. For more information about type, see the monitor options docs. Allowed enum values: 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

{
  "created": "2019-09-19T10:00:00.000Z",
  "creator": {
    "email": "string",
    "handle": "string",
    "name": "string"
  },
  "deleted": "2019-09-19T10:00:00.000Z",
  "id": "integer",
  "message": "string",
  "modified": "2019-09-19T10:00:00.000Z",
  "multi": false,
  "name": "My monitor",
  "options": {
    "aggregation": {
      "group_by": "host",
      "metric": "metrics.name",
      "type": "count"
    },
    "device_ids": [],
    "enable_logs_sample": false,
    "escalation_message": "string",
    "evaluation_delay": "integer",
    "groupby_simple_monitor": false,
    "include_tags": false,
    "locked": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "new_group_delay": "integer",
    "new_host_delay": "integer",
    "no_data_timeframe": "integer",
    "notify_audit": false,
    "notify_no_data": false,
    "renotify_interval": "integer",
    "renotify_occurrences": "integer",
    "renotify_statuses": [],
    "require_full_window": false,
    "silenced": {
      "<any-key>": "integer"
    },
    "synthetics_check_id": "string",
    "threshold_windows": {
      "recovery_window": "string",
      "trigger_window": "string"
    },
    "thresholds": {
      "critical": "number",
      "critical_recovery": "number",
      "ok": "number",
      "unknown": "number",
      "warning": "number",
      "warning_recovery": "number"
    },
    "timeout_h": "integer"
  },
  "overall_state": "string",
  "priority": "integer",
  "query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
  "restricted_roles": [],
  "state": {
    "groups": {
      "<any-key>": {
        "last_nodata_ts": "integer",
        "last_notified_ts": "integer",
        "last_resolved_ts": "integer",
        "last_triggered_ts": "integer",
        "name": "string",
        "status": "string"
      }
    }
  },
  "tags": [],
  "type": "query alert"
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Monitor Not Found error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Path parameters
export monitor_id="CHANGE_ME"
# Curl command curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor/${monitor_id}/mute" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Mute a monitor
dog.mute_monitor(62_628)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"

from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Mute a monitor
api.Monitor.mute(2088)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

POST https://api.datadoghq.eu/v1/monitor/mute_allhttps://api.ddog-gov.com/v1/monitor/mute_allhttps://api.datadoghq.com/v1/monitor/mute_allhttps://api.us3.datadoghq.com/v1/monitor/mute_allhttps://api.us5.datadoghq.com/v1/monitor/mute_all

Overview

Muting prevents all monitors from notifying through email and posts to the event stream. State changes are only visible by checking the alert page.

Response

OK

Object describing a monitor.

Expand All

Field

Type

Description

created

date-time

Timestamp of the monitor creation.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

deleted

date-time

Whether or not the monitor is deleted. (Always null)

id

int64

ID of this monitor.

message

string

A message to include with notifications for this monitor.

modified

date-time

Last timestamp when the monitor was edited.

multi

boolean

Whether or not the monitor is broken down on different groups.

name

string

The monitor name.

options

object

List of options associated with your monitor.

aggregation

object

Type of aggregation performed in the monitor query.

group_by

string

Group to break down the monitor on.

metric

string

Metric name used in the monitor.

type

string

Metric type used in the monitor.

device_ids

[string]

DEPRECATED: IDs of the device the Synthetics monitor is running on.

enable_logs_sample

boolean

Whether or not to send a log sample when the log monitor triggers.

escalation_message

string

We recommend using the is_renotify, block in the original message instead. A message to include with a re-notification. Supports the @username notification we allow elsewhere. Not applicable if renotify_interval is None.

evaluation_delay

int64

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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.

groupby_simple_monitor

boolean

Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.

include_tags

boolean

A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.

Examples

  • If True, [Triggered on {host:h1}] Monitor Title
  • If False, [Triggered] Monitor Title

locked

boolean

Whether or not the monitor is locked (only editable by creator and admins).

min_failure_duration

int64

How long the test should be in failure before alerting (integer, number of seconds, max 7200).

min_location_failed

int64

The minimum number of locations in failure at the same time during at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration are part of the advanced alerting rules - integer, >= 1).

new_group_delay

int64

Time (in seconds) to skip evaluations for new groups.

For example, this option can be used to skip evaluations for new hosts while they initialize.

Must be a non negative integer.

new_host_delay

int64

DEPRECATED: 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.

Use new_group_delay instead.

no_data_timeframe

int64

The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.

notify_audit

boolean

A Boolean indicating whether tagged users is notified on changes to this monitor.

notify_no_data

boolean

A Boolean indicating whether this monitor notifies when data stops reporting.

renotify_interval

int64

The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.

renotify_occurrences

int64

The number of times re-notification messages should be sent on the current status at the provided re-notification interval.

renotify_statuses

[string]

The types of monitor statuses for which re-notification messages are sent.

require_full_window

boolean

A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to false for sparse metrics, otherwise some evaluations are skipped. Default is false.

silenced

object

DEPRECATED: Information about the downtime applied to the monitor.

<any-key>

int64

ID of the downtime applied to the monitor.

synthetics_check_id

string

DEPRECATED: ID of the corresponding Synthetic check.

threshold_windows

object

Alerting time window options.

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.

thresholds

object

List of the different monitor threshold available.

critical

double

The monitor CRITICAL threshold.

critical_recovery

double

The monitor CRITICAL recovery threshold.

ok

double

The monitor OK threshold.

unknown

double

The monitor UNKNOWN threshold.

warning

double

The monitor WARNING threshold.

warning_recovery

double

The monitor WARNING recovery threshold.

timeout_h

int64

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.

overall_state

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

priority

int64

Integer from 1 (high) to 5 (low) indicating alert severity.

query [required]

string

The monitor query.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API. Cannot be used with locked option.

state

object

Wrapper object with the different monitor states.

groups

object

Dictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.

<any-key>

object

Monitor state for a single group.

last_nodata_ts

int64

Latest timestamp the monitor was in NO_DATA state.

last_notified_ts

int64

Latest timestamp of the notification sent for this monitor group.

last_resolved_ts

int64

Latest timestamp the monitor group was resolved.

last_triggered_ts

int64

Latest timestamp the monitor group triggered.

name

string

The name of the monitor.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

tags

[string]

Tags associated to your monitor.

type [required]

enum

The type of the monitor. For more information about type, see the monitor options docs. Allowed enum values: 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

{
  "created": "2019-09-19T10:00:00.000Z",
  "creator": {
    "email": "string",
    "handle": "string",
    "name": "string"
  },
  "deleted": "2019-09-19T10:00:00.000Z",
  "id": "integer",
  "message": "string",
  "modified": "2019-09-19T10:00:00.000Z",
  "multi": false,
  "name": "My monitor",
  "options": {
    "aggregation": {
      "group_by": "host",
      "metric": "metrics.name",
      "type": "count"
    },
    "device_ids": [],
    "enable_logs_sample": false,
    "escalation_message": "string",
    "evaluation_delay": "integer",
    "groupby_simple_monitor": false,
    "include_tags": false,
    "locked": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "new_group_delay": "integer",
    "new_host_delay": "integer",
    "no_data_timeframe": "integer",
    "notify_audit": false,
    "notify_no_data": false,
    "renotify_interval": "integer",
    "renotify_occurrences": "integer",
    "renotify_statuses": [],
    "require_full_window": false,
    "silenced": {
      "<any-key>": "integer"
    },
    "synthetics_check_id": "string",
    "threshold_windows": {
      "recovery_window": "string",
      "trigger_window": "string"
    },
    "thresholds": {
      "critical": "number",
      "critical_recovery": "number",
      "ok": "number",
      "unknown": "number",
      "warning": "number",
      "warning_recovery": "number"
    },
    "timeout_h": "integer"
  },
  "overall_state": "string",
  "priority": "integer",
  "query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
  "restricted_roles": [],
  "state": {
    "groups": {
      "<any-key>": {
        "last_nodata_ts": "integer",
        "last_notified_ts": "integer",
        "last_resolved_ts": "integer",
        "last_triggered_ts": "integer",
        "name": "string",
        "status": "string"
      }
    }
  },
  "tags": [],
  "type": "query alert"
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/v1/monitor/mute_all" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"

POST https://api.datadoghq.eu/api/v1/monitor/{monitor_id}/unmutehttps://api.ddog-gov.com/api/v1/monitor/{monitor_id}/unmutehttps://api.datadoghq.com/api/v1/monitor/{monitor_id}/unmutehttps://api.us3.datadoghq.com/api/v1/monitor/{monitor_id}/unmutehttps://api.us5.datadoghq.com/api/v1/monitor/{monitor_id}/unmute

Overview

Unmute the specified monitor.

Arguments

Path Parameters

Name

Type

Description

monitor_id [required]

integer

The id of the monitor

Query Strings

Name

Type

Description

scope

string

The scope to apply the mute to. For example, if your alert is grouped by {host}, you might mute host:app1.

all_scopes

boolean

Clear muting across all scopes. Default is false.

Response

OK

Object describing a monitor.

Expand All

Field

Type

Description

created

date-time

Timestamp of the monitor creation.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

deleted

date-time

Whether or not the monitor is deleted. (Always null)

id

int64

ID of this monitor.

message

string

A message to include with notifications for this monitor.

modified

date-time

Last timestamp when the monitor was edited.

multi

boolean

Whether or not the monitor is broken down on different groups.

name

string

The monitor name.

options

object

List of options associated with your monitor.

aggregation

object

Type of aggregation performed in the monitor query.

group_by

string

Group to break down the monitor on.

metric

string

Metric name used in the monitor.

type

string

Metric type used in the monitor.

device_ids

[string]

DEPRECATED: IDs of the device the Synthetics monitor is running on.

enable_logs_sample

boolean

Whether or not to send a log sample when the log monitor triggers.

escalation_message

string

We recommend using the is_renotify, block in the original message instead. A message to include with a re-notification. Supports the @username notification we allow elsewhere. Not applicable if renotify_interval is None.

evaluation_delay

int64

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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.

groupby_simple_monitor

boolean

Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.

include_tags

boolean

A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.

Examples

  • If True, [Triggered on {host:h1}] Monitor Title
  • If False, [Triggered] Monitor Title

locked

boolean

Whether or not the monitor is locked (only editable by creator and admins).

min_failure_duration

int64

How long the test should be in failure before alerting (integer, number of seconds, max 7200).

min_location_failed

int64

The minimum number of locations in failure at the same time during at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration are part of the advanced alerting rules - integer, >= 1).

new_group_delay

int64

Time (in seconds) to skip evaluations for new groups.

For example, this option can be used to skip evaluations for new hosts while they initialize.

Must be a non negative integer.

new_host_delay

int64

DEPRECATED: 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.

Use new_group_delay instead.

no_data_timeframe

int64

The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.

notify_audit

boolean

A Boolean indicating whether tagged users is notified on changes to this monitor.

notify_no_data

boolean

A Boolean indicating whether this monitor notifies when data stops reporting.

renotify_interval

int64

The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.

renotify_occurrences

int64

The number of times re-notification messages should be sent on the current status at the provided re-notification interval.

renotify_statuses

[string]

The types of monitor statuses for which re-notification messages are sent.

require_full_window

boolean

A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to false for sparse metrics, otherwise some evaluations are skipped. Default is false.

silenced

object

DEPRECATED: Information about the downtime applied to the monitor.

<any-key>

int64

ID of the downtime applied to the monitor.

synthetics_check_id

string

DEPRECATED: ID of the corresponding Synthetic check.

threshold_windows

object

Alerting time window options.

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.

thresholds

object

List of the different monitor threshold available.

critical

double

The monitor CRITICAL threshold.

critical_recovery

double

The monitor CRITICAL recovery threshold.

ok

double

The monitor OK threshold.

unknown

double

The monitor UNKNOWN threshold.

warning

double

The monitor WARNING threshold.

warning_recovery

double

The monitor WARNING recovery threshold.

timeout_h

int64

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.

overall_state

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

priority

int64

Integer from 1 (high) to 5 (low) indicating alert severity.

query [required]

string

The monitor query.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API. Cannot be used with locked option.

state

object

Wrapper object with the different monitor states.

groups

object

Dictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.

<any-key>

object

Monitor state for a single group.

last_nodata_ts

int64

Latest timestamp the monitor was in NO_DATA state.

last_notified_ts

int64

Latest timestamp of the notification sent for this monitor group.

last_resolved_ts

int64

Latest timestamp the monitor group was resolved.

last_triggered_ts

int64

Latest timestamp the monitor group triggered.

name

string

The name of the monitor.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

tags

[string]

Tags associated to your monitor.

type [required]

enum

The type of the monitor. For more information about type, see the monitor options docs. Allowed enum values: 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

{
  "created": "2019-09-19T10:00:00.000Z",
  "creator": {
    "email": "string",
    "handle": "string",
    "name": "string"
  },
  "deleted": "2019-09-19T10:00:00.000Z",
  "id": "integer",
  "message": "string",
  "modified": "2019-09-19T10:00:00.000Z",
  "multi": false,
  "name": "My monitor",
  "options": {
    "aggregation": {
      "group_by": "host",
      "metric": "metrics.name",
      "type": "count"
    },
    "device_ids": [],
    "enable_logs_sample": false,
    "escalation_message": "string",
    "evaluation_delay": "integer",
    "groupby_simple_monitor": false,
    "include_tags": false,
    "locked": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "new_group_delay": "integer",
    "new_host_delay": "integer",
    "no_data_timeframe": "integer",
    "notify_audit": false,
    "notify_no_data": false,
    "renotify_interval": "integer",
    "renotify_occurrences": "integer",
    "renotify_statuses": [],
    "require_full_window": false,
    "silenced": {
      "<any-key>": "integer"
    },
    "synthetics_check_id": "string",
    "threshold_windows": {
      "recovery_window": "string",
      "trigger_window": "string"
    },
    "thresholds": {
      "critical": "number",
      "critical_recovery": "number",
      "ok": "number",
      "unknown": "number",
      "warning": "number",
      "warning_recovery": "number"
    },
    "timeout_h": "integer"
  },
  "overall_state": "string",
  "priority": "integer",
  "query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
  "restricted_roles": [],
  "state": {
    "groups": {
      "<any-key>": {
        "last_nodata_ts": "integer",
        "last_notified_ts": "integer",
        "last_resolved_ts": "integer",
        "last_triggered_ts": "integer",
        "name": "string",
        "status": "string"
      }
    }
  },
  "tags": [],
  "type": "query alert"
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Monitor Not Found error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Path parameters
export monitor_id="CHANGE_ME"
# Curl command curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor/${monitor_id}/unmute" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Unmute an alert
dog.unmute_monitor(62_628)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Unmute all alerts
api.Monitor.unmute(2088)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

POST https://api.datadoghq.eu/api/v1/monitorhttps://api.ddog-gov.com/api/v1/monitorhttps://api.datadoghq.com/api/v1/monitorhttps://api.us3.datadoghq.com/api/v1/monitorhttps://api.us5.datadoghq.com/api/v1/monitor

Overview

Create a monitor using the specified options.

Monitor Types

The type of monitor chosen from:

  • anomaly: query alert
  • APM: query alert or trace-analytics alert
  • composite: composite
  • custom: service check
  • event: event alert
  • forecast: query alert
  • host: service check
  • integration: query alert or service check
  • live process: process alert
  • logs: log alert
  • metric: query alert
  • network: service check
  • outlier: query alert
  • process: service check
  • rum: rum alert
  • SLO: slo alert
  • watchdog: event alert
  • event-v2: event-v2 alert
  • audit: audit alert

Query Types

Metric Alert Query

Example: time_aggr(time_window):space_aggr:metric{tags} [by {key}] operator #

  • time_aggr: avg, sum, max, min, change, or pct_change
  • time_window: last_#m (with # between 1 and 10080 depending on the monitor type) or last_#h(with # between 1 and 168 depending on the monitor type) or last_1d, or last_1w
  • space_aggr: avg, sum, min, or max
  • tags: one or more tags (comma-separated), or *
  • key: a ‘key’ in key:value tag syntax; defines a separate alert for each tag in the group (multi-alert)
  • operator: <, <=, >, >=, ==, or !=
  • #: an integer or decimal number used to set the threshold

If you are using the _change_ or _pct_change_ time aggregator, instead use change_aggr(time_aggr(time_window), timeshift):space_aggr:metric{tags} [by {key}] operator # with:

  • change_aggr change, pct_change
  • time_aggr avg, sum, max, min Learn more
  • time_window last_#m (between 1 and 2880 depending on the monitor type), last_#h (between 1 and 48 depending on the monitor type), or last_#d (1 or 2)
  • timeshift #m_ago (5, 10, 15, or 30), #h_ago (1, 2, or 4), or 1d_ago

Use this to create an outlier monitor using the following query: avg(last_30m):outliers(avg:system.cpu.user{role:es-events-data} by {host}, 'dbscan', 7) > 0

Service Check Query

Example: "check".over(tags).last(count).by(group).count_by_status()

  • check name of the check, e.g. datadog.agent.up
  • tags one or more quoted tags (comma-separated), or “*”. e.g.: .over("env:prod", "role:db"); over cannot be blank.
  • count must be at greater than or equal to your max threshold (defined in the options). It is limited to 100. For example, if you’ve specified to notify on 1 critical, 3 ok, and 2 warn statuses, count should be at least 3.
  • group must be specified for check monitors. Per-check grouping is already explicitly known for some service checks. For example, Postgres integration monitors are tagged by db, host, and port, and Network monitors by host, instance, and url. See Service Checks documentation for more information.

Event Alert Query

Example: events('sources:nagios status:error,warning priority:normal tags: "string query"').rollup("count").last("1h")"

  • event, the event query string:
  • string_query free text query to match against event title and text.
  • sources event sources (comma-separated).
  • status event statuses (comma-separated). Valid options: error, warn, and info.
  • priority event priorities (comma-separated). Valid options: low, normal, all.
  • host event reporting host (comma-separated).
  • tags event tags (comma-separated).
  • excluded_tags excluded event tags (comma-separated).
  • rollup the stats roll-up method. count is the only supported method now.
  • last the timeframe to roll up the counts. Examples: 45m, 4h. Supported timeframes: m, h and d. This value should not exceed 48 hours.

NOTE Only available on US1 and EU.

Event V2 Alert Query

Example: events(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • rollup_method The stats roll-up method - supports count, avg and cardinality.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • time_window #m (between 1 and 2880), #h (between 1 and 48).
  • operator <, <=, >, >=, ==, or !=.
  • # an integer or decimal number used to set the threshold.

NOTE Only available on US1-FED, US3, US5 and in closed beta on EU and US1.

Process Alert Query

Example: processes(search).over(tags).rollup('count').last(timeframe) operator #

  • search free text search string for querying processes. Matching processes match results on the Live Processes page.
  • tags one or more tags (comma-separated)
  • timeframe the timeframe to roll up the counts. Examples: 10m, 4h. Supported timeframes: s, m, h and d
  • operator <, <=, >, >=, ==, or !=
  • # an integer or decimal number used to set the threshold

Logs Alert Query

Example: logs(query).index(index_name).rollup(rollup_method[, measure]).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • index_name For multi-index organizations, the log index in which the request is performed.
  • rollup_method The stats roll-up method - supports count, avg and cardinality.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • time_window #m (between 1 and 2880), #h (between 1 and 48).
  • operator <, <=, >, >=, ==, or !=.
  • # an integer or decimal number used to set the threshold.

Composite Query

Example: 12345 && 67890, where 12345 and 67890 are the IDs of non-composite monitors

  • name [required, default = dynamic, based on query]: The name of the alert.
  • message [required, default = dynamic, based on query]: 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.
  • tags [optional, default = empty list]: A list of tags to associate with your monitor. When getting all monitor details via the API, use the monitor_tags argument to filter results by these tags. It is only available via the API and isn’t visible or editable in the Datadog UI.

SLO Alert Query

Example: error_budget("slo_id").over("time_window") operator #

  • slo_id: The alphanumeric SLO ID of the SLO you are configuring the alert for.
  • time_window: The time window of the SLO target you wish to alert on. Valid options: 7d, 30d, 90d.
  • operator: >= or >

Audit Alert Query

Example: audits(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • rollup_method The stats roll-up method - supports count, avg and cardinality.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • time_window #m (between 1 and 2880), #h (between 1 and 48).
  • operator <, <=, >, >=, ==, or !=.
  • # an integer or decimal number used to set the threshold.

NOTE Only available on US1-FED and in closed beta on US1, EU, US3, and US5.

Request

Body Data (required)

Create a monitor request body.

Expand All

Field

Type

Description

created

date-time

Timestamp of the monitor creation.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

deleted

date-time

Whether or not the monitor is deleted. (Always null)

id

int64

ID of this monitor.

message

string

A message to include with notifications for this monitor.

modified

date-time

Last timestamp when the monitor was edited.

multi

boolean

Whether or not the monitor is broken down on different groups.

name

string

The monitor name.

options

object

List of options associated with your monitor.

aggregation

object

Type of aggregation performed in the monitor query.

group_by

string

Group to break down the monitor on.

metric

string

Metric name used in the monitor.

type

string

Metric type used in the monitor.

device_ids

[string]

DEPRECATED: IDs of the device the Synthetics monitor is running on.

enable_logs_sample

boolean

Whether or not to send a log sample when the log monitor triggers.

escalation_message

string

We recommend using the is_renotify, block in the original message instead. A message to include with a re-notification. Supports the @username notification we allow elsewhere. Not applicable if renotify_interval is None.

evaluation_delay

int64

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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.

groupby_simple_monitor

boolean

Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.

include_tags

boolean

A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.

Examples

  • If True, [Triggered on {host:h1}] Monitor Title
  • If False, [Triggered] Monitor Title

locked

boolean

Whether or not the monitor is locked (only editable by creator and admins).

min_failure_duration

int64

How long the test should be in failure before alerting (integer, number of seconds, max 7200).

min_location_failed

int64

The minimum number of locations in failure at the same time during at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration are part of the advanced alerting rules - integer, >= 1).

new_group_delay

int64

Time (in seconds) to skip evaluations for new groups.

For example, this option can be used to skip evaluations for new hosts while they initialize.

Must be a non negative integer.

new_host_delay

int64

DEPRECATED: 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.

Use new_group_delay instead.

no_data_timeframe

int64

The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.

notify_audit

boolean

A Boolean indicating whether tagged users is notified on changes to this monitor.

notify_no_data

boolean

A Boolean indicating whether this monitor notifies when data stops reporting.

renotify_interval

int64

The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.

renotify_occurrences

int64

The number of times re-notification messages should be sent on the current status at the provided re-notification interval.

renotify_statuses

[string]

The types of monitor statuses for which re-notification messages are sent.

require_full_window

boolean

A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to false for sparse metrics, otherwise some evaluations are skipped. Default is false.

silenced

object

DEPRECATED: Information about the downtime applied to the monitor.

<any-key>

int64

ID of the downtime applied to the monitor.

synthetics_check_id

string

DEPRECATED: ID of the corresponding Synthetic check.

threshold_windows

object

Alerting time window options.

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.

thresholds

object

List of the different monitor threshold available.

critical

double

The monitor CRITICAL threshold.

critical_recovery

double

The monitor CRITICAL recovery threshold.

ok

double

The monitor OK threshold.

unknown

double

The monitor UNKNOWN threshold.

warning

double

The monitor WARNING threshold.

warning_recovery

double

The monitor WARNING recovery threshold.

timeout_h

int64

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.

overall_state

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

priority

int64

Integer from 1 (high) to 5 (low) indicating alert severity.

query [required]

string

The monitor query.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API. Cannot be used with locked option.

state

object

Wrapper object with the different monitor states.

groups

object

Dictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.

<any-key>

object

Monitor state for a single group.

last_nodata_ts

int64

Latest timestamp the monitor was in NO_DATA state.

last_notified_ts

int64

Latest timestamp of the notification sent for this monitor group.

last_resolved_ts

int64

Latest timestamp the monitor group was resolved.

last_triggered_ts

int64

Latest timestamp the monitor group triggered.

name

string

The name of the monitor.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

tags

[string]

Tags associated to your monitor.

type [required]

enum

The type of the monitor. For more information about type, see the monitor options docs. Allowed enum values: 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

{
  "name": "Example-Create_a_monitor_returns_OK_response",
  "type": "log alert",
  "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\") > 2",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplecreateamonitorreturnsokresponse",
    "env:ci"
  ],
  "priority": 3,
  "restricted_roles": [
    "string"
  ]
}

Response

OK

Object describing a monitor.

Expand All

Field

Type

Description

created

date-time

Timestamp of the monitor creation.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

deleted

date-time

Whether or not the monitor is deleted. (Always null)

id

int64

ID of this monitor.

message

string

A message to include with notifications for this monitor.

modified

date-time

Last timestamp when the monitor was edited.

multi

boolean

Whether or not the monitor is broken down on different groups.

name

string

The monitor name.

options

object

List of options associated with your monitor.

aggregation

object

Type of aggregation performed in the monitor query.

group_by

string

Group to break down the monitor on.

metric

string

Metric name used in the monitor.

type

string

Metric type used in the monitor.

device_ids

[string]

DEPRECATED: IDs of the device the Synthetics monitor is running on.

enable_logs_sample

boolean

Whether or not to send a log sample when the log monitor triggers.

escalation_message

string

We recommend using the is_renotify, block in the original message instead. A message to include with a re-notification. Supports the @username notification we allow elsewhere. Not applicable if renotify_interval is None.

evaluation_delay

int64

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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.

groupby_simple_monitor

boolean

Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.

include_tags

boolean

A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.

Examples

  • If True, [Triggered on {host:h1}] Monitor Title
  • If False, [Triggered] Monitor Title

locked

boolean

Whether or not the monitor is locked (only editable by creator and admins).

min_failure_duration

int64

How long the test should be in failure before alerting (integer, number of seconds, max 7200).

min_location_failed

int64

The minimum number of locations in failure at the same time during at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration are part of the advanced alerting rules - integer, >= 1).

new_group_delay

int64

Time (in seconds) to skip evaluations for new groups.

For example, this option can be used to skip evaluations for new hosts while they initialize.

Must be a non negative integer.

new_host_delay

int64

DEPRECATED: 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.

Use new_group_delay instead.

no_data_timeframe

int64

The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.

notify_audit

boolean

A Boolean indicating whether tagged users is notified on changes to this monitor.

notify_no_data

boolean

A Boolean indicating whether this monitor notifies when data stops reporting.

renotify_interval

int64

The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.

renotify_occurrences

int64

The number of times re-notification messages should be sent on the current status at the provided re-notification interval.

renotify_statuses

[string]

The types of monitor statuses for which re-notification messages are sent.

require_full_window

boolean

A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to false for sparse metrics, otherwise some evaluations are skipped. Default is false.

silenced

object

DEPRECATED: Information about the downtime applied to the monitor.

<any-key>

int64

ID of the downtime applied to the monitor.

synthetics_check_id

string

DEPRECATED: ID of the corresponding Synthetic check.

threshold_windows

object

Alerting time window options.

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.

thresholds

object

List of the different monitor threshold available.

critical

double

The monitor CRITICAL threshold.

critical_recovery

double

The monitor CRITICAL recovery threshold.

ok

double

The monitor OK threshold.

unknown

double

The monitor UNKNOWN threshold.

warning

double

The monitor WARNING threshold.

warning_recovery

double

The monitor WARNING recovery threshold.

timeout_h

int64

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.

overall_state

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

priority

int64

Integer from 1 (high) to 5 (low) indicating alert severity.

query [required]

string

The monitor query.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API. Cannot be used with locked option.

state

object

Wrapper object with the different monitor states.

groups

object

Dictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.

<any-key>

object

Monitor state for a single group.

last_nodata_ts

int64

Latest timestamp the monitor was in NO_DATA state.

last_notified_ts

int64

Latest timestamp of the notification sent for this monitor group.

last_resolved_ts

int64

Latest timestamp the monitor group was resolved.

last_triggered_ts

int64

Latest timestamp the monitor group triggered.

name

string

The name of the monitor.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

tags

[string]

Tags associated to your monitor.

type [required]

enum

The type of the monitor. For more information about type, see the monitor options docs. Allowed enum values: 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

{
  "created": "2019-09-19T10:00:00.000Z",
  "creator": {
    "email": "string",
    "handle": "string",
    "name": "string"
  },
  "deleted": "2019-09-19T10:00:00.000Z",
  "id": "integer",
  "message": "string",
  "modified": "2019-09-19T10:00:00.000Z",
  "multi": false,
  "name": "My monitor",
  "options": {
    "aggregation": {
      "group_by": "host",
      "metric": "metrics.name",
      "type": "count"
    },
    "device_ids": [],
    "enable_logs_sample": false,
    "escalation_message": "string",
    "evaluation_delay": "integer",
    "groupby_simple_monitor": false,
    "include_tags": false,
    "locked": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "new_group_delay": "integer",
    "new_host_delay": "integer",
    "no_data_timeframe": "integer",
    "notify_audit": false,
    "notify_no_data": false,
    "renotify_interval": "integer",
    "renotify_occurrences": "integer",
    "renotify_statuses": [],
    "require_full_window": false,
    "silenced": {
      "<any-key>": "integer"
    },
    "synthetics_check_id": "string",
    "threshold_windows": {
      "recovery_window": "string",
      "trigger_window": "string"
    },
    "thresholds": {
      "critical": "number",
      "critical_recovery": "number",
      "ok": "number",
      "unknown": "number",
      "warning": "number",
      "warning_recovery": "number"
    },
    "timeout_h": "integer"
  },
  "overall_state": "string",
  "priority": "integer",
  "query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
  "restricted_roles": [],
  "state": {
    "groups": {
      "<any-key>": {
        "last_nodata_ts": "integer",
        "last_notified_ts": "integer",
        "last_resolved_ts": "integer",
        "last_triggered_ts": "integer",
        "name": "string",
        "status": "string"
      }
    }
  },
  "tags": [],
  "type": "query alert"
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


## json-request-body
# 
# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "message": "You may need to add web hosts if this is consistently high.",
  "name": "Bytes received on host0",
  "options": {
    "no_data_timeframe": 20,
    "notify_no_data": true
  },
  "query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} \u003e 100",
  "tags": [
    "app:webserver",
    "frontend"
  ],
  "type": "query alert"
}
EOF
"""
Create a monitor returns "OK" response
"""

from os import environ
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_type import MonitorType

# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]

body = Monitor(
    name="Example-Create_a_monitor_returns_OK_response",
    type=MonitorType("log alert"),
    query='logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2',
    message="some message Notify: @hipchat-channel",
    tags=["test:examplecreateamonitorreturnsokresponse", "env:ci"],
    priority=3,
    restricted_roles=[ROLE_DATA_ID],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.create_monitor(body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Create a monitor returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MonitorsAPI.new

# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]

body = DatadogAPIClient::V1::Monitor.new({
  name: "Example-Create_a_monitor_returns_OK_response",
  type: DatadogAPIClient::V1::MonitorType::LOG_ALERT,
  query: 'logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2',
  message: "some message Notify: @hipchat-channel",
  tags: [
    "test:examplecreateamonitorreturnsokresponse",
    "env:ci",
  ],
  priority: 3,
  restricted_roles: [
    ROLE_DATA_ID,
  ],
})
p api_instance.create_monitor(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Create a new monitor
options = {
  'notify_no_data' => true,
  'no_data_timeframe' => 20
}
tags = ['app:webserver', 'frontend']
dog.monitor(
  'query alert',
  'avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100',
  name: 'Bytes received on host0',
  message: 'We may need to add web hosts if this is consistently high.',
  tags: tags,
  options: options
)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Create a monitor returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.MonitorsApi(configuration);

// there is a valid "role" in the system
let ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;

let params: v1.MonitorsApiCreateMonitorRequest = {
  body: {
    name: "Example-Create_a_monitor_returns_OK_response",
    type: "log alert",
    query: `logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2`,
    message: "some message Notify: @hipchat-channel",
    tags: ["test:examplecreateamonitorreturnsokresponse", "env:ci"],
    priority: 3,
    restrictedRoles: [ROLE_DATA_ID],
  },
};

apiInstance
  .createMonitor(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Create a monitor returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	// there is a valid "role" in the system
	ROLE_DATA_ID := os.Getenv("ROLE_DATA_ID")

	body := datadog.Monitor{
		Name:    datadog.PtrString("Example-Create_a_monitor_returns_OK_response"),
		Type:    datadog.MONITORTYPE_LOG_ALERT,
		Query:   `logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2`,
		Message: datadog.PtrString("some message Notify: @hipchat-channel"),
		Tags: &[]string{
			"test:examplecreateamonitorreturnsokresponse",
			"env:ci",
		},
		Priority: *datadog.NewNullableInt64(datadog.PtrInt64(3)),
		RestrictedRoles: []string{
			ROLE_DATA_ID,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MonitorsApi.CreateMonitor(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.CreateMonitor`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.CreateMonitor`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Create a monitor returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.MonitorsApi;
import com.datadog.api.v1.client.model.Monitor;
import com.datadog.api.v1.client.model.MonitorType;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    MonitorsApi apiInstance = new MonitorsApi(defaultClient);

    // there is a valid "role" in the system
    String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");

    Monitor body =
        new Monitor()
            .name("Example-Create_a_monitor_returns_OK_response")
            .type(MonitorType.LOG_ALERT)
            .query(
                """
logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2
""")
            .message("some message Notify: @hipchat-channel")
            .tags(
                new ArrayList<String>() {
                  {
                    add("test:examplecreateamonitorreturnsokresponse");
                    add("env:ci");
                  }
                })
            .priority(3L)
            .restrictedRoles(
                new ArrayList<String>() {
                  {
                    add(ROLE_DATA_ID);
                  }
                });

    try {
      Monitor result = apiInstance.createMonitor(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#updateDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Create a new monitor
monitor_options = {
    "notify_no_data": True,
    "no_data_timeframe": 20
}
tags = ["app:webserver", "frontend"]
api.Monitor.create(
    type="query alert",
    query="avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
    name="Bytes received on host0",
    message="We may need to add web hosts if this is consistently high.",
    tags=tags,
    options=monitor_options
)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

GET https://api.datadoghq.eu/api/v1/monitor/searchhttps://api.ddog-gov.com/api/v1/monitor/searchhttps://api.datadoghq.com/api/v1/monitor/searchhttps://api.us3.datadoghq.com/api/v1/monitor/searchhttps://api.us5.datadoghq.com/api/v1/monitor/search

Overview

Search and filter your monitors details.

Arguments

Query Strings

Name

Type

Description

query

string

After entering a search query in your Manage Monitor page use the query parameter value in the URL of the page as value for this parameter. Consult the dedicated manage monitor documentation page to learn more.

The query can contain any number of space-separated monitor attributes, for instance query="type:metric status:alert".

page

integer

Page to start paginating from.

per_page

integer

Number of monitors to return per page.

sort

string

String for sort order, composed of field and sort order separate by a comma, e.g. name,asc. Supported sort directions: asc, desc. Supported fields:

  • name
  • status
  • tags

Response

OK

The response form a monitor search.

Expand All

Field

Type

Description

counts

object

The counts of monitors per different criteria.

muted

[object]

Search facets.

count

int64

The number of found monitors with the listed value.

name

The facet value.

status

[object]

Search facets.

count

int64

The number of found monitors with the listed value.

name

The facet value.

tag

[object]

Search facets.

count

int64

The number of found monitors with the listed value.

name

The facet value.

type

[object]

Search facets.

count

int64

The number of found monitors with the listed value.

name

The facet value.

metadata

object

Metadata about the response.

page

int64

The page to start paginating from.

page_count

int64

The number of pages.

per_page

int64

The number of monitors to return per page.

total_count

int64

The total number of monitors.

monitors

[object]

The list of found monitors.

classification

string

Classification of the monitor.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

id

int64

ID of the monitor.

last_triggered_ts

int64

Latest timestamp the monitor triggered.

metrics

[string]

Metrics used by the monitor.

name

string

The monitor name.

notifications

[object]

The notification triggered by the monitor.

handle

string

The email address that received the notification.

name

string

The username receiving the notification

org_id

int64

The ID of the organization.

query

string

The monitor query.

scopes

[string]

The scope(s) to which the downtime applies, e.g. host:app2. Provide multiple scopes as a comma-separated list, e.g. env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (i.e. env:dev AND env:prod), NOT any of them.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

tags

[string]

Tags associated with the monitor.

type

enum

The type of the monitor. For more information about type, see the monitor options docs. Allowed enum values: 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

{
  "counts": {
    "muted": [
      {
        "count": "integer",
        "name": "undefined"
      }
    ],
    "status": [
      {
        "count": "integer",
        "name": "undefined"
      }
    ],
    "tag": [
      {
        "count": "integer",
        "name": "undefined"
      }
    ],
    "type": [
      {
        "count": "integer",
        "name": "undefined"
      }
    ]
  },
  "metadata": {
    "page": "integer",
    "page_count": "integer",
    "per_page": "integer",
    "total_count": "integer"
  },
  "monitors": [
    {
      "classification": "string",
      "creator": {
        "email": "string",
        "handle": "string",
        "name": "string"
      },
      "id": "integer",
      "last_triggered_ts": "integer",
      "metrics": [],
      "name": "string",
      "notifications": [
        {
          "handle": "string",
          "name": "string"
        }
      ],
      "org_id": "integer",
      "query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
      "scopes": [
        "host:app2",
        "env:dev,env:prod"
      ],
      "status": "string",
      "tags": [],
      "type": "query alert"
    }
  ]
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Curl command
curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor/search" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Monitors search returns "OK" response
"""

from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.search_monitors()

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Monitors search returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MonitorsAPI.new
p api_instance.search_monitors()

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Search monitors
dog.search_monitors

# Examples of possible query parameters:
# dog.search_monitors(query="id:7100311")
# dog.search_monitors(query="title:foo metric:system.core.idle status:Alert")

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Monitors search returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.MonitorsApi(configuration);

apiInstance
  .searchMonitors()
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Monitors search returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MonitorsApi.SearchMonitors(ctx, *datadog.NewSearchMonitorsOptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.SearchMonitors`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.SearchMonitors`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Monitors search returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.MonitorsApi;
import com.datadog.api.v1.client.model.MonitorSearchResponse;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    MonitorsApi apiInstance = new MonitorsApi(defaultClient);

    try {
      MonitorSearchResponse result = apiInstance.searchMonitors();
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#updateDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api

options = {
	'api_key': '<DATADOG_API_KEY>',
	'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Search monitors
api.Monitor.search()

# Examples of possible query parameters:
# api.Monitor.search(query="id:7100311")
# api.Monitor.search(query="title:foo metric:system.core.idle status:Alert")

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

GET https://api.datadoghq.eu/api/v1/monitorhttps://api.ddog-gov.com/api/v1/monitorhttps://api.datadoghq.com/api/v1/monitorhttps://api.us3.datadoghq.com/api/v1/monitorhttps://api.us5.datadoghq.com/api/v1/monitor

Overview

Get details about the specified monitor from your organization.

Arguments

Query Strings

Name

Type

Description

group_states

string

When specified, shows additional information about the group states. Choose one or more from all, alert, warn, and no data.

name

string

A string to filter monitors by name.

tags

string

A comma separated list indicating what tags, if any, should be used to filter the list of monitors by scope. For example, host:host0.

monitor_tags

string

A comma separated list indicating what service and/or custom tags, if any, should be used to filter the list of monitors. Tags created in the Datadog UI automatically have the service key prepended. For example, service:my-app.

with_downtimes

boolean

If this argument is set to true, then the returned data includes all current active downtimes for each monitor.

id_offset

integer

Monitor ID offset.

page

integer

The page to start paginating from. If this argument is not specified, the request returns all monitors without pagination.

page_size

integer

The number of monitors to return per page. If the page argument is not specified, the default behavior returns all monitors without a page_size limit. However, if page is specified and page_size is not, the argument defaults to 100.

Response

OK

Expand All

Field

Type

Description

created

date-time

Timestamp of the monitor creation.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

deleted

date-time

Whether or not the monitor is deleted. (Always null)

id

int64

ID of this monitor.

message

string

A message to include with notifications for this monitor.

modified

date-time

Last timestamp when the monitor was edited.

multi

boolean

Whether or not the monitor is broken down on different groups.

name

string

The monitor name.

options

object

List of options associated with your monitor.

aggregation

object

Type of aggregation performed in the monitor query.

group_by

string

Group to break down the monitor on.

metric

string

Metric name used in the monitor.

type

string

Metric type used in the monitor.

device_ids

[string]

DEPRECATED: IDs of the device the Synthetics monitor is running on.

enable_logs_sample

boolean

Whether or not to send a log sample when the log monitor triggers.

escalation_message

string

We recommend using the is_renotify, block in the original message instead. A message to include with a re-notification. Supports the @username notification we allow elsewhere. Not applicable if renotify_interval is None.

evaluation_delay

int64

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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.

groupby_simple_monitor

boolean

Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.

include_tags

boolean

A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.

Examples

  • If True, [Triggered on {host:h1}] Monitor Title
  • If False, [Triggered] Monitor Title

locked

boolean

Whether or not the monitor is locked (only editable by creator and admins).

min_failure_duration

int64

How long the test should be in failure before alerting (integer, number of seconds, max 7200).

min_location_failed

int64

The minimum number of locations in failure at the same time during at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration are part of the advanced alerting rules - integer, >= 1).

new_group_delay

int64

Time (in seconds) to skip evaluations for new groups.

For example, this option can be used to skip evaluations for new hosts while they initialize.

Must be a non negative integer.

new_host_delay

int64

DEPRECATED: 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.

Use new_group_delay instead.

no_data_timeframe

int64

The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.

notify_audit

boolean

A Boolean indicating whether tagged users is notified on changes to this monitor.

notify_no_data

boolean

A Boolean indicating whether this monitor notifies when data stops reporting.

renotify_interval

int64

The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.

renotify_occurrences

int64

The number of times re-notification messages should be sent on the current status at the provided re-notification interval.

renotify_statuses

[string]

The types of monitor statuses for which re-notification messages are sent.

require_full_window

boolean

A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to false for sparse metrics, otherwise some evaluations are skipped. Default is false.

silenced

object

DEPRECATED: Information about the downtime applied to the monitor.

<any-key>

int64

ID of the downtime applied to the monitor.

synthetics_check_id

string

DEPRECATED: ID of the corresponding Synthetic check.

threshold_windows

object

Alerting time window options.

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.

thresholds

object

List of the different monitor threshold available.

critical

double

The monitor CRITICAL threshold.

critical_recovery

double

The monitor CRITICAL recovery threshold.

ok

double

The monitor OK threshold.

unknown

double

The monitor UNKNOWN threshold.

warning

double

The monitor WARNING threshold.

warning_recovery

double

The monitor WARNING recovery threshold.

timeout_h

int64

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.

overall_state

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

priority

int64

Integer from 1 (high) to 5 (low) indicating alert severity.

query

string

The monitor query.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API. Cannot be used with locked option.

state

object

Wrapper object with the different monitor states.

groups

object

Dictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.

<any-key>

object

Monitor state for a single group.

last_nodata_ts

int64

Latest timestamp the monitor was in NO_DATA state.

last_notified_ts

int64

Latest timestamp of the notification sent for this monitor group.

last_resolved_ts

int64

Latest timestamp the monitor group was resolved.

last_triggered_ts

int64

Latest timestamp the monitor group triggered.

name

string

The name of the monitor.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

tags

[string]

Tags associated to your monitor.

type

enum

The type of the monitor. For more information about type, see the monitor options docs. Allowed enum values: 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

{
  "created": "2019-09-19T10:00:00.000Z",
  "creator": {
    "email": "string",
    "handle": "string",
    "name": "string"
  },
  "deleted": "2019-09-19T10:00:00.000Z",
  "id": "integer",
  "message": "string",
  "modified": "2019-09-19T10:00:00.000Z",
  "multi": false,
  "name": "My monitor",
  "options": {
    "aggregation": {
      "group_by": "host",
      "metric": "metrics.name",
      "type": "count"
    },
    "device_ids": [],
    "enable_logs_sample": false,
    "escalation_message": "string",
    "evaluation_delay": "integer",
    "groupby_simple_monitor": false,
    "include_tags": false,
    "locked": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "new_group_delay": "integer",
    "new_host_delay": "integer",
    "no_data_timeframe": "integer",
    "notify_audit": false,
    "notify_no_data": false,
    "renotify_interval": "integer",
    "renotify_occurrences": "integer",
    "renotify_statuses": [],
    "require_full_window": false,
    "silenced": {
      "<any-key>": "integer"
    },
    "synthetics_check_id": "string",
    "threshold_windows": {
      "recovery_window": "string",
      "trigger_window": "string"
    },
    "thresholds": {
      "critical": "number",
      "critical_recovery": "number",
      "ok": "number",
      "unknown": "number",
      "warning": "number",
      "warning_recovery": "number"
    },
    "timeout_h": "integer"
  },
  "overall_state": "string",
  "priority": "integer",
  "query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
  "restricted_roles": [],
  "state": {
    "groups": {
      "<any-key>": {
        "last_nodata_ts": "integer",
        "last_notified_ts": "integer",
        "last_resolved_ts": "integer",
        "last_triggered_ts": "integer",
        "name": "string",
        "status": "string"
      }
    }
  },
  "tags": [],
  "type": "query alert"
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Curl command
curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get all monitor details returns "OK" response
"""

from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.list_monitors()

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get all monitor details returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MonitorsAPI.new
p api_instance.list_monitors()

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Get all monitor details
dog.get_all_monitors

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get all monitor details returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.MonitorsApi(configuration);

apiInstance
  .listMonitors()
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get all monitor details returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MonitorsApi.ListMonitors(ctx, *datadog.NewListMonitorsOptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.ListMonitors`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.ListMonitors`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get all monitor details returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.MonitorsApi;
import com.datadog.api.v1.client.model.Monitor;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    MonitorsApi apiInstance = new MonitorsApi(defaultClient);

    try {
      List<Monitor> result = apiInstance.listMonitors();
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#updateDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Get all monitor details
print(api.Monitor.get_all())

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

GET https://api.datadoghq.eu/api/v1/monitor/groups/searchhttps://api.ddog-gov.com/api/v1/monitor/groups/searchhttps://api.datadoghq.com/api/v1/monitor/groups/searchhttps://api.us3.datadoghq.com/api/v1/monitor/groups/searchhttps://api.us5.datadoghq.com/api/v1/monitor/groups/search

Overview

Search and filter your monitor groups details.

Arguments

Query Strings

Name

Type

Description

query

string

After entering a search query in your Manage Monitor page use the query parameter value in the URL of the page as value for this parameter. Consult the dedicated manage monitor documentation page to learn more.

The query can contain any number of space-separated monitor attributes, for instance query="type:metric status:alert".

page

integer

Page to start paginating from.

per_page

integer

Number of monitors to return per page.

sort

string

String for sort order, composed of field and sort order separate by a comma, e.g. name,asc. Supported sort directions: asc, desc. Supported fields:

  • name
  • status
  • tags

Response

OK

The response of a monitor group search.

Expand All

Field

Type

Description

counts

object

The counts of monitor groups per different criteria.

status

[object]

Search facets.

count

int64

The number of found monitors with the listed value.

name

The facet value.

type

[object]

Search facets.

count

int64

The number of found monitors with the listed value.

name

The facet value.

groups

[object]

The list of found monitor groups.

group

string

The name of the group.

group_tags

[string]

The list of tags of the monitor group.

last_nodata_ts

int64

Latest timestamp the monitor group was in NO_DATA state.

last_triggered_ts

int64

Latest timestamp the monitor group triggered.

monitor_id

int64

The ID of the monitor.

monitor_name

string

The name of the monitor.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

metadata

object

Metadata about the response.

page

int64

The page to start paginating from.

page_count

int64

The number of pages.

per_page

int64

The number of monitors to return per page.

total_count

int64

The total number of monitors.

{
  "counts": {
    "status": [
      {
        "count": "integer",
        "name": "undefined"
      }
    ],
    "type": [
      {
        "count": "integer",
        "name": "undefined"
      }
    ]
  },
  "groups": [
    {
      "group": "string",
      "group_tags": [],
      "last_nodata_ts": "integer",
      "last_triggered_ts": "integer",
      "monitor_id": "integer",
      "monitor_name": "string",
      "status": "string"
    }
  ],
  "metadata": {
    "page": "integer",
    "page_count": "integer",
    "per_page": "integer",
    "total_count": "integer"
  }
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Curl command
curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor/groups/search" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Monitors group search returns "OK" response
"""

from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.search_monitor_groups()

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Monitors group search returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MonitorsAPI.new
p api_instance.search_monitor_groups()

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Search monitor groups
dog.search_monitor_groups

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Monitors group search returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.MonitorsApi(configuration);

apiInstance
  .searchMonitorGroups()
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Monitors group search returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MonitorsApi.SearchMonitorGroups(ctx, *datadog.NewSearchMonitorGroupsOptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.SearchMonitorGroups`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.SearchMonitorGroups`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Monitors group search returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.MonitorsApi;
import com.datadog.api.v1.client.model.MonitorGroupSearchResponse;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    MonitorsApi apiInstance = new MonitorsApi(defaultClient);

    try {
      MonitorGroupSearchResponse result = apiInstance.searchMonitorGroups();
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#updateDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api

options = {
	'api_key': '<DATADOG_API_KEY>',
	'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Search monitor groups
api.Monitor.search_groups()

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

PUT https://api.datadoghq.eu/api/v1/monitor/{monitor_id}https://api.ddog-gov.com/api/v1/monitor/{monitor_id}https://api.datadoghq.com/api/v1/monitor/{monitor_id}https://api.us3.datadoghq.com/api/v1/monitor/{monitor_id}https://api.us5.datadoghq.com/api/v1/monitor/{monitor_id}

Overview

Edit the specified monitor.

Arguments

Path Parameters

Name

Type

Description

monitor_id [required]

integer

The ID of the monitor.

Request

Body Data (required)

Edit a monitor request body.

Expand All

Field

Type

Description

created

date-time

Timestamp of the monitor creation.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

deleted

date-time

Whether or not the monitor is deleted. (Always null)

id

int64

ID of this monitor.

message

string

A message to include with notifications for this monitor.

modified

date-time

Last timestamp when the monitor was edited.

multi

boolean

Whether or not the monitor is broken down on different groups.

name

string

The monitor name.

options

object

List of options associated with your monitor.

aggregation

object

Type of aggregation performed in the monitor query.

group_by

string

Group to break down the monitor on.

metric

string

Metric name used in the monitor.

type

string

Metric type used in the monitor.

device_ids

[string]

DEPRECATED: IDs of the device the Synthetics monitor is running on.

enable_logs_sample

boolean

Whether or not to send a log sample when the log monitor triggers.

escalation_message

string

We recommend using the is_renotify, block in the original message instead. A message to include with a re-notification. Supports the @username notification we allow elsewhere. Not applicable if renotify_interval is None.

evaluation_delay

int64

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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.

groupby_simple_monitor

boolean

Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.

include_tags

boolean

A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.

Examples

  • If True, [Triggered on {host:h1}] Monitor Title
  • If False, [Triggered] Monitor Title

locked

boolean

Whether or not the monitor is locked (only editable by creator and admins).

min_failure_duration

int64

How long the test should be in failure before alerting (integer, number of seconds, max 7200).

min_location_failed

int64

The minimum number of locations in failure at the same time during at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration are part of the advanced alerting rules - integer, >= 1).

new_group_delay

int64

Time (in seconds) to skip evaluations for new groups.

For example, this option can be used to skip evaluations for new hosts while they initialize.

Must be a non negative integer.

new_host_delay

int64

DEPRECATED: 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.

Use new_group_delay instead.

no_data_timeframe

int64

The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.

notify_audit

boolean

A Boolean indicating whether tagged users is notified on changes to this monitor.

notify_no_data

boolean

A Boolean indicating whether this monitor notifies when data stops reporting.

renotify_interval

int64

The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.

renotify_occurrences

int64

The number of times re-notification messages should be sent on the current status at the provided re-notification interval.

renotify_statuses

[string]

The types of monitor statuses for which re-notification messages are sent.

require_full_window

boolean

A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to false for sparse metrics, otherwise some evaluations are skipped. Default is false.

silenced

object

DEPRECATED: Information about the downtime applied to the monitor.

<any-key>

int64

ID of the downtime applied to the monitor.

synthetics_check_id

string

DEPRECATED: ID of the corresponding Synthetic check.

threshold_windows

object

Alerting time window options.

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.

thresholds

object

List of the different monitor threshold available.

critical

double

The monitor CRITICAL threshold.

critical_recovery

double

The monitor CRITICAL recovery threshold.

ok

double

The monitor OK threshold.

unknown

double

The monitor UNKNOWN threshold.

warning

double

The monitor WARNING threshold.

warning_recovery

double

The monitor WARNING recovery threshold.

timeout_h

int64

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.

overall_state

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

priority

int64

Integer from 1 (high) to 5 (low) indicating alert severity.

query

string

The monitor query.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API. Cannot be used with locked option.

state

object

Wrapper object with the different monitor states.

groups

object

Dictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.

<any-key>

object

Monitor state for a single group.

last_nodata_ts

int64

Latest timestamp the monitor was in NO_DATA state.

last_notified_ts

int64

Latest timestamp of the notification sent for this monitor group.

last_resolved_ts

int64

Latest timestamp the monitor group was resolved.

last_triggered_ts

int64

Latest timestamp the monitor group triggered.

name

string

The name of the monitor.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

tags

[string]

Tags associated to your monitor.

type

enum

The type of the monitor. For more information about type, see the monitor options docs. Allowed enum values: 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

{
  "name": "My monitor-updated",
  "options": {
    "evaluation_delay": null,
    "new_group_delay": 600,
    "new_host_delay": null,
    "renotify_interval": null,
    "thresholds": {
      "critical": 2,
      "warning": null
    },
    "timeout_h": null
  }
}

Response

OK

Object describing a monitor.

Expand All

Field

Type

Description

created

date-time

Timestamp of the monitor creation.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

deleted

date-time

Whether or not the monitor is deleted. (Always null)

id

int64

ID of this monitor.

message

string

A message to include with notifications for this monitor.

modified

date-time

Last timestamp when the monitor was edited.

multi

boolean

Whether or not the monitor is broken down on different groups.

name

string

The monitor name.

options

object

List of options associated with your monitor.

aggregation

object

Type of aggregation performed in the monitor query.

group_by

string

Group to break down the monitor on.

metric

string

Metric name used in the monitor.

type

string

Metric type used in the monitor.

device_ids

[string]

DEPRECATED: IDs of the device the Synthetics monitor is running on.

enable_logs_sample

boolean

Whether or not to send a log sample when the log monitor triggers.

escalation_message

string

We recommend using the is_renotify, block in the original message instead. A message to include with a re-notification. Supports the @username notification we allow elsewhere. Not applicable if renotify_interval is None.

evaluation_delay

int64

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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.

groupby_simple_monitor

boolean

Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.

include_tags

boolean

A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.

Examples

  • If True, [Triggered on {host:h1}] Monitor Title
  • If False, [Triggered] Monitor Title

locked

boolean

Whether or not the monitor is locked (only editable by creator and admins).

min_failure_duration

int64

How long the test should be in failure before alerting (integer, number of seconds, max 7200).

min_location_failed

int64

The minimum number of locations in failure at the same time during at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration are part of the advanced alerting rules - integer, >= 1).

new_group_delay

int64

Time (in seconds) to skip evaluations for new groups.

For example, this option can be used to skip evaluations for new hosts while they initialize.

Must be a non negative integer.

new_host_delay

int64

DEPRECATED: 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.

Use new_group_delay instead.

no_data_timeframe

int64

The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.

notify_audit

boolean

A Boolean indicating whether tagged users is notified on changes to this monitor.

notify_no_data

boolean

A Boolean indicating whether this monitor notifies when data stops reporting.

renotify_interval

int64

The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.

renotify_occurrences

int64

The number of times re-notification messages should be sent on the current status at the provided re-notification interval.

renotify_statuses

[string]

The types of monitor statuses for which re-notification messages are sent.

require_full_window

boolean

A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to false for sparse metrics, otherwise some evaluations are skipped. Default is false.

silenced

object

DEPRECATED: Information about the downtime applied to the monitor.

<any-key>

int64

ID of the downtime applied to the monitor.

synthetics_check_id

string

DEPRECATED: ID of the corresponding Synthetic check.

threshold_windows

object

Alerting time window options.

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.

thresholds

object

List of the different monitor threshold available.

critical

double

The monitor CRITICAL threshold.

critical_recovery

double

The monitor CRITICAL recovery threshold.

ok

double

The monitor OK threshold.

unknown

double

The monitor UNKNOWN threshold.

warning

double

The monitor WARNING threshold.

warning_recovery

double

The monitor WARNING recovery threshold.

timeout_h

int64

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.

overall_state

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

priority

int64

Integer from 1 (high) to 5 (low) indicating alert severity.

query [required]

string

The monitor query.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API. Cannot be used with locked option.

state

object

Wrapper object with the different monitor states.

groups

object

Dictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.

<any-key>

object

Monitor state for a single group.

last_nodata_ts

int64

Latest timestamp the monitor was in NO_DATA state.

last_notified_ts

int64

Latest timestamp of the notification sent for this monitor group.

last_resolved_ts

int64

Latest timestamp the monitor group was resolved.

last_triggered_ts

int64

Latest timestamp the monitor group triggered.

name

string

The name of the monitor.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

tags

[string]

Tags associated to your monitor.

type [required]

enum

The type of the monitor. For more information about type, see the monitor options docs. Allowed enum values: 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

{
  "created": "2019-09-19T10:00:00.000Z",
  "creator": {
    "email": "string",
    "handle": "string",
    "name": "string"
  },
  "deleted": "2019-09-19T10:00:00.000Z",
  "id": "integer",
  "message": "string",
  "modified": "2019-09-19T10:00:00.000Z",
  "multi": false,
  "name": "My monitor",
  "options": {
    "aggregation": {
      "group_by": "host",
      "metric": "metrics.name",
      "type": "count"
    },
    "device_ids": [],
    "enable_logs_sample": false,
    "escalation_message": "string",
    "evaluation_delay": "integer",
    "groupby_simple_monitor": false,
    "include_tags": false,
    "locked": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "new_group_delay": "integer",
    "new_host_delay": "integer",
    "no_data_timeframe": "integer",
    "notify_audit": false,
    "notify_no_data": false,
    "renotify_interval": "integer",
    "renotify_occurrences": "integer",
    "renotify_statuses": [],
    "require_full_window": false,
    "silenced": {
      "<any-key>": "integer"
    },
    "synthetics_check_id": "string",
    "threshold_windows": {
      "recovery_window": "string",
      "trigger_window": "string"
    },
    "thresholds": {
      "critical": "number",
      "critical_recovery": "number",
      "ok": "number",
      "unknown": "number",
      "warning": "number",
      "warning_recovery": "number"
    },
    "timeout_h": "integer"
  },
  "overall_state": "string",
  "priority": "integer",
  "query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
  "restricted_roles": [],
  "state": {
    "groups": {
      "<any-key>": {
        "last_nodata_ts": "integer",
        "last_notified_ts": "integer",
        "last_resolved_ts": "integer",
        "last_triggered_ts": "integer",
        "name": "string",
        "status": "string"
      }
    }
  },
  "tags": [],
  "type": "query alert"
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Monitor Not Found error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Path parameters
export monitor_id="CHANGE_ME"
# Curl command curl -X PUT "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor/${monitor_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF {} EOF
"""
Edit a monitor returns "OK" response
"""

from os import environ
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
from datadog_api_client.v1.model.monitor_update_request import MonitorUpdateRequest

# there is a valid "monitor" in the system
MONITOR_ID = environ["MONITOR_ID"]
MONITOR_NAME = environ["MONITOR_NAME"]

body = MonitorUpdateRequest(
    name="My monitor-updated",
    options=MonitorOptions(
        evaluation_delay=None,
        new_group_delay=600,
        new_host_delay=None,
        renotify_interval=None,
        thresholds=MonitorThresholds(critical=2.0, warning=None),
        timeout_h=None,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.update_monitor(monitor_id=int(MONITOR_ID), body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Edit a monitor returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MonitorsAPI.new

# there is a valid "monitor" in the system
MONITOR_ID = ENV["MONITOR_ID"]
MONITOR_NAME = ENV["MONITOR_NAME"]

body = DatadogAPIClient::V1::MonitorUpdateRequest.new({
  name: "My monitor-updated",
  options: DatadogAPIClient::V1::MonitorOptions.new({
    evaluation_delay: nil,
    new_group_delay: 600,
    new_host_delay: nil,
    renotify_interval: nil,
    thresholds: DatadogAPIClient::V1::MonitorThresholds.new({
      critical: 2,
      warning: nil,
    }),
    timeout_h: nil,
  }),
})
p api_instance.update_monitor(MONITOR_ID.to_i, body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Edit a monitor returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.MonitorsApi(configuration);

// there is a valid "monitor" in the system
let MONITOR_ID = parseInt(process.env.MONITOR_ID as string);

let params: v1.MonitorsApiUpdateMonitorRequest = {
  body: {
    name: "My monitor-updated",
    options: {
      evaluationDelay: undefined,
      newGroupDelay: 600,
      newHostDelay: undefined,
      renotifyInterval: undefined,
      thresholds: {
        critical: 2,
        warning: undefined,
      },
      timeoutH: undefined,
    },
  },
  monitorId: MONITOR_ID,
};

apiInstance
  .updateMonitor(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Edit a monitor returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"strconv"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	// there is a valid "monitor" in the system
	MONITOR_ID, _ := strconv.ParseInt(os.Getenv("MONITOR_ID"), 10, 64)

	body := datadog.MonitorUpdateRequest{
		Name: datadog.PtrString("My monitor-updated"),
		Options: &datadog.MonitorOptions{
			EvaluationDelay:  *datadog.NewNullableInt64(nil),
			NewGroupDelay:    *datadog.NewNullableInt64(datadog.PtrInt64(600)),
			NewHostDelay:     *datadog.NewNullableInt64(nil),
			RenotifyInterval: *datadog.NewNullableInt64(nil),
			Thresholds: &datadog.MonitorThresholds{
				Critical: datadog.PtrFloat64(2),
				Warning:  *datadog.NewNullableFloat64(nil),
			},
			TimeoutH: *datadog.NewNullableInt64(nil),
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MonitorsApi.UpdateMonitor(ctx, MONITOR_ID, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.UpdateMonitor`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.UpdateMonitor`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Edit a monitor returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.MonitorsApi;
import com.datadog.api.v1.client.model.Monitor;
import com.datadog.api.v1.client.model.MonitorOptions;
import com.datadog.api.v1.client.model.MonitorThresholds;
import com.datadog.api.v1.client.model.MonitorUpdateRequest;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    MonitorsApi apiInstance = new MonitorsApi(defaultClient);

    // there is a valid "monitor" in the system
    Long MONITOR_ID = Long.parseLong(System.getenv("MONITOR_ID"));
    String MONITOR_NAME = System.getenv("MONITOR_NAME");

    MonitorUpdateRequest body =
        new MonitorUpdateRequest()
            .name("My monitor-updated")
            .options(
                new MonitorOptions()
                    .evaluationDelay(null)
                    .newGroupDelay(600L)
                    .newHostDelay(null)
                    .renotifyInterval(null)
                    .thresholds(new MonitorThresholds().critical(2.0).warning(null))
                    .timeoutH(null));

    try {
      Monitor result = apiInstance.updateMonitor(MONITOR_ID, body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#updateDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/monitor/{monitor_id}https://api.ddog-gov.com/api/v1/monitor/{monitor_id}https://api.datadoghq.com/api/v1/monitor/{monitor_id}https://api.us3.datadoghq.com/api/v1/monitor/{monitor_id}https://api.us5.datadoghq.com/api/v1/monitor/{monitor_id}

Overview

Get details about the specified monitor from your organization.

Arguments

Path Parameters

Name

Type

Description

monitor_id [required]

integer

The ID of the monitor

Query Strings

Name

Type

Description

group_states

string

When specified, shows additional information about the group states. Choose one or more from all, alert, warn, and no data.

Response

OK

Object describing a monitor.

Expand All

Field

Type

Description

created

date-time

Timestamp of the monitor creation.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

deleted

date-time

Whether or not the monitor is deleted. (Always null)

id

int64

ID of this monitor.

message

string

A message to include with notifications for this monitor.

modified

date-time

Last timestamp when the monitor was edited.

multi

boolean

Whether or not the monitor is broken down on different groups.

name

string

The monitor name.

options

object

List of options associated with your monitor.

aggregation

object

Type of aggregation performed in the monitor query.

group_by

string

Group to break down the monitor on.

metric

string

Metric name used in the monitor.

type

string

Metric type used in the monitor.

device_ids

[string]

DEPRECATED: IDs of the device the Synthetics monitor is running on.

enable_logs_sample

boolean

Whether or not to send a log sample when the log monitor triggers.

escalation_message

string

We recommend using the is_renotify, block in the original message instead. A message to include with a re-notification. Supports the @username notification we allow elsewhere. Not applicable if renotify_interval is None.

evaluation_delay

int64

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 evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.

groupby_simple_monitor

boolean

Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.

include_tags

boolean

A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.

Examples

  • If True, [Triggered on {host:h1}] Monitor Title
  • If False, [Triggered] Monitor Title

locked

boolean

Whether or not the monitor is locked (only editable by creator and admins).

min_failure_duration

int64

How long the test should be in failure before alerting (integer, number of seconds, max 7200).

min_location_failed

int64

The minimum number of locations in failure at the same time during at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration are part of the advanced alerting rules - integer, >= 1).

new_group_delay

int64

Time (in seconds) to skip evaluations for new groups.

For example, this option can be used to skip evaluations for new hosts while they initialize.

Must be a non negative integer.

new_host_delay

int64

DEPRECATED: 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.

Use new_group_delay instead.

no_data_timeframe

int64

The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.

notify_audit

boolean

A Boolean indicating whether tagged users is notified on changes to this monitor.

notify_no_data

boolean

A Boolean indicating whether this monitor notifies when data stops reporting.

renotify_interval

int64

The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.

renotify_occurrences

int64

The number of times re-notification messages should be sent on the current status at the provided re-notification interval.

renotify_statuses

[string]

The types of monitor statuses for which re-notification messages are sent.

require_full_window

boolean

A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to false for sparse metrics, otherwise some evaluations are skipped. Default is false.

silenced

object

DEPRECATED: Information about the downtime applied to the monitor.

<any-key>

int64

ID of the downtime applied to the monitor.

synthetics_check_id

string

DEPRECATED: ID of the corresponding Synthetic check.

threshold_windows

object

Alerting time window options.

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.

thresholds

object

List of the different monitor threshold available.

critical

double

The monitor CRITICAL threshold.

critical_recovery

double

The monitor CRITICAL recovery threshold.

ok

double

The monitor OK threshold.

unknown

double

The monitor UNKNOWN threshold.

warning

double

The monitor WARNING threshold.

warning_recovery

double

The monitor WARNING recovery threshold.

timeout_h

int64

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.

overall_state

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

priority

int64

Integer from 1 (high) to 5 (low) indicating alert severity.

query [required]

string

The monitor query.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API. Cannot be used with locked option.

state

object

Wrapper object with the different monitor states.

groups

object

Dictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.

<any-key>

object

Monitor state for a single group.

last_nodata_ts

int64

Latest timestamp the monitor was in NO_DATA state.

last_notified_ts

int64

Latest timestamp of the notification sent for this monitor group.

last_resolved_ts

int64

Latest timestamp the monitor group was resolved.

last_triggered_ts

int64

Latest timestamp the monitor group triggered.

name

string

The name of the monitor.

status

enum

The different states your monitor can be in. Allowed enum values: Alert,Ignored,No Data,OK,Skipped,Unknown,Warn

tags

[string]

Tags associated to your monitor.

type [required]

enum

The type of the monitor. For more information about type, see the monitor options docs. Allowed enum values: 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

{
  "created": "2019-09-19T10:00:00.000Z",
  "creator": {
    "email": "string",
    "handle": "string",
    "name": "string"
  },
  "deleted": "2019-09-19T10:00:00.000Z",
  "id": "integer",
  "message": "string",
  "modified": "2019-09-19T10:00:00.000Z",
  "multi": false,
  "name": "My monitor",
  "options": {
    "aggregation": {
      "group_by": "host",
      "metric": "metrics.name",
      "type": "count"
    },
    "device_ids": [],
    "enable_logs_sample": false,
    "escalation_message": "string",
    "evaluation_delay": "integer",
    "groupby_simple_monitor": false,
    "include_tags": false,
    "locked": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "new_group_delay": "integer",
    "new_host_delay": "integer",
    "no_data_timeframe": "integer",
    "notify_audit": false,
    "notify_no_data": false,
    "renotify_interval": "integer",
    "renotify_occurrences": "integer",
    "renotify_statuses": [],
    "require_full_window": false,
    "silenced": {
      "<any-key>": "integer"
    },
    "synthetics_check_id": "string",
    "threshold_windows": {
      "recovery_window": "string",
      "trigger_window": "string"
    },
    "thresholds": {
      "critical": "number",
      "critical_recovery": "number",
      "ok": "number",
      "unknown": "number",
      "warning": "number",
      "warning_recovery": "number"
    },
    "timeout_h": "integer"
  },
  "overall_state": "string",
  "priority": "integer",
  "query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
  "restricted_roles": [],
  "state": {
    "groups": {
      "<any-key>": {
        "last_nodata_ts": "integer",
        "last_notified_ts": "integer",
        "last_resolved_ts": "integer",
        "last_triggered_ts": "integer",
        "name": "string",
        "status": "string"
      }
    }
  },
  "tags": [],
  "type": "query alert"
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Monitor Not Found error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Path parameters
export monitor_id="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor/${monitor_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get a monitor's details returns "OK" response
"""

from os import environ
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi

# there is a valid "monitor" in the system
MONITOR_ID = environ["MONITOR_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.get_monitor(monitor_id=int(MONITOR_ID))

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get a monitor's details returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MonitorsAPI.new

# there is a valid "monitor" in the system
MONITOR_ID = ENV["MONITOR_ID"]
p api_instance.get_monitor(MONITOR_ID.to_i)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Get a monitors's details
dog.get_monitor(91_879, group_states: 'all')

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get a monitor's details returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.MonitorsApi(configuration);

// there is a valid "monitor" in the system
let MONITOR_ID = parseInt(process.env.MONITOR_ID as string);

let params: v1.MonitorsApiGetMonitorRequest = {
  monitorId: MONITOR_ID,
};

apiInstance
  .getMonitor(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get a monitor's details returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"strconv"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	// there is a valid "monitor" in the system
	MONITOR_ID, _ := strconv.ParseInt(os.Getenv("MONITOR_ID"), 10, 64)

	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MonitorsApi.GetMonitor(ctx, MONITOR_ID, *datadog.NewGetMonitorOptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.GetMonitor`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.GetMonitor`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get a monitor's details returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.MonitorsApi;
import com.datadog.api.v1.client.model.Monitor;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    MonitorsApi apiInstance = new MonitorsApi(defaultClient);

    // there is a valid "monitor" in the system
    Long MONITOR_ID = Long.parseLong(System.getenv("MONITOR_ID"));

    try {
      Monitor result = apiInstance.getMonitor(MONITOR_ID);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#updateDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Get a monitor's details
api.Monitor.get(2081, group_states='all')

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

DELETE https://api.datadoghq.eu/api/v1/monitor/{monitor_id}https://api.ddog-gov.com/api/v1/monitor/{monitor_id}https://api.datadoghq.com/api/v1/monitor/{monitor_id}https://api.us3.datadoghq.com/api/v1/monitor/{monitor_id}https://api.us5.datadoghq.com/api/v1/monitor/{monitor_id}

Overview

Delete the specified monitor

Arguments

Path Parameters

Name

Type

Description

monitor_id [required]

integer

The ID of the monitor.

Query Strings

Name

Type

Description

force

string

Delete the monitor even if it’s referenced by other resources (e.g. SLO, composite monitor).

Response

OK

Response from the delete monitor call.

Expand All

Field

Type

Description

deleted_monitor_id

int64

ID of the deleted monitor.

{
  "deleted_monitor_id": "integer"
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Item not found error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Path parameters
export monitor_id="CHANGE_ME"
# Curl command curl -X DELETE "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor/${monitor_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Delete a monitor returns "OK" response
"""

from os import environ
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi

# there is a valid "monitor" in the system
MONITOR_ID = environ["MONITOR_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.delete_monitor(monitor_id=int(MONITOR_ID))

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Delete a monitor returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MonitorsAPI.new

# there is a valid "monitor" in the system
MONITOR_ID = ENV["MONITOR_ID"]
p api_instance.delete_monitor(MONITOR_ID.to_i)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Delete a monitor
dog.delete_monitor(62_625)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Delete a monitor returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.MonitorsApi(configuration);

// there is a valid "monitor" in the system
let MONITOR_ID = parseInt(process.env.MONITOR_ID as string);

let params: v1.MonitorsApiDeleteMonitorRequest = {
  monitorId: MONITOR_ID,
};

apiInstance
  .deleteMonitor(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Delete a monitor returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"strconv"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	// there is a valid "monitor" in the system
	MONITOR_ID, _ := strconv.ParseInt(os.Getenv("MONITOR_ID"), 10, 64)

	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MonitorsApi.DeleteMonitor(ctx, MONITOR_ID, *datadog.NewDeleteMonitorOptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.DeleteMonitor`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.DeleteMonitor`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Delete a monitor returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.MonitorsApi;
import com.datadog.api.v1.client.model.DeletedMonitor;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    MonitorsApi apiInstance = new MonitorsApi(defaultClient);

    // there is a valid "monitor" in the system
    Long MONITOR_ID = Long.parseLong(System.getenv("MONITOR_ID"));

    try {
      DeletedMonitor result = apiInstance.deleteMonitor(MONITOR_ID);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#updateDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Delete a monitor
api.Monitor.delete(2081)

# Force delete a monitor to override warnings
api.Monitor.delete(2081, force=True)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

GET https://api.datadoghq.eu/api/v1/monitor/can_deletehttps://api.ddog-gov.com/api/v1/monitor/can_deletehttps://api.datadoghq.com/api/v1/monitor/can_deletehttps://api.us3.datadoghq.com/api/v1/monitor/can_deletehttps://api.us5.datadoghq.com/api/v1/monitor/can_delete

Overview

Check if the given monitors can be deleted.

Arguments

Query Strings

Name

Type

Description

monitor_ids [required]

array

The IDs of the monitor to check.

Response

OK

Response of monitor IDs that can or can’t be safely deleted.

Expand All

Field

Type

Description

data [required]

object

Wrapper object with the list of monitor IDs.

ok

[integer]

An array of of Monitor IDs that can be safely deleted.

errors

object

A mapping of Monitor ID to strings denoting where it's used.

<any-key>

[string]

Strings denoting where a monitor is used.

{
  "data": {
    "ok": []
  },
  "errors": {
    "<any-key>": []
  }
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Deletion conflict error

Response of monitor IDs that can or can’t be safely deleted.

Expand All

Field

Type

Description

data [required]

object

Wrapper object with the list of monitor IDs.

ok

[integer]

An array of of Monitor IDs that can be safely deleted.

errors

object

A mapping of Monitor ID to strings denoting where it's used.

<any-key>

[string]

Strings denoting where a monitor is used.

{
  "data": {
    "ok": []
  },
  "errors": {
    "<any-key>": []
  }
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Required query arguments
export monitor_ids="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor/can_delete?monitor_ids=${monitor_ids}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Check if a monitor can be deleted returns "OK" response
"""

from os import environ
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi

# there is a valid "monitor" in the system
MONITOR_ID = environ["MONITOR_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.check_can_delete_monitor(monitor_ids=["MONITOR_ID"])

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Check if a monitor can be deleted returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MonitorsAPI.new

# there is a valid "monitor" in the system
MONITOR_ID = ENV["MONITOR_ID"]
p api_instance.check_can_delete_monitor([
  MONITOR_ID.to_i,
])

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Check if you can delete the given monitors.
dog.can_delete_monitors([56838, 771060, 1000376])

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Check if a monitor can be deleted returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.MonitorsApi(configuration);

// there is a valid "monitor" in the system
let MONITOR_ID = parseInt(process.env.MONITOR_ID as string);

let params: v1.MonitorsApiCheckCanDeleteMonitorRequest = {
  monitorIds: [MONITOR_ID],
};

apiInstance
  .checkCanDeleteMonitor(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Check if a monitor can be deleted returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"strconv"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	// there is a valid "monitor" in the system
	MONITOR_ID, _ := strconv.ParseInt(os.Getenv("MONITOR_ID"), 10, 64)

	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MonitorsApi.CheckCanDeleteMonitor(ctx, []int64{
		MONITOR_ID,
	})

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.CheckCanDeleteMonitor`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.CheckCanDeleteMonitor`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Check if a monitor can be deleted returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.MonitorsApi;
import com.datadog.api.v1.client.model.CheckCanDeleteMonitorResponse;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    MonitorsApi apiInstance = new MonitorsApi(defaultClient);

    // there is a valid "monitor" in the system
    Long MONITOR_ID = Long.parseLong(System.getenv("MONITOR_ID"));

    try {
      CheckCanDeleteMonitorResponse result =
          apiInstance.checkCanDeleteMonitor(
              new ArrayList<Long>() {
                {
                  add(MONITOR_ID);
                }
              });
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#updateDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Check if you can delete the given monitors.
api.Monitor.can_delete(monitor_ids=[56838, 771060, 1000376])

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"