POST /api/synthetics/monitors

Spaces method and path for this operation:

post /s/{space_id}/api/synthetics/monitors

Refer to Spaces for more information.

Create a new monitor with the specified attributes. A monitor can be one of the following types: HTTP, TCP, ICMP, or Browser. The required and default fields may vary based on the monitor type. You must have all privileges for the Synthetics feature in the Observability section of the Kibana feature privileges.

application/json

Body object Required

The request body should contain the attributes of the monitor you want to create. The required and default fields differ depending on the monitor type.

One of:

Responses

  • 200 application/json

    A successful response. The response may include a warnings array when the monitor configuration has non-critical issues. For example, if a browser monitor specifies a timeout but has no private locations configured, a warning is returned indicating the timeout will have no effect.

    Hide response attribute Show response attribute object
    • warnings array[object]

      An optional array of warnings about the monitor configuration.

      Hide warnings attributes Show warnings attributes object
      • message string

        A human-readable warning message.

      • monitorId string

        The monitor ID associated with the warning.

      • publicLocationIds array[string]

        The public location IDs associated with the warning.

  • 400 application/json

    Bad request. For browser monitors, a 400 error is returned if the timeout is less than 30 seconds.

    Hide response attributes Show response attributes object
    • attributes object
      Hide attributes attribute Show attributes attribute object
      • details string
    • error string
    • message string
    • statusCode integer
POST /api/synthetics/monitors
curl \
 --request POST 'https://localhost:5601/api/synthetics/monitors' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '"{\n  \"type\": \"http\",\n  \"name\": \"Website Availability\",\n  \"url\": \"https://example.com\",\n  \"tags\": [\"website\", \"availability\"],\n  \"locations\": [\"united_kingdom\"]\n}"'
Request examples
Create an HTTP monitor to check a website's availability.
{
  "type": "http",
  "name": "Website Availability",
  "url": "https://example.com",
  "tags": ["website", "availability"],
  "locations": ["united_kingdom"]
}
Create a TCP monitor to monitor a server's availability.
{
  "type": "tcp",
  "name": "Server Availability",
  "host": "example.com",
  "private_locations": ["my_private_location"]
}
Create an ICMP monitor to perform ping checks.
{
  "type": "icmp",
  "name": "Ping Test",
  "host": "example.com",
  "locations": ["united_kingdom"]
}
Create a browser monitor to check a website.
{
  "type": "browser",
  "name": "Example journey",
  "inline_script": "step('Go to https://google.com.co', () => page.goto('https://www.google.com'))",
  "locations": ["united_kingdom"]
}
Response examples (200)
A response when a browser monitor specifies a timeout but has no private locations.
{
  "type": "browser",
  "name": "Example journey",
  "enabled": true,
  "warnings": [
    {
      "id": "monitor-id",
      "message": "For browser monitors, timeout is only supported on private locations. Browser monitor \"Example journey\" specifies a timeout and is running on public locations: \"public-1, public-2\". The timeout will have no effect on these locations.",
      "publicLocationIds": ["public-1", "public-2"]
    }
  ]
}
Response examples (400)
A 400 error when a browser monitor timeout is below 30 seconds.
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Browser Monitor timeout is invalid",
  "attributes": {
    "details": "Invalid timeout 20 seconds supplied. Minimum timeout for browser monitors is 30 seconds."
  }
}