Create a monitor
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.
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.
-
The alert configuration. The default is
{ status: { enabled: true }, tls: { enabled: true } }
. -
Specify whether the monitor is enabled.
Default value is
true
. -
Key-value pairs of labels to associate with the monitor. Labels can be used for filtering and grouping monitors.
-
The location to deploy the monitor. Monitors can be deployed in multiple locations so that you can detect differences in availability and response times across those locations. To list available locations you can:
- Run the
elastic-synthetics locations
command with the deployment's Kibana URL. - Go to Synthetics > Management and click Create monitor. Locations will be listed in Locations.
- Run the
-
The monitor name.
-
The namespace field should be lowercase and not contain spaces. The namespace must not include any of the following characters:
*
,\
,/
,?
,"
,<
,>
,|
, whitespace,,
,#
,:
, or-
.Default value is
default
. -
The monitor parameters.
-
The private locations to which the monitors will be deployed. These private locations refer to locations hosted and managed by you, whereas
locations
are hosted by Elastic. You can specify a private location using the location's name. To list available private locations you can:- Run the
elastic-synthetics locations
command with the deployment's Kibana URL. - Go to Synthetics > Settings and click Private locationsr. Private locations will be listed in the table.
You can provide
locations
orprivate_locations
or both. At least one is required. - Run the
-
Turn retesting for when a monitor fails on or off. By default, monitors are automatically retested if the monitor goes from "up" to "down". If the result of the retest is also "down", an error will be created and if configured, an alert sent. The monitor will then resume running according to the defined schedule. Using
retest_on_failure
can reduce noise related to transient problems.Default value is
true
. -
The monitor's schedule in minutes. Supported values are
1
,3
,5
,10
,15
,30
,60
,120
, and240
. The default value is3
minutes for HTTP, TCP, and ICMP monitors. The default value is10
minutes for Browser monitors. -
The APM service name.
-
An array of tags.
-
The monitor timeout in seconds. The monitor will fail if it doesn't complete within this time.
Default value is
16
. -
Ignore HTTPS errors.
Default value is
false
. -
The inline script.
-
Playwright options.
-
The screenshot option.
Values are
on
,off
, oronly-on-failure
. Default value ison
. -
Synthetics agent CLI arguments.
-
The monitor type.
Value is
browser
.
-
The alert configuration. The default is
{ status: { enabled: true }, tls: { enabled: true } }
. -
Specify whether the monitor is enabled.
Default value is
true
. -
Key-value pairs of labels to associate with the monitor. Labels can be used for filtering and grouping monitors.
-
The location to deploy the monitor. Monitors can be deployed in multiple locations so that you can detect differences in availability and response times across those locations. To list available locations you can:
- Run the
elastic-synthetics locations
command with the deployment's Kibana URL. - Go to Synthetics > Management and click Create monitor. Locations will be listed in Locations.
- Run the
-
The monitor name.
-
The namespace field should be lowercase and not contain spaces. The namespace must not include any of the following characters:
*
,\
,/
,?
,"
,<
,>
,|
, whitespace,,
,#
,:
, or-
.Default value is
default
. -
The monitor parameters.
-
The private locations to which the monitors will be deployed. These private locations refer to locations hosted and managed by you, whereas
locations
are hosted by Elastic. You can specify a private location using the location's name. To list available private locations you can:- Run the
elastic-synthetics locations
command with the deployment's Kibana URL. - Go to Synthetics > Settings and click Private locationsr. Private locations will be listed in the table.
You can provide
locations
orprivate_locations
or both. At least one is required. - Run the
-
Turn retesting for when a monitor fails on or off. By default, monitors are automatically retested if the monitor goes from "up" to "down". If the result of the retest is also "down", an error will be created and if configured, an alert sent. The monitor will then resume running according to the defined schedule. Using
retest_on_failure
can reduce noise related to transient problems.Default value is
true
. -
The monitor's schedule in minutes. Supported values are
1
,3
,5
,10
,15
,30
,60
,120
, and240
. The default value is3
minutes for HTTP, TCP, and ICMP monitors. The default value is10
minutes for Browser monitors. -
The APM service name.
-
An array of tags.
-
The monitor timeout in seconds. The monitor will fail if it doesn't complete within this time.
Default value is
16
. -
The check request settings.
-
If
true
, ping using the ipv4 protocol.Default value is
true
. -
If
true
, ping using the ipv6 protocol.Default value is
true
. -
The maximum number of redirects to follow.
Default value is
0
. -
The mode of the monitor. If it is
all
, the monitor pings all resolvable IPs for a hostname. If it isany
, the monitor pings only one IP address for a hostname. If you're using a DNS-load balancer and want to ping every IP address for the specified hostname, you should useall
.Values are
all
orany
. Default value isany
. -
The password for authenticating with the server. The credentials are passed with the request.
-
Additional headers to send to proxies during CONNECT requests.
-
The URL of the proxy to use for this monitor.
-
Controls the indexing of the HTTP response body contents to the
http.response.body.contents field
. -
The TLS/SSL connection settings for use with the HTTPS endpoint. If you don't specify settings, the system defaults are used.
-
The monitor type.
Value is
http
. -
The URL to monitor.
-
The username for authenticating with the server. The credentials are passed with the request.
-
The alert configuration. The default is
{ status: { enabled: true }, tls: { enabled: true } }
. -
Specify whether the monitor is enabled.
Default value is
true
. -
Key-value pairs of labels to associate with the monitor. Labels can be used for filtering and grouping monitors.
-
The location to deploy the monitor. Monitors can be deployed in multiple locations so that you can detect differences in availability and response times across those locations. To list available locations you can:
- Run the
elastic-synthetics locations
command with the deployment's Kibana URL. - Go to Synthetics > Management and click Create monitor. Locations will be listed in Locations.
- Run the
-
The monitor name.
-
The namespace field should be lowercase and not contain spaces. The namespace must not include any of the following characters:
*
,\
,/
,?
,"
,<
,>
,|
, whitespace,,
,#
,:
, or-
.Default value is
default
. -
The monitor parameters.
-
The private locations to which the monitors will be deployed. These private locations refer to locations hosted and managed by you, whereas
locations
are hosted by Elastic. You can specify a private location using the location's name. To list available private locations you can:- Run the
elastic-synthetics locations
command with the deployment's Kibana URL. - Go to Synthetics > Settings and click Private locationsr. Private locations will be listed in the table.
You can provide
locations
orprivate_locations
or both. At least one is required. - Run the
-
Turn retesting for when a monitor fails on or off. By default, monitors are automatically retested if the monitor goes from "up" to "down". If the result of the retest is also "down", an error will be created and if configured, an alert sent. The monitor will then resume running according to the defined schedule. Using
retest_on_failure
can reduce noise related to transient problems.Default value is
true
. -
The monitor's schedule in minutes. Supported values are
1
,3
,5
,10
,15
,30
,60
,120
, and240
. The default value is3
minutes for HTTP, TCP, and ICMP monitors. The default value is10
minutes for Browser monitors. -
The APM service name.
-
An array of tags.
-
The monitor timeout in seconds. The monitor will fail if it doesn't complete within this time.
Default value is
16
. -
The host to ping.
-
The monitor type.
Value is
icmp
. -
The wait time in seconds.
Default value is
1
.
-
The alert configuration. The default is
{ status: { enabled: true }, tls: { enabled: true } }
. -
Specify whether the monitor is enabled.
Default value is
true
. -
Key-value pairs of labels to associate with the monitor. Labels can be used for filtering and grouping monitors.
-
The location to deploy the monitor. Monitors can be deployed in multiple locations so that you can detect differences in availability and response times across those locations. To list available locations you can:
- Run the
elastic-synthetics locations
command with the deployment's Kibana URL. - Go to Synthetics > Management and click Create monitor. Locations will be listed in Locations.
- Run the
-
The monitor name.
-
The namespace field should be lowercase and not contain spaces. The namespace must not include any of the following characters:
*
,\
,/
,?
,"
,<
,>
,|
, whitespace,,
,#
,:
, or-
.Default value is
default
. -
The monitor parameters.
-
The private locations to which the monitors will be deployed. These private locations refer to locations hosted and managed by you, whereas
locations
are hosted by Elastic. You can specify a private location using the location's name. To list available private locations you can:- Run the
elastic-synthetics locations
command with the deployment's Kibana URL. - Go to Synthetics > Settings and click Private locationsr. Private locations will be listed in the table.
You can provide
locations
orprivate_locations
or both. At least one is required. - Run the
-
Turn retesting for when a monitor fails on or off. By default, monitors are automatically retested if the monitor goes from "up" to "down". If the result of the retest is also "down", an error will be created and if configured, an alert sent. The monitor will then resume running according to the defined schedule. Using
retest_on_failure
can reduce noise related to transient problems.Default value is
true
. -
The monitor's schedule in minutes. Supported values are
1
,3
,5
,10
,15
,30
,60
,120
, and240
. The default value is3
minutes for HTTP, TCP, and ICMP monitors. The default value is10
minutes for Browser monitors. -
The APM service name.
-
An array of tags.
-
The monitor timeout in seconds. The monitor will fail if it doesn't complete within this time.
Default value is
16
. -
The host to monitor; it can be an IP address or a hostname. The host can include the port using a colon, for example "example.com:9200".
-
The URL of the SOCKS5 proxy to use when connecting to the server. The value must be a URL with a scheme of
socks5://
. If the SOCKS5 proxy server requires client authentication, then a username and password can be embedded in the URL. When using a proxy, hostnames are resolved on the proxy server instead of on the client. You can change this behavior by setting theproxy_use_local_resolver
option. -
Specify that hostnames are resolved locally instead of being resolved on the proxy server. If
false
, name resolution occurs on the proxy server.Default value is
false
. -
The TLS/SSL connection settings for use with the HTTPS endpoint. If you don't specify settings, the system defaults are used.
-
The monitor type.
Value is
tcp
.
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"]
}