Spaces method and path for this operation:
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.
Responses
-
A successful response. The response may include a
warningsarray 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. -
Bad request. For browser monitors, a 400 error is returned if the timeout is less than 30 seconds.
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}"'
{
"type": "http",
"name": "Website Availability",
"url": "https://example.com",
"tags": ["website", "availability"],
"locations": ["united_kingdom"]
}
{
"type": "tcp",
"name": "Server Availability",
"host": "example.com",
"private_locations": ["my_private_location"]
}
{
"type": "icmp",
"name": "Ping Test",
"host": "example.com",
"locations": ["united_kingdom"]
}
{
"type": "browser",
"name": "Example journey",
"inline_script": "step('Go to https://google.com.co', () => page.goto('https://www.google.com'))",
"locations": ["united_kingdom"]
}
{
"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"]
}
]
}
{
"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."
}
}