When setting up a new Synthetic Monitoring API test, use snippets to automatically fill in basic auth, performance, and regions, rather than selecting these options manually. The following snippets are available:
Basic Auth: Automatically test your APIs using pre-populated basic auth headers, JavaScript, bearer token, and API/app key auth variables.
Performance: Automatically configure a test with the shortest frequency (one minute), perform a gRPC health check, and test for overall response time latency with a breakdown of network timing.
Regions: Automatically test your API endpoint against a location in each of the three primary geographic regions (AMER, APAC and EMEA).
高度なオプション
HTTP version (HTTP バージョン): HTTP/1.1 only、HTTP/2 only、または HTTP/2 fallback to HTTP/1.1 を選択します。
CDN (Akamai、CloudFront、Fastly など) を経由するエンドポイントの場合は、HTTP バージョンをデフォルトの HTTP/2 with fallback to HTTP/1.1 ではなく、HTTP/2 only または HTTP/1.1 only に設定してください。HTTP バージョンのサポートはプローブによって異なり、デフォルト設定では次のような HTTP エラー が断続的に発生する可能性があります。
OAuth 2.0: クライアント資格情報またはリソース所有者パスワードのどちらを付与するかを選択し、アクセストークンの URL を入力します。選択内容に応じて、クライアント ID とシークレット、またはユーザー名とパスワードを入力します。ドロップダウンメニューから、API トークンを基本認証ヘッダーとして送信するか、クライアント資格情報を本文で送信するかを選択します。オプションで、オーディエンス、リソース、スコープなどの追加情報を提供できます ([Resource Owner Password] (リソース所有者パスワード) を選択した場合は、クライアント ID とシークレットも指定できます)。
JWT: 認証用に署名付き JWT ベアラートークンを生成します。署名アルゴリズム (HS256、RS256、または ES256) を選択し、署名キーを指定します。HS256 の場合はテキスト形式のシークレットを入力し、RS256 および ES256 の場合は PEM 形式の秘密鍵をアップロードします。両方とも {{ GLOBAL_VARIABLE }} references. Enter payload claims as a JSON object; claims can be strings, numbers, Booleans, arrays, or nested objects. The iat (issued at) and exp (expiration) claims are auto-added by default. If you include iat or exp in the payload JSON, those values take precedence over the auto-generated ones. Optionally, set the expiration window in seconds (default: 3600), add custom JWT header fields such as kid or x5t, and customize the token prefix in the Authorization header (default: Bearer)。
Do not save response body (レスポンスボディを保存しない): このオプションを選択すると、実行時にレスポンスボディは保存されず、失敗した JavaScript アサーションのエラーメッセージが切り捨てられます。これにより、テスト結果に機密データが表示されるのを防ぐことができますが、障害のトラブルシューティングが難しくなる可能性があります。セキュリティに関する完全な推奨事項については、「Synthetic Monitoring のデータセキュリティ」を参照してください。
JavaScript を使用して HTTP API テスト用の変数を定義します。
Windows プライベートロケーションでは API テストの JavaScript 機能はサポートされていません。
Windows プライベートロケーションでは API テストの JavaScript 機能はサポートされていません。
失敗した JavaScript アサーションのエラーメッセージに機密データが含まれる可能性がある場合は、[Advanced Options] (高度なオプション) > [Privacy] (プライバシー) で [Do not save response body] (レスポンスボディを保存しない) を有効にします。これにより、アサーションのエラーメッセージが切り捨てられます。
dd.assert() の使用
従来のアサーション構文には dd.assert() を使用します。
たとえば、status.code フィールドの許容値をアサートするには、次のように指定します。
constresponse=JSON.parse(dd.response.body);// Assert that the status code is 200, 210, 320, or 330
dd.assert.include([200,210,320,330],response.status.code);
Datadog’s out-of-the-box managed locations allow you to test public-facing websites and endpoints from regions where your customers are located.
AWS:
Americas
Asia Pacific
EMEA
Canada Central
Hong Kong
Bahrain
Northern California
Jakarta
Cape Town
Northern Virginia
Mumbai
Frankfurt
Ohio
Osaka
Ireland
Oregon
Seoul
London
São Paulo
Singapore
Milan
Sydney
Paris
Tokyo
Stockholm
GCP:
Americas
Asia Pacific
EMEA
Dallas
Tokyo
Frankfurt
Los Angeles
Oregon
Virginia
Azure:
Region
Location
Americas
Virginia
The Datadog for Government site (US1-FED) uses the following managed location:
Region
Location
Americas
US-West
テストの頻度を指定する
HTTP テストは次の頻度で実行できます。
On a schedule (スケジュール): 最も重要なエンドポイントにユーザーが常にアクセスできるようにします。Datadog で HTTP テストを実行する頻度を選択します。
Within your CI/CD pipelines (CI/CD パイプライン内): 欠陥のあるコードがカスタマーエクスペリエンスに影響を与えることを心配せずに、デプロイを開始できます。
[* On-demand] (オンデマンド): チームにとって最適なタイミングでテストを実行します。
Define alert conditions
Set alert conditions to determine the circumstances under which you want a test to fail and trigger an alert.
Alerting rule
When you set the alert conditions to: An alert is triggered if any assertion fails for X minutes from any n of N locations, an alert is triggered only if these two conditions are true:
At least one location was in failure (at least one assertion failed) during the last X minutes;
At one moment during the last X minutes, at least n locations were in failure.
Fast retry
Your test can trigger retries X times after Y ms in case of a failed test result. Customize the retry interval to suit your alerting sensibility.
Location uptime is computed on a per-evaluation basis (whether the last test result before evaluation was up or down). The total uptime is computed based on the configured alert conditions. Notifications sent are based on the total uptime.
A notification is sent by your test based on the alerting conditions previously defined. Use this section to define how and what to message your team.
Similar to how you configure monitors, select users and/or services that should receive notifications either by adding an @notification to the message or by searching for team members and connected integrations with the dropdown menu.
Enter the notification message for your test or use pre-filled monitor messages. This field allows standard Markdown formatting and supports the following conditional variables:
Conditional Variable
Description
{{#is_alert}}
Show when the test alerts.
{{^is_alert}}
Show unless the test alerts.
{{#is_recovery}}
Show when the test recovers from alert.
{{^is_recovery}}
Show unless the test recovers from alert.
{{#is_renotify}}
Show when the monitor renotifies.
{{^is_renotify}}
Show unless the monitor renotifies.
{{#is_priority}}
Show when the monitor matches priority (P1 to P5).
{{^is_priority}}
Show unless the monitor matches priority (P1 to P5).
Notification messages include the message defined in this section and information about the failing locations. Pre-filled monitor messages are included in the message body section:
Specify how often you want your test to re-send the notification message in case of test failure. To prevent renotification on failing tests, check the option Stop re-notifying on X occurrences.
Click Save & Start Recording to save your test configuration and monitor.
To pause test execution during planned maintenance windows, select an existing Scheduled downtime in the Downtimes section. The test automatically pauses during the downtime’s scheduled time slots.
Note: You cannot create a new downtime from the test creation form. To create one, navigate to Settings > Downtimes.
ワンクリック
API テストの作成は、カタログ と既存の API テストからエンドポイントを提案し、関連するオプションをテストフォームに自動入力します。
既存の Datadog データソース (APM トレース、カタログで検出されたエンドポイント、ユーザーが作成した類似の Synthetic テストなど) を活用します。
API テストの URL に入力を開始すると、エンドポイントの候補や Synthetic Monitoring の類似テストが表示されます。
To create a local variable, click + All steps > Variables. You can select one of the following available builtins to add to your variable string:
{{ numeric(n) }}
Generates a numeric string with n digits.
{{ alphabetic(n) }}
Generates an alphabetic string with n letters.
{{ alphanumeric(n) }}
Generates an alphanumeric string with n characters.
{{ date(n unit, format) }}
Generates a date in one of Datadog’s accepted formats with a value corresponding to the UTC date the test is initiated at + or - n units.
{{ timestamp(n, unit) }}
Generates a timestamp in one of Datadog’s accepted units with a value corresponding to the UTC timestamp the test is initiated at +/- n units.
{{ uuid }}
Generates a version 4 universally unique identifier (UUID).
{{ public-id }}
Injects the Public ID of your test.
{{ result-id }}
Injects the Result ID of your test run.
To obfuscate local variable values in test results, select Hide and obfuscate variable value. After you have defined the variable string, click Add Variable.
Apply filters to variable values
When you reference a variable, you can transform its resolved value by appending a filter with a pipe (|). Use the syntax {{ VARIABLE_NAME | filter }} anywhere a variable is accepted, such as the URL, request body, headers, and assertions. The following filters are available:
{{ VARIABLE_NAME | urlEncode }}
URL-encodes the variable’s value. For example, hello world becomes hello%20world.
{{ VARIABLE_NAME | urlDecode }}
URL-decodes the variable’s value. For example, hello%20world becomes hello world.
{{ VARIABLE_NAME | base64Encode }}
Base64-encodes the variable’s value. For example, hello becomes aGVsbG8=.
{{ VARIABLE_NAME | base64Decode }}
Base64-decodes the variable’s value. For example, aGVsbG8= becomes hello.
Filters apply to both local and global variables. You can apply one filter per reference, and filter names are case-sensitive.