이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

Overview

HTTP tests allow you to send HTTP requests to your applications’ API endpoints to verify responses and defined conditions, such as overall response time, expected status code, header, or body content.

HTTP tests can run from both managed and private locations depending on your preference for running the test from outside or inside your network. HTTP tests can run on a schedule, on-demand, or directly within your CI/CD pipelines.

Configuration

After choosing to create an HTTP test, define your test’s request.

Define request

  1. Choose the HTTP Method and specify the URL to query. Available methods are: GET, POST, PATCH, PUT, HEAD, DELETE, and OPTIONS. Both http and https URLs are supported.

    See Advanced options for more options.
  2. Name your HTTP test.

  3. Add env Tags as well as any other tag to your HTTP test. You can then use these tags to filter through your Synthetic tests on the Synthetic Monitoring & Continuous Testing page.

    Define HTTP request

Click Test URL to try out the request configuration. A response preview is displayed on the right side of your screen.

Advanced options

  • HTTP version: Select HTTP/1.1 only, HTTP/2 only, or HTTP/2 fallback to HTTP/1.1.
  • Follow redirects: Select to have your HTTP test follow up to ten redirects when performing the request.
  • Ignore server certificate error: Select to have your HTTP test go on with connection even if there are errors when validating the SSL certificate.
  • Timeout: Specify the amount of time in seconds before the test times out.
  • Request headers: Define headers to add to your HTTP request. You can also override the default headers (for example, the user-agent header).
  • Cookies: Define cookies to add to your HTTP request. Set multiple cookies using the format <COOKIE_NAME1>=<COOKIE_VALUE1>; <COOKIE_NAME2>=<COOKIE_VALUE2>.
  • Client Certificate: Authenticate through mTLS by uploading your client certificate (.crt) and the associated private key (.key) in PEM format. You can use the openssl library to convert your certificates. For example, convert a PKCS12 certificate to PEM formatted private keys and certificates.

    openssl pkcs12 -in <CERT>.p12 -out <CERT_KEY>.key -nodes -nocerts
    openssl pkcs12 -in <CERT>.p12 -out <CERT>.cert -nokeys
    
  • HTTP Basic Auth: Add HTTP basic authentication credentials.

  • Digest Auth: Add Digest authentication credentials.

  • NTLM: Add NTLM authentication credentials. Support both NTLMv2 and NTLMv1.

  • AWS Signature v4: Enter your Access Key ID and Secret Access Key. Datadog generates the signature for your request. This option uses the basic implementation of SigV4. Specific signatures such as Amazon S3 are not supported out-of-the box.
    For “Single Chunk” transfer requests to Amazon S3 buckets, add x-amz-content-sha256 containing the sha256-encoded body of the request as a header (for an empty body: x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855).

  • OAuth 2.0: Choose between granting client credentials or a resource owner password and enter an access token URL. Depending on your selection, enter a client ID and secret, or a username and password. From the dropdown menu, select an option to either send the API token as a basic authentication header, or send the client credentials in the body. Optionally, you can provide additional information such as the audience, resource, and scope (as well as the client ID and secret, if you selected Resource Owner Password).

  • Encode parameters: Add the name and value of query parameters that require encoding.
  • Body type: Select the type of the request body (application/json, application/octet-stream, application/x-www-form-urlencoded, multipart/form-data, text/html, text/plain, text/xml, GraphQL, or None) you want to add to your HTTP request.
  • Request body: Add the content of your HTTP request body.
    • The request body is limited to a maximum size of 50 kilobytes for application/json, application/x-www-form-urlencoded, text/html, text/plain, text/xml, GraphQL.
    • The request body is limited to one file of 3 megabytes for application/octet-stream.
    • The request body is limited to three files of 3 megabytes each for multipart/form-data.
  • Proxy URL: Specify the URL of the proxy the HTTP request should go through (http://<YOUR_USER>:<YOUR_PWD>@<YOUR_IP>:<YOUR_PORT>).
  • Proxy header: Add headers to include in the HTTP request to the proxy.
  • Do not save response body: Select this option to prevent response body from being saved at runtime. This can be helpful to ensure no sensitive data gets featured in your test results. Use mindfully as it can make failures troubleshooting more difficult. For more security recommendations, see Synthetic Monitoring Security.

Define variables for your HTTP API tests with JavaScript:

<div class="shortcode-wrapper shortcode-img expand"><figure class="text-center"><a href="https://datadog-docs.imgix.net/images/synthetics/api_tests/http_javascript.66fe410698cb2c156ee0634db040393e.png?fit=max&amp;auto=format" class="pop" data-bs-toggle="modal" data-bs-target="#popupImageModal"><picture class=""  style="width:90%;"  >
        <img 
            class="img-fluid" 
            srcset="https://datadog-docs.imgix.net/images/synthetics/api_tests/http_javascript.66fe410698cb2c156ee0634db040393e.png?auto=format" 
            style="width:90%;"  alt="Define HTTP API test with Javascript"  />
      </picture></a></figure>
</div>

Define assertions

Assertions define what an expected test result is. After you click Test URL, basic assertions on response time, status code, and header content-type are added based on the response that was obtained. You must define at least one assertion for your test to monitor.

TypeOperatorValue type
bodycontains, does not contain, is, is not,
matches, does not match,
jsonpath, xpath
String
Regex
headercontains, does not contain, is, is not,
matches, does not match
String
Regex
response timeis less thanInteger (ms)
status codeis, is not,
matches, does not match
Integer
Regex

HTTP tests can decompress bodies with the following content-encoding headers: br, deflate, gzip, and identity.

You can create up to 20 assertions per API test by clicking New Assertion or by clicking directly on the response preview:

Define assertions for your HTTP test to succeed or fail on

To perform OR logic in an assertion, use the matches regex comparator to define a regex with multiple expected values like (200|302). For example, you may want your HTTP test to succeed when a server must respond with a 200 or 302 status code. The status code assertion succeeds if the status code is 200 or 302. You can also add OR logic on a body or header assertion.

If a test does not contain an assertion on the response body, the body payload drops and returns an associated response time for the request within the timeout limit set by the Synthetics Worker.

If a test contains an assertion on the response body and the timeout limit is reached, an Assertions on the body/response cannot be run beyond this limit error appears.

Select locations

Select the Locations to run your HTTP test from. HTTP tests can run from both managed and private locations depending on your preference for running the test from outside or inside your network.

Datadog’s out-of-the-box managed locations allow you to test public-facing websites and endpoints from regions where your customers are located.

AmericasAPACEMEA
Canada Central (AWS)Hong Kong (AWS)Cape Town (AWS)
Northern California (AWS)Mumbai (AWS)Frankfurt (AWS)
Northern Virginia (AWS)Seoul (AWS)Ireland (AWS)
Ohio (AWS)Singapore (AWS)London (AWS)
Oregon (AWS)Sydney (AWS)Paris (AWS)
São Paulo (AWS)Tokyo (AWS)Stockholm (AWS)
Virginia (Azure)Osaka (AWS)Milan (AWS)
Jakarta (AWS)Bahrain (AWS)

The Datadog for Government site (US1-FED) uses the following managed location:

Americas
US-West

Specify test frequency

HTTP tests can run:

  • On a schedule to ensure your most important endpoints are always accessible to your users. Select the frequency at which you want Datadog to run your HTTP test.
  • Within your CI/CD pipelines to start shipping without fearing faulty code might impact your customers’ experience.
  • On-demand to run your tests whenever makes the most sense for your team.

경고 조건 정의

알림 조건을 설정해 테스트 실패 시 알림을 트리거할 상황을 정의하세요.

알림 규칙

알림 조건을 An alert is triggered if any assertion fails for X minutes from any n of N locations으로 설정하면 해당 두 조건이 참인 경우에만 알림이 트리거됩니다.

  • 최소 하나의 위치가 지난 X분 동안 실패 상태여야 합니다(최소 하나의 어서션 실패).
  • 지난 X분 중 어느 시점 최소 n개의 위치가 실패해야 합니다.

빠른 재시도

결과가 테스트 실패인 경우 Y밀리초 후 X회 재시도를 트리거할 수 있습니다. 알림 중요도에 맞게 재시도 간격을 커스터마이즈할 수 있습니다.

위치 가동 시간은 각 평가 기준으로 계산됩니다(평가 전 마지막 테스트 결과가 상승 또는 감소했는지 여부). 총 가동 시간은 설정된 알림 조건에 따라 계산됩니다. 전송된 알림은 총 가동 시간을 기준으로 합니다.

테스트 모니터 설정

알림은 이전에 정의된 알림 조건 기준 테스트에서 전송됩니다. 이 섹션을 통해 팀에 메시지를 전달하는 방법과 해당 메시지의 내용을 정의하세요.

  1. 모니터 설정 방법과 유사하게 알림을 받아야 하는 사용자 및/또는 서비스를 선택합니다. @notification를 메시지에 추가하거나, 드롭다운 메뉴를 사용해 팀 구성원과 연결된 통합을 검색할 수 있습니다.

  2. 테스트에 대한 알림 메시지를 입력합니다. 이 필드는 표준 마크다운 형식을 허용하며 다음 조건부 변수를 지원합니다.

    조건 변수설명
    {{ #is_alert }}테스트가 알림을 전송하면 표시합니다.
    {{ ^is_alert }}테스트가 알림을 전송하지 않으면 표시합니다.
    {{ #is_recovery }}테스트에서 알림을 복원하면 표시합니다.
    {{ ^is_recovery }}테스트가 일림을 복원하지 않으면 표시합니다.
    {{ #is_renotify }}모니터가 알림을 다시 알리면 표시합니다.
    {{ ^is_renotify }}모니터가 알림을 다시 알리면 표시합니다.
    {{ #is_priority }}모니터가 우선순위(P1~P5)와 일치하면 표시합니다.
    {{ ^is_priority }}모니터가 우선순위와 일치하지 않으면 표시됩니다(P1~P5).
  3. 테스트 실패 시 테스트에서 알림 메시지를 재전송할 빈도를 지정합니다. 테스트 실패에 대해 알림이 다시 전송되는 것을 방지하려면 옵션을 Never renotify if the monitor has not been resolved로 남겨둡니다.

  4. 생성을 클릭해 테스트 설정 및 모니터를 저장합니다.

자세한 정보는 신서틱(Synthetic) 테스트 모니터를 참조하세요.

One-click

API test creation suggests endpoints from the API Catalog and existing API tests to prefill your test form with relevant options. Use existing Datadog data sources such as APM traces, API Catalog endpoints discovery, and existing similar Synthetic tests created by users.

Start typing in the API test URL input to get endpoint suggestions or similar tests in Synthetic Monitoring:

HTTP API Test showing a GET search for an existing API test

Then, select a suggestion to prefill your test configuration (request options and headers, authentication, and variables):

Select

Variables

Create local variables

To create a local variable, click Create a Local Variable. 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. Once you have defined the variable string, click Add Variable.

Use variables

You can use the global variables defined on the Settings page in the URL, advanced options, and assertions of your HTTP tests.

To display your list of variables, type {{ in your desired field:

Test failure

A test is considered FAILED if it does not satisfy one or more assertions or if the request prematurely failed. In some cases, the test can fail without testing the assertions against the endpoint.

The most common errors include the following:

CONNREFUSED
No connection could be made because the target machine actively refused it.
CONNRESET
The connection was abruptly closed by the remote server. Possible causes include the web server encountering an error or crashing while responding, or loss of connectivity of the web server.
DNS
DNS entry not found for the test URL. Possible causes include misconfigured test URL or the wrong configuration of your DNS entries.
Error performing HTTP/2 request
The request could not be performed. See the dedicated error page for more information.
INVALID_REQUEST
The configuration of the test is invalid (for example, a typo in the URL).
SSL
The SSL connection couldn’t be performed. See the dedicated error page for more information.
TIMEOUT
The request couldn’t be completed in a reasonable time. Two types of TIMEOUT can happen:
  • TIMEOUT: The request couldn't be completed in a reasonable time. indicates that the request duration hit the test defined timeout (default is set to 60s). For each request only the completed stages for the request are displayed in the network waterfall. For example, in the case of Total response time only being displayed, the timeout occurred during the DNS resolution.
  • TIMEOUT: Overall test execution couldn't be completed in a reasonable time. indicates that the test duration (request + assertions) hits the maximum duration (60.5s).
MALFORMED_RESPONSE
The remote server responded with a payload that does not comply with HTTP specifications.

Permissions

By default, only users with the Datadog Admin and Datadog Standard roles can create, edit, and delete Synthetic HTTP tests. To get create, edit, and delete access to Synthetic HTTP tests, upgrade your user to one of those two default roles.

If you are using the custom role feature, add your user to any custom role that includes synthetics_read and synthetics_write permissions.

Restrict access

Access restriction is available for customers using custom roles on their accounts.

You can restrict access to an HTTP test based on the roles in your organization. When creating an HTTP test, choose which roles (in addition to your user) can read and write your test.

Set permissions for your test

Further Reading