For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/es/api/latest/monitors/validate-a-monitor.md. A documentation index is available at /llms.txt.
Language
Datadog site

Confirmar un monitor

POSThttps://api.datadoghq.com/api/v1/monitor/validatehttps://api.us3.datadoghq.com/api/v1/monitor/validatehttps://api.us5.datadoghq.com/api/v1/monitor/validatehttps://api.datadoghq.eu/api/v1/monitor/validatehttps://api.ap1.datadoghq.com/api/v1/monitor/validatehttps://api.ap2.datadoghq.com/api/v1/monitor/validatehttps://api.uk1.datadoghq.com/api/v1/monitor/validatehttps://api.ddog-gov.com/api/v1/monitor/validatehttps://api.us2.ddog-gov.com/api/v1/monitor/validate

Descripción general

Confirma el monitor proporcionado en la solicitud.

Nota: Los monitores de logs requieren una clave de aplicación sin contexto.

This endpoint requires the monitors_read permission.

OAuth apps require the monitors_read authorization scope to access this endpoint.

Solicitud

Body Data (required)

Monitorizar el objeto de la solicitud

Campo
Type
Descripción
assets
[object]

Objeto que describe un monitor.

draft_status
enum

Indicates whether the monitor is in a draft or published state.

draft: The monitor appears as Draft and does not send notifications. published: The monitor is active and evaluates conditions and notify as configured.

This field is in preview. The draft value is only available to customers with the feature enabled.

Default: published
Allowed enum values: draft, published
matching_downtimes
[object]

A list of active v1 downtimes that match this monitor.

message
string

A message to include with notifications for this monitor.

name
string

The monitor name.

options
object

List of options associated with your monitor.

priority
int64

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

query [required]
string

The monitor query.

restricted_roles
[string]

A list of unique role identifiers to define which roles are allowed to edit the monitor. The unique identifiers for all roles can be pulled from the Roles API and are located in the data.id field. Editing a monitor includes any updates to the monitor configuration, monitor deletion, and muting of the monitor for any amount of time. You can use the Restriction Policies API to manage write authorization for individual monitors by teams and users, in addition to roles.

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
Show 13 moreslo alert, event-v2 alert, audit alert, ci-pipelines alert, ci-tests alert, error-tracking alert, database-monitoring alert, network-performance alert, cost alert, data-quality alert, network-path alert, data-jobs alert, llm-observability alert

Respuesta

OK

No response body

Ejemplo de código

Validate a monitor returns "OK" response
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "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:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "notification_preset_name": "hide_handles",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "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:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "notification_preset_name": "hide_handles",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "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:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "notification_preset_name": "hide_handles",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "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:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "notification_preset_name": "hide_handles",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "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:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "notification_preset_name": "hide_handles",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "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:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "notification_preset_name": "hide_handles",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "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:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "notification_preset_name": "hide_handles",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "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:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "notification_preset_name": "hide_handles",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "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:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "notification_preset_name": "hide_handles",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
Validate a multi-alert monitor returns "OK" response
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "log alert",
  "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source,status\").last(\"5m\") > 2",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "group_retention_duration": "2d",
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_by": [
      "status"
    ],
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "log alert",
  "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source,status\").last(\"5m\") > 2",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "group_retention_duration": "2d",
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_by": [
      "status"
    ],
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "log alert",
  "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source,status\").last(\"5m\") > 2",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "group_retention_duration": "2d",
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_by": [
      "status"
    ],
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "log alert",
  "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source,status\").last(\"5m\") > 2",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "group_retention_duration": "2d",
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_by": [
      "status"
    ],
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "log alert",
  "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source,status\").last(\"5m\") > 2",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "group_retention_duration": "2d",
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_by": [
      "status"
    ],
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "log alert",
  "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source,status\").last(\"5m\") > 2",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "group_retention_duration": "2d",
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_by": [
      "status"
    ],
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "log alert",
  "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source,status\").last(\"5m\") > 2",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "group_retention_duration": "2d",
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_by": [
      "status"
    ],
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "log alert",
  "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source,status\").last(\"5m\") > 2",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "group_retention_duration": "2d",
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_by": [
      "status"
    ],
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/monitor/validate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "log alert",
  "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source,status\").last(\"5m\") > 2",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "enable_logs_sample": true,
    "escalation_message": "the situation has escalated",
    "evaluation_delay": 700,
    "group_retention_duration": "2d",
    "include_tags": true,
    "locked": false,
    "new_host_delay": 600,
    "no_data_timeframe": null,
    "notify_audit": false,
    "notify_by": [
      "status"
    ],
    "notify_no_data": false,
    "on_missing_data": "show_and_notify_no_data",
    "renotify_interval": 60,
    "require_full_window": true,
    "timeout_h": 24,
    "thresholds": {
      "critical": 2,
      "warning": 1
    }
  }
}
EOF