For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/ja/api/latest/monitors/create-a-monitor.md. A documentation index is available at /llms.txt.
Language
Datadog site

モニターを作成する

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

概要

指定されたオプションを使用してモニターを作成します。

モニタータイプ

次から選択されたモニタータイプ:

  • anomaly: query alert
  • APM: query alert または trace-analytics alert
  • composite: composite
  • custom: service check
  • forecast: query alert
  • host: service check
  • integration: query alert または 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-v2 alert
  • event-v2: event-v2 alert
  • audit: audit alert
  • error-tracking: error-tracking alert
  • database-monitoring: database-monitoring alert
  • network-performance: network-performance alert
  • cloud cost: cost alert
  • network-path: network-path alert

注:

  • Synthetic モニターは、Synthetics API を通じて作成されます。詳細については、Synthetics API のドキュメントを参照してください。
  • ログモニターには、スコープなしの App Key が必要です。

クエリタイプ

メトリクスアラートクエリ

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

  • time_aggr: avg、sum、max、min、change、または pct_change
  • time_window: last_#m (モニタータイプに応じて # は 1〜10080)、last_#h (モニタータイプに応じて # は 1〜168)、last_1d、または last_1w
  • space_aggr: avg、sum、min、または max
  • tags: 1 つ以上のタグ (カンマ区切り)、または *
  • key: key:value タグ構文の 'key' 。グループ内の各タグに対して個別の警告を定義 (マルチアラート)
  • operator: <、<=、>、>=、==、または !=
  • #: しきい値を設定するために使用される整数または小数

数式クエリを使用するメトリクスモニターで動的しきい値を使用するには、# を threshold キーワードに置き換え、 (例: ...> threshold)、options.thresholds の critical_query を介してクエリとしてしきい値を提供します。 この機能はプレビュー版です。

_change_ または _pct_change_ 時間集計を使用している場合は、代わりに change_aggr(time_aggr(time_window), timeshift):space_aggr:metric{tags} [by {key}] operator # を使用します。

  • change_aggr change, pct_change
  • time_aggr: avg、sum、max、min 詳細はこちら
  • time_window: last\#m (モニタータイプに応じて 1〜2880)、last\#h (モニタータイプに応じて 1〜48)、または last_#d (1 または 2)
  • timeshift: #m_ago (5、10、15、または 30)、#h_ago (1、2、または 4)、または 1d_ago

これを使用し、次のクエリを使用して外れ値モニターを作成します。 avg(last_30m):outliers(avg:system.cpu.user{role:es-events-data} by {host}, 'dbscan', 7) > 0

サービスチェッククエリ

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

  • check: チェックの名前、例: datadog.agent.up
  • tags 1 つ以上の引用符で囲まれたタグ (カンマ区切り)、または "*"。例: .over(\"env:prod\", \"role:db\"); over は空白にできません。
  • count は、最大しきい値 (options で定義) 以上でなければなりません。100 に制限されています。 例えば、critical が 1、ok が 3、warn が 2 のステータスで通知するように指定した場合、count は少なくとも 3 でなければなりません。
  • チェックモニターには group を指定する必要があります。チェックごとのグループ化は、一部のサービスチェックについてはすでに明示的に知られています。 例えば、Postgres インテグレーションモニターはdb、host、port でタグ付けされ、ネットワークモニターは host、instance、url でタグ付けされます。詳細については、サービスチェック のドキュメントを参照してください。
イベントアラートクエリ

注: イベントアラートクエリは、イベント V2 アラートクエリに置き換えられました。詳細については、イベント移行ガイド を参照してください。

イベント V2 アラートクエリ

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

  • query 検索クエリ - ログ検索構文 に従います。
  • rollup_method 統計のロールアップメソッド - count、avg、cardinality をサポートします。
  • measure avg および cardinality の rollup_method の場合 - 使用するメジャーまたはファセット名を指定します。
  • time_window #m (1 から 2880 の間)、#h (1 から 48 の間)。
  • operator <, <=, >, >=, ==、または !=。
  • # しきい値を設定するために使用される整数または小数。
プロセスアラートクエリ

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

  • search プロセスをクエリするためのフリーテキスト検索文字列。 一致するプロセスは、Live Processes ページの結果と一致します。
  • tags 1 つ以上のタグ (カンマ区切り)
  • timeframe カウントをロールアップする期間。例: 10m、4h。サポートされている期間: s、m、h、d
  • operator <、<=、>、>=、==、または !=
  • # しきい値を設定するために使用する整数または小数
ログアラートクエリ

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

  • query 検索クエリ - ログ検索構文 に従います。
  • index_name 複数のインデックスを持つ組織の場合、リクエストを実行するログインデックス。
  • rollup_method 統計のロールアップメソッド - count、avg、cardinality をサポートします。
  • measure avg および cardinality の rollup_method の場合 - 使用するメジャーまたはファセット名を指定します。
  • time_window #m (1 から 2880 の間)、#h (1 から 48 の間)。
  • operator <, <=, >, >=, ==、または !=。
  • # しきい値を設定するために使用される整数または小数。
複合条件クエリ

例: 12345 && 67890(12345 と 67890 は複合条件ではないモニターの ID)

  • name [必須, デフォルト = 動的、クエリに基づく]: アラートの名前。
  • message [必須, デフォルト = 動的、クエリに基づく]: このモニターの通知に含めるメッセージ。 メール通知は、イベントと同じ '@username' 表記を使用して特定のユーザーに送信できます。
  • tags [任意, デフォルト = 空白のリスト]: モニターに関連付けるタグのリスト。 API 経由ですべてのモニターの詳細を取得する際は、monitor_tags 引数を使用してこれらのタグで結果をフィルタリングします。 これは API 経由でのみ利用可能であり、Datadog UI では表示や編集ができません。
SLO アラートクエリ

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

  • slo_id: アラートを設定する SLO の英数字の SLO ID。
  • time_window: アラート対象とする SLO ターゲットの時間枠。有効なオプション: 7d、30d、90d。
  • operator: >= または >
監査アラートクエリ

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

  • query 検索クエリ - ログ検索構文 に従います。
  • rollup_method 統計のロールアップメソッド - count、avg、cardinality をサポートします。
  • measure avg および cardinality の rollup_method の場合 - 使用するメジャーまたはファセット名を指定します。
  • time_window #m (1 から 2880 の間)、#h (1 から 48 の間)。
  • operator <, <=, >, >=, ==、または !=。
  • # しきい値を設定するために使用される整数または小数。
CI パイプラインアラートクエリ

例: ci-pipelines(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query 検索クエリ - ログ検索構文 に従います。
  • rollup_method: 統計のロールアップメソッド。count、avg、cardinality をサポートします。
  • measure avg および cardinality の rollup_method の場合 - 使用するメジャーまたはファセット名を指定します。
  • time_window #m (1 から 2880 の間)、#h (1 から 48 の間)。
  • operator <, <=, >, >=, ==、または !=。
  • # しきい値を設定するために使用される整数または小数。
CI テストアラートクエリ

例: ci-tests(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query 検索クエリ - ログ検索構文 に従います。
  • rollup_method: 統計のロールアップメソッド。count、avg、cardinality をサポートします。
  • measure avg および cardinality の rollup_method の場合 - 使用するメジャーまたはファセット名を指定します。
  • time_window #m (1 から 2880 の間)、#h (1 から 48 の間)。
  • operator <, <=, >, >=, ==、または !=。
  • # しきい値を設定するために使用される整数または小数。
Error Tracking アラートクエリ

「新しい問題」の例: error-tracking(query).source(issue_source).new().rollup(rollup_method[, measure]).by(group_by).last(time_window) operator # 「大きな影響がある問題」の例: error-tracking(query).source(issue_source).impact().rollup(rollup_method[, measure]).by(group_by).last(time_window) operator #

  • query 検索クエリ - ログ検索構文 に従います。
  • issue_source: 問題のソース - all、browser、mobile、backend をサポートします。省略した場合は all がデフォルトとなります。
  • rollup_method: 統計のロールアップメソッド。count、avg、cardinality をサポートします。省略した場合は count がデフォルトとなります。
  • measure avg および cardinality の rollup_method の場合 - 使用するメジャーまたはファセット名を指定します。
  • group by: グループ化する属性のカンマ区切りリスト。少なくとも issue.id を含める必要があります。
  • time_window #m (1 から 2880 の間)、#h (1 から 48 の間)。
  • operator <, <=, >, >=, ==、または !=。
  • # しきい値を設定するために使用される整数または小数。

Database Monitoring アラートクエリ

例: database-monitoring(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query 検索クエリ - ログ検索構文 に従います。
  • rollup_method: 統計のロールアップメソッド。count、avg、cardinality をサポートします。
  • measure avg および cardinality の rollup_method の場合 - 使用するメジャーまたはファセット名を指定します。
  • time_window #m (1 から 2880 の間)、#h (1 から 48 の間)。
  • operator <, <=, >, >=, ==、または !=。
  • # しきい値を設定するために使用される整数または小数。

ネットワークパフォーマンスアラートクエリ

例: network-performance(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query 検索クエリ - ログ検索構文 に従います。
  • rollup_method: 統計のロールアップメソッド。count、avg、cardinality をサポートします。
  • measure avg および cardinality の rollup_method の場合 - 使用するメジャーまたはファセット名を指定します。
  • time_window #m (1 から 2880 の間)、#h (1 から 48 の間)。
  • operator <, <=, >, >=, ==、または !=。
  • # しきい値を設定するために使用される整数または小数。

コストアラートクエリ

例: formula(query).timeframe_type(time_window).function(parameter) operator #

  • query 検索クエリ - ログ検索構文 に従います。
  • timeframe_type コストを評価するための期間タイプ - forecast の場合、current をサポートします - change、anomaly、threshold の場合、last をサポートします
  • time_window - 日次ロールアップをサポートします。例: 7d
  • function - [オプション。省略した場合は threshold モニターがデフォルト] change、anomaly、forecast をサポートします
  • parameter タイプのパラメータを指定します
    • change の場合:
      • relative、absolute をサポートします
      • [オプション] # をサポートします。ここで # はしきい値を設定するために使用される整数または小数です
    • anomaly の場合:
      • direction=both、direction=above、direction=below をサポートします
      • [オプション] threshold=# をサポートします。ここで # はしきい値を設定するために使用される整数または小数です
  • operator
    • threshold の場合、<、<=、>、>=、==、または != をサポートします
    • change の場合、>、< をサポートします
    • anomaly の場合、>= をサポートします
    • forecast の場合、> をサポートします
  • # しきい値を設定するために使用される整数または小数。

** Network Path アラートクエリ**

例: network-path(query).index(index_name).rollup(rollup_method[, measure]).last(time_window) operator #

  • query 検索クエリ - ログ検索構文 に従います。
  • index_name 監視対象のデータタイプ。netpath-path および netpath-hop をサポートします。
  • rollup_method: 統計のロールアップメソッド。count、avg、cardinality をサポートします。
  • measure avg および cardinality の rollup_method の場合 - 使用するメジャーまたはファセット名を指定します。
  • time_window #m (1 から 2880 の間)、#h (1 から 48 の間)。
  • operator <, <=, >, >=, ==、または !=。
  • # しきい値を設定するために使用される整数または小数。

This endpoint requires any of the following permissions:

  • monitors_write
  • monitors_draft_write

OAuth apps require one of the following authorization scopes to access this endpoint: monitors_write, monitors_draft_write.

リクエスト

Body Data (required)

モニターリクエストボディを作成します。

フィールド
タイプ
説明
assets
[object]

モニターを記述するオブジェクト。

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

応答

OK

Object describing a monitor.

フィールド
タイプ
説明
assets
[object]

The list of monitor assets tied to a monitor, which represents key links for users to take action on monitor alerts (for example, runbooks).

created
date-time

Timestamp of the monitor creation.

creator
object

Object describing the creator of the shared element.

deleted
date-time

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

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
id
int64

ID of this monitor.

matching_downtimes
[object]

A list of active v1 downtimes that match 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.

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

state
object

Wrapper object with the different monitor states.

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

コード例

Create a Cost 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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example Monitor",
  "type": "cost alert",
  "query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 5,
      "warning": 3
    },
    "variables": [
      {
        "data_source": "cloud_cost",
        "query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
        "name": "query1",
        "aggregator": "sum"
      }
    ],
    "include_tags": true
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example Monitor",
  "type": "cost alert",
  "query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 5,
      "warning": 3
    },
    "variables": [
      {
        "data_source": "cloud_cost",
        "query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
        "name": "query1",
        "aggregator": "sum"
      }
    ],
    "include_tags": true
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example Monitor",
  "type": "cost alert",
  "query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 5,
      "warning": 3
    },
    "variables": [
      {
        "data_source": "cloud_cost",
        "query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
        "name": "query1",
        "aggregator": "sum"
      }
    ],
    "include_tags": true
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example Monitor",
  "type": "cost alert",
  "query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 5,
      "warning": 3
    },
    "variables": [
      {
        "data_source": "cloud_cost",
        "query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
        "name": "query1",
        "aggregator": "sum"
      }
    ],
    "include_tags": true
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example Monitor",
  "type": "cost alert",
  "query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 5,
      "warning": 3
    },
    "variables": [
      {
        "data_source": "cloud_cost",
        "query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
        "name": "query1",
        "aggregator": "sum"
      }
    ],
    "include_tags": true
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example Monitor",
  "type": "cost alert",
  "query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 5,
      "warning": 3
    },
    "variables": [
      {
        "data_source": "cloud_cost",
        "query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
        "name": "query1",
        "aggregator": "sum"
      }
    ],
    "include_tags": true
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example Monitor",
  "type": "cost alert",
  "query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 5,
      "warning": 3
    },
    "variables": [
      {
        "data_source": "cloud_cost",
        "query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
        "name": "query1",
        "aggregator": "sum"
      }
    ],
    "include_tags": true
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example Monitor",
  "type": "cost alert",
  "query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 5,
      "warning": 3
    },
    "variables": [
      {
        "data_source": "cloud_cost",
        "query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
        "name": "query1",
        "aggregator": "sum"
      }
    ],
    "include_tags": true
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example Monitor",
  "type": "cost alert",
  "query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
  "message": "some message Notify: @hipchat-channel",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 5,
      "warning": 3
    },
    "variables": [
      {
        "data_source": "cloud_cost",
        "query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
        "name": "query1",
        "aggregator": "sum"
      }
    ],
    "include_tags": true
  }
}
EOF
Create a Data Jobs 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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-jobs alert",
  "query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
  "message": "Data jobs alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "options": {
    "thresholds": {
      "critical": 0
    },
    "variables": [
      {
        "name": "run_query",
        "jobs_query": "job_name:*",
        "job_type": "databricks.job",
        "query_dialect": "metric"
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-jobs alert",
  "query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
  "message": "Data jobs alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "options": {
    "thresholds": {
      "critical": 0
    },
    "variables": [
      {
        "name": "run_query",
        "jobs_query": "job_name:*",
        "job_type": "databricks.job",
        "query_dialect": "metric"
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-jobs alert",
  "query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
  "message": "Data jobs alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "options": {
    "thresholds": {
      "critical": 0
    },
    "variables": [
      {
        "name": "run_query",
        "jobs_query": "job_name:*",
        "job_type": "databricks.job",
        "query_dialect": "metric"
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-jobs alert",
  "query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
  "message": "Data jobs alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "options": {
    "thresholds": {
      "critical": 0
    },
    "variables": [
      {
        "name": "run_query",
        "jobs_query": "job_name:*",
        "job_type": "databricks.job",
        "query_dialect": "metric"
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-jobs alert",
  "query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
  "message": "Data jobs alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "options": {
    "thresholds": {
      "critical": 0
    },
    "variables": [
      {
        "name": "run_query",
        "jobs_query": "job_name:*",
        "job_type": "databricks.job",
        "query_dialect": "metric"
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-jobs alert",
  "query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
  "message": "Data jobs alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "options": {
    "thresholds": {
      "critical": 0
    },
    "variables": [
      {
        "name": "run_query",
        "jobs_query": "job_name:*",
        "job_type": "databricks.job",
        "query_dialect": "metric"
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-jobs alert",
  "query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
  "message": "Data jobs alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "options": {
    "thresholds": {
      "critical": 0
    },
    "variables": [
      {
        "name": "run_query",
        "jobs_query": "job_name:*",
        "job_type": "databricks.job",
        "query_dialect": "metric"
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-jobs alert",
  "query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
  "message": "Data jobs alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "options": {
    "thresholds": {
      "critical": 0
    },
    "variables": [
      {
        "name": "run_query",
        "jobs_query": "job_name:*",
        "job_type": "databricks.job",
        "query_dialect": "metric"
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-jobs alert",
  "query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
  "message": "Data jobs alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "options": {
    "thresholds": {
      "critical": 0
    },
    "variables": [
      {
        "name": "run_query",
        "jobs_query": "job_name:*",
        "job_type": "databricks.job",
        "query_dialect": "metric"
      }
    ]
  }
}
EOF
Create a Data Quality 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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-quality alert",
  "query": "formula(\"query1\").last(\"5m\") > 100",
  "message": "Data quality alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 100
    },
    "variables": [
      {
        "name": "query1",
        "data_source": "data_quality_metrics",
        "measure": "row_count",
        "filter": "search for column where `database:production AND table:users`",
        "group_by": [
          "entity_id"
        ]
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-quality alert",
  "query": "formula(\"query1\").last(\"5m\") > 100",
  "message": "Data quality alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 100
    },
    "variables": [
      {
        "name": "query1",
        "data_source": "data_quality_metrics",
        "measure": "row_count",
        "filter": "search for column where `database:production AND table:users`",
        "group_by": [
          "entity_id"
        ]
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-quality alert",
  "query": "formula(\"query1\").last(\"5m\") > 100",
  "message": "Data quality alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 100
    },
    "variables": [
      {
        "name": "query1",
        "data_source": "data_quality_metrics",
        "measure": "row_count",
        "filter": "search for column where `database:production AND table:users`",
        "group_by": [
          "entity_id"
        ]
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-quality alert",
  "query": "formula(\"query1\").last(\"5m\") > 100",
  "message": "Data quality alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 100
    },
    "variables": [
      {
        "name": "query1",
        "data_source": "data_quality_metrics",
        "measure": "row_count",
        "filter": "search for column where `database:production AND table:users`",
        "group_by": [
          "entity_id"
        ]
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-quality alert",
  "query": "formula(\"query1\").last(\"5m\") > 100",
  "message": "Data quality alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 100
    },
    "variables": [
      {
        "name": "query1",
        "data_source": "data_quality_metrics",
        "measure": "row_count",
        "filter": "search for column where `database:production AND table:users`",
        "group_by": [
          "entity_id"
        ]
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-quality alert",
  "query": "formula(\"query1\").last(\"5m\") > 100",
  "message": "Data quality alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 100
    },
    "variables": [
      {
        "name": "query1",
        "data_source": "data_quality_metrics",
        "measure": "row_count",
        "filter": "search for column where `database:production AND table:users`",
        "group_by": [
          "entity_id"
        ]
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-quality alert",
  "query": "formula(\"query1\").last(\"5m\") > 100",
  "message": "Data quality alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 100
    },
    "variables": [
      {
        "name": "query1",
        "data_source": "data_quality_metrics",
        "measure": "row_count",
        "filter": "search for column where `database:production AND table:users`",
        "group_by": [
          "entity_id"
        ]
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-quality alert",
  "query": "formula(\"query1\").last(\"5m\") > 100",
  "message": "Data quality alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 100
    },
    "variables": [
      {
        "name": "query1",
        "data_source": "data_quality_metrics",
        "measure": "row_count",
        "filter": "search for column where `database:production AND table:users`",
        "group_by": [
          "entity_id"
        ]
      }
    ]
  }
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "name": "Example-Monitor",
  "type": "data-quality alert",
  "query": "formula(\"query1\").last(\"5m\") > 100",
  "message": "Data quality alert triggered",
  "tags": [
    "test:examplemonitor",
    "env:ci"
  ],
  "priority": 3,
  "options": {
    "thresholds": {
      "critical": 100
    },
    "variables": [
      {
        "name": "query1",
        "data_source": "data_quality_metrics",
        "measure": "row_count",
        "filter": "search for column where `database:production AND table:users`",
        "group_by": [
          "entity_id"
        ]
      }
    ]
  }
}
EOF