SyntheticsClient¶
Client for the Kibana Synthetics API.
Synthetics periodically checks the status of your services and applications from lightweight (HTTP, TCP, ICMP) and browser monitors. This client manages monitors, global parameters, and private locations, and can trigger on-demand test runs.
All Synthetics resources are space-scoped: every method accepts an optional
space_id to target a specific space (None targets the default space
or the space the client is scoped to).
Note
Creating a monitor requires at least one location: either an Elastic
managed location (cloud) or a private location. Private locations are
backed by a Fleet agent policy (agent_policy_id).
- class kibana._sync.client.synthetics.SyntheticsClient(client, default_space_id=None, validate_spaces=True)[source]¶
Bases:
NamespaceClientClient for the Kibana Synthetics API.
Synthetics periodically checks the status of your services and applications from lightweight (HTTP, TCP, ICMP) and browser monitors. This client manages monitors, global parameters, and private locations, and can trigger on-demand test runs.
All Synthetics resources are space-scoped: every method accepts an optional
space_idto target a specific space (Nonetargets the default space or the space the client is scoped to).Note
Creating a monitor requires at least one location: either an Elastic managed location (cloud) or a private location. Private locations are backed by a Fleet agent policy (
agent_policy_id).Example
>>> from kibana import Kibana >>> client = Kibana("http://localhost:5601", api_key="...") >>> >>> # Create a private location, then an HTTP monitor using it >>> loc = client.synthetics.create_private_location( ... label="My private location", ... agent_policy_id="abc-123", ... ) >>> monitor = client.synthetics.create_monitor( ... type="http", ... name="My monitor", ... url="https://example.com", ... private_locations=[loc.body["id"]], ... ) >>> client.synthetics.delete_monitor(id=monitor.body["id"])
Private Locations
from kibana import Kibana client = Kibana("http://localhost:5601", api_key="your_api_key") # Create a private location backed by a Fleet agent policy loc = client.synthetics.create_private_location( label="My private location", agent_policy_id="abc-123", ) location_id = loc.body["id"] # List private locations locations = client.synthetics.get_private_locations()
Monitors
# Create an HTTP monitor running from the private location monitor = client.synthetics.create_monitor( type="http", name="My monitor", url="https://example.com", private_locations=[location_id], schedule={"number": "5", "unit": "m"}, tags=["production"], ) monitor_id = monitor.body["id"] # List monitors with filters monitors = client.synthetics.get_monitors( monitor_types="http", tags="production" ) for m in monitors.body["monitors"]: print(m["id"], m["name"]) # Update a monitor (partial update) client.synthetics.update_monitor( id=monitor_id, enabled=False, ) # Trigger an on-demand test run test = client.synthetics.test_monitor(monitor_id=monitor_id) # Delete the monitor client.synthetics.delete_monitor(id=monitor_id)
Global Parameters
Global parameters can be referenced from monitor configurations (e.g.
${my_param}):# Create a parameter param = client.synthetics.create_param( key="base_url", value="https://example.com", ) # List parameters params = client.synthetics.get_params() # Bulk delete parameters client.synthetics.bulk_delete_params(ids=[param.body["id"]])
- __init__(client, default_space_id=None, validate_spaces=True)[source]¶
Initialize the SyntheticsClient.
- Parameters:
Example
>>> synthetics_client = SyntheticsClient(kibana_client)
- get_monitors(*, filter=None, locations=None, monitor_types=None, page=None, per_page=None, projects=None, query=None, schedules=None, sort_field=None, sort_order=None, status=None, tags=None, use_logical_and_for=None, space_id=None, validate_spaces=None)[source]¶
Get monitors.
Get a paginated list of synthetics monitors, optionally filtered by type, location, tags, project, schedule or status.
- Parameters:
filter (str | None) – Additional filtering criteria (KQL-style filter string).
locations (str | list[str] | None) – The location IDs to filter by.
monitor_types (str | list[str] | None) – The monitor types to filter by (
http,tcp,icmp,browser).page (int | None) – The page number for paginated results.
per_page (int | None) – The number of monitors to return per page. Sent to the server as
perPage(the documentedper_pagename is rejected by Kibana 9.4.3).projects (str | list[str] | None) – The project IDs to filter by.
query (str | None) – A free-text query string.
schedules (str | list[str] | None) – The schedules (in minutes) to filter by.
sort_field (str | None) – The field to sort by. Kibana 9.4.3 accepts
enabled,status,updated_at,name.keyword,tags.keyword,project_id.keyword,type.keyword,schedule.keywordandjourney_id(the documentedname/createdAt/updatedAtvalues are rejected).sort_order (str | None) – The sort order:
ascordesc.status (str | list[str] | None) – The monitor status to filter by (
up,down).use_logical_and_for (str | list[str] | None) – Fields (
tags,locations) that should be combined with logical AND instead of OR.space_id (str | None) – Optional space ID to list monitors from.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
monitors(list of monitor objects),page,perPage,total,absoluteTotalandsyncErrors.- Raises:
BadRequestError – If a query parameter is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> response = client.synthetics.get_monitors( ... monitor_types="http", per_page=10 ... ) >>> for monitor in response.body["monitors"]: ... print(monitor["name"])
- get_monitor(*, id, space_id=None, validate_spaces=None)[source]¶
Get a monitor.
Get a synthetics monitor by config ID.
- Parameters:
- Returns:
ObjectApiResponse with the full monitor object (
id,name,type,locations,schedule,enabled, type-specific fields such asurlorhost, and audit metadata).- Raises:
NotFoundError – If no monitor exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> monitor = client.synthetics.get_monitor(id="d4ba9d2f-...") >>> print(monitor.body["name"], monitor.body["type"])
- create_monitor(*, type, name, url=None, host=None, inline_script=None, locations=None, private_locations=None, schedule=None, enabled=None, tags=None, alert=None, labels=None, namespace=None, params=None, retest_on_failure=None, service_name=None, timeout=None, fields=None, space_id=None, validate_spaces=None)[source]¶
Create a monitor.
Create a synthetics monitor of type
http,tcp,icmporbrowser. The required type-specific field differs per type:urlfor HTTP monitors,hostfor TCP and ICMP monitors, andinline_scriptfor browser monitors. At least one location is required, either Elastic managed (locations) or private (private_locations).- Parameters:
type (str) – The monitor type:
http,tcp,icmporbrowser.name (str) – The monitor’s name.
url (str | None) – The URL to monitor (required for
httpmonitors).host (str | None) – The host to ping or connect to (required for
icmpandtcpmonitors; may include the port, e.g."example.com:443", for TCP).inline_script (str | None) – The inline playwright script to run (required for
browsermonitors).locations (list[str] | None) – Elastic managed locations the monitor runs from.
private_locations (list[str] | None) – Private location IDs or labels the monitor runs from.
schedule (dict[str, Any] | None) – The monitor’s schedule in minutes, for example
{"number": "5", "unit": "m"}.enabled (bool | None) – Whether the monitor is enabled (default
Trueon the server).alert (dict[str, Any] | None) – Alert configuration, for example
{"status": {"enabled": True}, "tls": {"enabled": True}}.labels (dict[str, str] | None) – Custom key-value label pairs to add to the monitor.
namespace (str | None) – The data-stream namespace (defaults to the space name).
params (dict[str, Any] | None) – Monitor variables available to the monitor’s checks.
retest_on_failure (bool | None) – Whether the monitor is retested on failure.
service_name (str | None) – The APM service name to associate with the monitor (sent as
service.name).timeout (int | str | None) – Time in seconds before a check is considered failed.
fields (dict[str, Any] | None) – Additional type-specific fields merged into the request body verbatim (for example
{"max_redirects": 3},{"ssl.verification_mode": "none"},{"check": {"request": {"method": "POST"}}}).space_id (str | None) – Optional space ID to create the monitor in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the created monitor, including its generated
id/config_idand the resolved locations.- Raises:
BadRequestError – If the monitor definition is invalid or no location was provided.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> monitor = client.synthetics.create_monitor( ... type="http", ... name="Example HTTP monitor", ... url="https://example.com", ... private_locations=["my-private-location-id"], ... schedule={"number": "10", "unit": "m"}, ... tags=["example"], ... ) >>> print(monitor.body["id"])
- update_monitor(*, id, type=None, name=None, url=None, host=None, inline_script=None, locations=None, private_locations=None, schedule=None, enabled=None, tags=None, alert=None, labels=None, namespace=None, params=None, retest_on_failure=None, service_name=None, timeout=None, fields=None, space_id=None, validate_spaces=None)[source]¶
Update a monitor.
Update a synthetics monitor with a partial set of attributes; fields that are not provided keep their current values. The spec documents
typeas required in the request body, but Kibana 9.4.3 accepts partial updates without it.- Parameters:
id (str) – The config ID of the monitor to update.
type (str | None) – The monitor type (
http,tcp,icmporbrowser). The type of an existing monitor cannot be changed.name (str | None) – The monitor’s name.
url (str | None) – The URL to monitor (
httpmonitors).host (str | None) – The host to ping or connect to (
icmp/tcpmonitors).inline_script (str | None) – The inline playwright script (
browsermonitors).locations (list[str] | None) – Elastic managed locations the monitor runs from.
private_locations (list[str] | None) – Private location IDs or labels the monitor runs from.
schedule (dict[str, Any] | None) – The monitor’s schedule, e.g.
{"number": "5", "unit": "m"}.enabled (bool | None) – Whether the monitor is enabled.
labels (dict[str, str] | None) – Custom key-value label pairs.
namespace (str | None) – The data-stream namespace.
retest_on_failure (bool | None) – Whether the monitor is retested on failure.
service_name (str | None) – The APM service name (sent as
service.name).timeout (int | str | None) – Time in seconds before a check is considered failed.
fields (dict[str, Any] | None) – Additional type-specific fields merged into the request body verbatim.
space_id (str | None) – Optional space ID the monitor lives in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the updated monitor object.
- Raises:
NotFoundError – If no monitor exists with the given ID.
BadRequestError – If the update payload is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> updated = client.synthetics.update_monitor( ... id="d4ba9d2f-...", ... name="Renamed monitor", ... tags=["updated"], ... ) >>> print(updated.body["name"]) Renamed monitor
- delete_monitor(*, id, space_id=None, validate_spaces=None)[source]¶
Delete a monitor.
Delete a synthetics monitor by config ID.
- Parameters:
- Returns:
ApiResponse with a list of deletion results, for example
[{"id": "...", "deleted": true}].- Raises:
NotFoundError – If no monitor exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> result = client.synthetics.delete_monitor(id="d4ba9d2f-...") >>> print(result.body[0]["deleted"]) True
- bulk_delete_monitors(*, ids, space_id=None, validate_spaces=None)[source]¶
Delete monitors.
Delete multiple synthetics monitors by their config IDs in a single request.
- Parameters:
- Returns:
ObjectApiResponse with a
resultlist; each entry containsid,deletedand, for monitors that could not be deleted, anerrormessage.- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> result = client.synthetics.bulk_delete_monitors( ... ids=["id-1", "id-2"] ... ) >>> for item in result.body["result"]: ... print(item["id"], item["deleted"])
- test_monitor(*, monitor_id, space_id=None, validate_spaces=None)[source]¶
Trigger an on-demand test run for a monitor.
Trigger a one-off test run for an existing monitor without waiting for its schedule. The monitor must have at least one location with a running agent for the test to actually execute. Generally available since 9.2.0.
- Parameters:
- Returns:
ObjectApiResponse with the
testRunIdof the triggered run.- Raises:
NotFoundError – If no monitor exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> run = client.synthetics.test_monitor(monitor_id="d4ba9d2f-...") >>> print(run.body["testRunId"])
- get_params(*, space_id=None, validate_spaces=None)[source]¶
Get parameters.
Get all synthetics global parameters visible in the space. Parameter values are redacted unless the user has the proper read privileges.
- Parameters:
- Returns:
ApiResponse with a list of parameter objects (
id,key,description,tags,namespaces).- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> response = client.synthetics.get_params() >>> for param in response.body: ... print(param["key"])
- get_param(*, id, space_id=None, validate_spaces=None)[source]¶
Get a parameter.
Get a synthetics global parameter by ID.
- Parameters:
- Returns:
ObjectApiResponse with the parameter (
id,key,description,tags,namespaces).- Raises:
NotFoundError – If no parameter exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> param = client.synthetics.get_param(id="a1b2c3") >>> print(param.body["key"])
- create_param(*, key, value, description=None, tags=None, share_across_spaces=None, space_id=None, validate_spaces=None)[source]¶
Add a parameter.
Create a single synthetics global parameter that can be referenced by monitors.
- Parameters:
key (str) – The key of the parameter.
value (str) – The value associated with the parameter.
description (str | None) – A description of the parameter.
tags (list[str] | None) – An array of tags to categorize the parameter.
share_across_spaces (bool | None) – Whether the parameter should be shared across spaces.
space_id (str | None) – Optional space ID to create the parameter in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the created parameter (
id,key,description,tags,namespaces).- Raises:
BadRequestError – If the parameter definition is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> param = client.synthetics.create_param( ... key="my-api-token", ... value="s3cret", ... description="Token used by browser monitors", ... ) >>> print(param.body["id"])
- bulk_create_params(*, parameters, space_id=None, validate_spaces=None)[source]¶
Add multiple parameters.
Create several synthetics global parameters in a single request. Each entry must contain at least
keyandvalueand may also containdescription,tagsandshare_across_spaces.- Parameters:
- Returns:
ApiResponse with the list of created parameters (
id,key,namespaces).- Raises:
BadRequestError – If a parameter definition is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> created = client.synthetics.bulk_create_params( ... parameters=[ ... {"key": "username", "value": "admin"}, ... {"key": "password", "value": "changeme"}, ... ] ... ) >>> print(len(created.body)) 2
- update_param(*, id, key=None, value=None, description=None, tags=None, space_id=None, validate_spaces=None)[source]¶
Update a parameter.
Update a synthetics global parameter. Only the provided fields are changed.
Note
Kibana 9.4.3 applies a new
valuebut echoes the previously stored value in the response body (thevaluefield is encrypted at rest and is not re-read after the write). A subsequent request reflects the new value.- Parameters:
id (str) – The ID of the parameter to update.
key (str | None) – The new key of the parameter.
value (str | None) – The new value associated with the parameter.
description (str | None) – The new description of the parameter.
tags (list[str] | None) – An array of updated tags to categorize the parameter.
space_id (str | None) – Optional space ID the parameter lives in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the updated parameter.
- Raises:
NotFoundError – If no parameter exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> updated = client.synthetics.update_param( ... id="a1b2c3", description="Rotated 2026-07" ... ) >>> print(updated.body["description"]) Rotated 2026-07
- delete_param(*, id, space_id=None, validate_spaces=None)[source]¶
Delete a parameter.
Delete a synthetics global parameter by ID.
- Parameters:
- Returns:
ApiResponse with a list of deletion results, for example
[{"id": "...", "deleted": true}].- Raises:
NotFoundError – If no parameter exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> result = client.synthetics.delete_param(id="a1b2c3") >>> print(result.body[0]["deleted"]) True
- bulk_delete_params(*, ids, space_id=None, validate_spaces=None)[source]¶
Delete parameters.
Delete multiple synthetics global parameters by ID in a single request.
- Parameters:
- Returns:
ApiResponse with a list of deletion results, for example
[{"id": "...", "deleted": true}].- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> result = client.synthetics.bulk_delete_params( ... ids=["id-1", "id-2"] ... ) >>> print([item["deleted"] for item in result.body]) [True, True]
- get_private_locations(*, space_id=None, validate_spaces=None)[source]¶
Get private locations.
Get all synthetics private locations visible in the space.
- Parameters:
- Returns:
ApiResponse with a list of private location objects (
id,label,agentPolicyId,isInvalid,tags,geo,spaces).- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> response = client.synthetics.get_private_locations() >>> for location in response.body: ... print(location["label"], location["id"])
- get_private_location(*, id, space_id=None, validate_spaces=None)[source]¶
Get a private location.
Get a synthetics private location by ID or label.
- Parameters:
- Returns:
ObjectApiResponse with the private location (
id,label,agentPolicyId,isInvalid,tags,geo,spaces).- Raises:
NotFoundError – If no private location exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> location = client.synthetics.get_private_location( ... id="e3134290-..." ... ) >>> print(location.body["label"])
- create_private_location(*, label, agent_policy_id, tags=None, geo=None, spaces=None, space_id=None, validate_spaces=None)[source]¶
Create a private location.
Create a synthetics private location backed by a Fleet agent policy. Monitors assigned to the location run from Elastic Agents enrolled in that policy.
- Parameters:
label (str) – A label for the private location.
agent_policy_id (str) – The ID of the Fleet agent policy associated with the private location.
tags (list[str] | None) – An array of tags to categorize the private location.
geo (dict[str, float] | None) – Geographic coordinates (WGS84) for the location, e.g.
{"lat": 40.4, "lon": -3.7}.spaces (list[str] | None) – Space IDs where the private location is available. If not provided, the private location is available in all spaces.
space_id (str | None) – Optional space ID to create the private location in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the created private location (
id,label,agentPolicyId,isServiceManaged,isInvalid,tags,geo,spaces).- Raises:
BadRequestError – If the definition is invalid, the agent policy does not exist, or the agent policy is already used by another private location.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> location = client.synthetics.create_private_location( ... label="Madrid DC", ... agent_policy_id="abc-123", ... geo={"lat": 40.4, "lon": -3.7}, ... ) >>> print(location.body["id"])
- update_private_location(*, id, label, space_id=None, validate_spaces=None)[source]¶
Update a private location.
Update the label of a synthetics private location. The label is the only editable attribute.
- Parameters:
- Returns:
ObjectApiResponse with the updated private location.
- Raises:
NotFoundError – If no private location exists with the given ID.
BadRequestError – If the label is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> updated = client.synthetics.update_private_location( ... id="e3134290-...", label="Madrid DC (rack 2)" ... ) >>> print(updated.body["label"]) Madrid DC (rack 2)
- delete_private_location(*, id, space_id=None, validate_spaces=None)[source]¶
Delete a private location.
Delete a synthetics private location by ID. A location that still has monitors assigned to it cannot be deleted; delete or reassign the monitors first.
- Parameters:
- Returns:
ObjectApiResponse with an empty body on success.
- Raises:
NotFoundError – If no private location exists with the given ID.
BadRequestError – If monitors are still assigned to the location.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> client.synthetics.delete_private_location(id="e3134290-...")
AsyncSyntheticsClient¶
Asynchronous version of the SyntheticsClient for use with async/await syntax.
- class kibana._async.client.synthetics.AsyncSyntheticsClient(client, default_space_id=None, validate_spaces=True)[source]¶
Bases:
AsyncNamespaceClientAsync client for the Kibana Synthetics API.
Synthetics periodically checks the status of your services and applications from lightweight (HTTP, TCP, ICMP) and browser monitors. This client manages monitors, global parameters, and private locations, and can trigger on-demand test runs.
All Synthetics resources are space-scoped: every method accepts an optional
space_idto target a specific space (Nonetargets the default space or the space the client is scoped to).Note
Creating a monitor requires at least one location: either an Elastic managed location (cloud) or a private location. Private locations are backed by a Fleet agent policy (
agent_policy_id).Example
>>> from kibana import AsyncKibana >>> client = AsyncKibana("http://localhost:5601", api_key="...") >>> >>> # Create a private location, then an HTTP monitor using it >>> loc = await client.synthetics.create_private_location( ... label="My private location", ... agent_policy_id="abc-123", ... ) >>> monitor = await client.synthetics.create_monitor( ... type="http", ... name="My monitor", ... url="https://example.com", ... private_locations=[loc.body["id"]], ... ) >>> await client.synthetics.delete_monitor(id=monitor.body["id"])
Usage
The AsyncSyntheticsClient provides the same methods as SyntheticsClient but all methods are async and must be awaited:
from kibana import AsyncKibana import asyncio async def main(): async with AsyncKibana("http://localhost:5601") as client: # Create a monitor (async) monitor = await client.synthetics.create_monitor( type="http", name="Async monitor", url="https://example.com", private_locations=["private-location-id"], ) # List monitors (async) monitors = await client.synthetics.get_monitors() # Delete (async) await client.synthetics.delete_monitor(id=monitor.body["id"]) asyncio.run(main())
- __init__(client, default_space_id=None, validate_spaces=True)[source]¶
Initialize the AsyncSyntheticsClient.
- Parameters:
client (AsyncKibana) – The parent AsyncKibana client instance to delegate requests to.
default_space_id (str | None) – Optional default space ID for all operations.
validate_spaces (bool) – Whether to validate space existence before space-scoped operations (default: True).
Example
>>> synthetics_client = AsyncSyntheticsClient(kibana_client)
- async get_monitors(*, filter=None, locations=None, monitor_types=None, page=None, per_page=None, projects=None, query=None, schedules=None, sort_field=None, sort_order=None, status=None, tags=None, use_logical_and_for=None, space_id=None, validate_spaces=None)[source]¶
Get monitors.
Get a paginated list of synthetics monitors, optionally filtered by type, location, tags, project, schedule or status.
- Parameters:
filter (str | None) – Additional filtering criteria (KQL-style filter string).
locations (str | list[str] | None) – The location IDs to filter by.
monitor_types (str | list[str] | None) – The monitor types to filter by (
http,tcp,icmp,browser).page (int | None) – The page number for paginated results.
per_page (int | None) – The number of monitors to return per page. Sent to the server as
perPage(the documentedper_pagename is rejected by Kibana 9.4.3).projects (str | list[str] | None) – The project IDs to filter by.
query (str | None) – A free-text query string.
schedules (str | list[str] | None) – The schedules (in minutes) to filter by.
sort_field (str | None) – The field to sort by. Kibana 9.4.3 accepts
enabled,status,updated_at,name.keyword,tags.keyword,project_id.keyword,type.keyword,schedule.keywordandjourney_id(the documentedname/createdAt/updatedAtvalues are rejected).sort_order (str | None) – The sort order:
ascordesc.status (str | list[str] | None) – The monitor status to filter by (
up,down).use_logical_and_for (str | list[str] | None) – Fields (
tags,locations) that should be combined with logical AND instead of OR.space_id (str | None) – Optional space ID to list monitors from.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
monitors(list of monitor objects),page,perPage,total,absoluteTotalandsyncErrors.- Raises:
BadRequestError – If a query parameter is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> response = await client.synthetics.get_monitors( ... monitor_types="http", per_page=10 ... ) >>> for monitor in response.body["monitors"]: ... print(monitor["name"])
- async get_monitor(*, id, space_id=None, validate_spaces=None)[source]¶
Get a monitor.
Get a synthetics monitor by config ID.
- Parameters:
- Returns:
ObjectApiResponse with the full monitor object (
id,name,type,locations,schedule,enabled, type-specific fields such asurlorhost, and audit metadata).- Raises:
NotFoundError – If no monitor exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> monitor = await client.synthetics.get_monitor(id="d4ba9d2f-...") >>> print(monitor.body["name"], monitor.body["type"])
- async create_monitor(*, type, name, url=None, host=None, inline_script=None, locations=None, private_locations=None, schedule=None, enabled=None, tags=None, alert=None, labels=None, namespace=None, params=None, retest_on_failure=None, service_name=None, timeout=None, fields=None, space_id=None, validate_spaces=None)[source]¶
Create a monitor.
Create a synthetics monitor of type
http,tcp,icmporbrowser. The required type-specific field differs per type:urlfor HTTP monitors,hostfor TCP and ICMP monitors, andinline_scriptfor browser monitors. At least one location is required, either Elastic managed (locations) or private (private_locations).- Parameters:
type (str) – The monitor type:
http,tcp,icmporbrowser.name (str) – The monitor’s name.
url (str | None) – The URL to monitor (required for
httpmonitors).host (str | None) – The host to ping or connect to (required for
icmpandtcpmonitors; may include the port, e.g."example.com:443", for TCP).inline_script (str | None) – The inline playwright script to run (required for
browsermonitors).locations (list[str] | None) – Elastic managed locations the monitor runs from.
private_locations (list[str] | None) – Private location IDs or labels the monitor runs from.
schedule (dict[str, Any] | None) – The monitor’s schedule in minutes, for example
{"number": "5", "unit": "m"}.enabled (bool | None) – Whether the monitor is enabled (default
Trueon the server).alert (dict[str, Any] | None) – Alert configuration, for example
{"status": {"enabled": True}, "tls": {"enabled": True}}.labels (dict[str, str] | None) – Custom key-value label pairs to add to the monitor.
namespace (str | None) – The data-stream namespace (defaults to the space name).
params (dict[str, Any] | None) – Monitor variables available to the monitor’s checks.
retest_on_failure (bool | None) – Whether the monitor is retested on failure.
service_name (str | None) – The APM service name to associate with the monitor (sent as
service.name).timeout (int | str | None) – Time in seconds before a check is considered failed.
fields (dict[str, Any] | None) – Additional type-specific fields merged into the request body verbatim (for example
{"max_redirects": 3},{"ssl.verification_mode": "none"},{"check": {"request": {"method": "POST"}}}).space_id (str | None) – Optional space ID to create the monitor in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the created monitor, including its generated
id/config_idand the resolved locations.- Raises:
BadRequestError – If the monitor definition is invalid or no location was provided.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> monitor = await client.synthetics.create_monitor( ... type="http", ... name="Example HTTP monitor", ... url="https://example.com", ... private_locations=["my-private-location-id"], ... schedule={"number": "10", "unit": "m"}, ... tags=["example"], ... ) >>> print(monitor.body["id"])
- async update_monitor(*, id, type=None, name=None, url=None, host=None, inline_script=None, locations=None, private_locations=None, schedule=None, enabled=None, tags=None, alert=None, labels=None, namespace=None, params=None, retest_on_failure=None, service_name=None, timeout=None, fields=None, space_id=None, validate_spaces=None)[source]¶
Update a monitor.
Update a synthetics monitor with a partial set of attributes; fields that are not provided keep their current values. The spec documents
typeas required in the request body, but Kibana 9.4.3 accepts partial updates without it.- Parameters:
id (str) – The config ID of the monitor to update.
type (str | None) – The monitor type (
http,tcp,icmporbrowser). The type of an existing monitor cannot be changed.name (str | None) – The monitor’s name.
url (str | None) – The URL to monitor (
httpmonitors).host (str | None) – The host to ping or connect to (
icmp/tcpmonitors).inline_script (str | None) – The inline playwright script (
browsermonitors).locations (list[str] | None) – Elastic managed locations the monitor runs from.
private_locations (list[str] | None) – Private location IDs or labels the monitor runs from.
schedule (dict[str, Any] | None) – The monitor’s schedule, e.g.
{"number": "5", "unit": "m"}.enabled (bool | None) – Whether the monitor is enabled.
labels (dict[str, str] | None) – Custom key-value label pairs.
namespace (str | None) – The data-stream namespace.
retest_on_failure (bool | None) – Whether the monitor is retested on failure.
service_name (str | None) – The APM service name (sent as
service.name).timeout (int | str | None) – Time in seconds before a check is considered failed.
fields (dict[str, Any] | None) – Additional type-specific fields merged into the request body verbatim.
space_id (str | None) – Optional space ID the monitor lives in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the updated monitor object.
- Raises:
NotFoundError – If no monitor exists with the given ID.
BadRequestError – If the update payload is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> updated = await client.synthetics.update_monitor( ... id="d4ba9d2f-...", ... name="Renamed monitor", ... tags=["updated"], ... ) >>> print(updated.body["name"]) Renamed monitor
- async delete_monitor(*, id, space_id=None, validate_spaces=None)[source]¶
Delete a monitor.
Delete a synthetics monitor by config ID.
- Parameters:
- Returns:
ApiResponse with a list of deletion results, for example
[{"id": "...", "deleted": true}].- Raises:
NotFoundError – If no monitor exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> result = await client.synthetics.delete_monitor(id="d4ba9d2f-...") >>> print(result.body[0]["deleted"]) True
- async bulk_delete_monitors(*, ids, space_id=None, validate_spaces=None)[source]¶
Delete monitors.
Delete multiple synthetics monitors by their config IDs in a single request.
- Parameters:
- Returns:
ObjectApiResponse with a
resultlist; each entry containsid,deletedand, for monitors that could not be deleted, anerrormessage.- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> result = await client.synthetics.bulk_delete_monitors( ... ids=["id-1", "id-2"] ... ) >>> for item in result.body["result"]: ... print(item["id"], item["deleted"])
- async test_monitor(*, monitor_id, space_id=None, validate_spaces=None)[source]¶
Trigger an on-demand test run for a monitor.
Trigger a one-off test run for an existing monitor without waiting for its schedule. The monitor must have at least one location with a running agent for the test to actually execute. Generally available since 9.2.0.
- Parameters:
- Returns:
ObjectApiResponse with the
testRunIdof the triggered run.- Raises:
NotFoundError – If no monitor exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> run = await client.synthetics.test_monitor(monitor_id="d4ba9d2f-...") >>> print(run.body["testRunId"])
- async get_params(*, space_id=None, validate_spaces=None)[source]¶
Get parameters.
Get all synthetics global parameters visible in the space. Parameter values are redacted unless the user has the proper read privileges.
- Parameters:
- Returns:
ApiResponse with a list of parameter objects (
id,key,description,tags,namespaces).- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> response = await client.synthetics.get_params() >>> for param in response.body: ... print(param["key"])
- async get_param(*, id, space_id=None, validate_spaces=None)[source]¶
Get a parameter.
Get a synthetics global parameter by ID.
- Parameters:
- Returns:
ObjectApiResponse with the parameter (
id,key,description,tags,namespaces).- Raises:
NotFoundError – If no parameter exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> param = await client.synthetics.get_param(id="a1b2c3") >>> print(param.body["key"])
- async create_param(*, key, value, description=None, tags=None, share_across_spaces=None, space_id=None, validate_spaces=None)[source]¶
Add a parameter.
Create a single synthetics global parameter that can be referenced by monitors.
- Parameters:
key (str) – The key of the parameter.
value (str) – The value associated with the parameter.
description (str | None) – A description of the parameter.
tags (list[str] | None) – An array of tags to categorize the parameter.
share_across_spaces (bool | None) – Whether the parameter should be shared across spaces.
space_id (str | None) – Optional space ID to create the parameter in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the created parameter (
id,key,description,tags,namespaces).- Raises:
BadRequestError – If the parameter definition is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> param = await client.synthetics.create_param( ... key="my-api-token", ... value="s3cret", ... description="Token used by browser monitors", ... ) >>> print(param.body["id"])
- async bulk_create_params(*, parameters, space_id=None, validate_spaces=None)[source]¶
Add multiple parameters.
Create several synthetics global parameters in a single request. Each entry must contain at least
keyandvalueand may also containdescription,tagsandshare_across_spaces.- Parameters:
- Returns:
ApiResponse with the list of created parameters (
id,key,namespaces).- Raises:
BadRequestError – If a parameter definition is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> created = await client.synthetics.bulk_create_params( ... parameters=[ ... {"key": "username", "value": "admin"}, ... {"key": "password", "value": "changeme"}, ... ] ... ) >>> print(len(created.body)) 2
- async update_param(*, id, key=None, value=None, description=None, tags=None, space_id=None, validate_spaces=None)[source]¶
Update a parameter.
Update a synthetics global parameter. Only the provided fields are changed.
Note
Kibana 9.4.3 applies a new
valuebut echoes the previously stored value in the response body (thevaluefield is encrypted at rest and is not re-read after the write). A subsequent request reflects the new value.- Parameters:
id (str) – The ID of the parameter to update.
key (str | None) – The new key of the parameter.
value (str | None) – The new value associated with the parameter.
description (str | None) – The new description of the parameter.
tags (list[str] | None) – An array of updated tags to categorize the parameter.
space_id (str | None) – Optional space ID the parameter lives in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the updated parameter.
- Raises:
NotFoundError – If no parameter exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> updated = await client.synthetics.update_param( ... id="a1b2c3", description="Rotated 2026-07" ... ) >>> print(updated.body["description"]) Rotated 2026-07
- async delete_param(*, id, space_id=None, validate_spaces=None)[source]¶
Delete a parameter.
Delete a synthetics global parameter by ID.
- Parameters:
- Returns:
ApiResponse with a list of deletion results, for example
[{"id": "...", "deleted": true}].- Raises:
NotFoundError – If no parameter exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> result = await client.synthetics.delete_param(id="a1b2c3") >>> print(result.body[0]["deleted"]) True
- async bulk_delete_params(*, ids, space_id=None, validate_spaces=None)[source]¶
Delete parameters.
Delete multiple synthetics global parameters by ID in a single request.
- Parameters:
- Returns:
ApiResponse with a list of deletion results, for example
[{"id": "...", "deleted": true}].- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> result = await client.synthetics.bulk_delete_params( ... ids=["id-1", "id-2"] ... ) >>> print([item["deleted"] for item in result.body]) [True, True]
- async get_private_locations(*, space_id=None, validate_spaces=None)[source]¶
Get private locations.
Get all synthetics private locations visible in the space.
- Parameters:
- Returns:
ApiResponse with a list of private location objects (
id,label,agentPolicyId,isInvalid,tags,geo,spaces).- Raises:
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> response = await client.synthetics.get_private_locations() >>> for location in response.body: ... print(location["label"], location["id"])
- async get_private_location(*, id, space_id=None, validate_spaces=None)[source]¶
Get a private location.
Get a synthetics private location by ID or label.
- Parameters:
- Returns:
ObjectApiResponse with the private location (
id,label,agentPolicyId,isInvalid,tags,geo,spaces).- Raises:
NotFoundError – If no private location exists with the given ID.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> location = await client.synthetics.get_private_location( ... id="e3134290-..." ... ) >>> print(location.body["label"])
- async create_private_location(*, label, agent_policy_id, tags=None, geo=None, spaces=None, space_id=None, validate_spaces=None)[source]¶
Create a private location.
Create a synthetics private location backed by a Fleet agent policy. Monitors assigned to the location run from Elastic Agents enrolled in that policy.
- Parameters:
label (str) – A label for the private location.
agent_policy_id (str) – The ID of the Fleet agent policy associated with the private location.
tags (list[str] | None) – An array of tags to categorize the private location.
geo (dict[str, float] | None) – Geographic coordinates (WGS84) for the location, e.g.
{"lat": 40.4, "lon": -3.7}.spaces (list[str] | None) – Space IDs where the private location is available. If not provided, the private location is available in all spaces.
space_id (str | None) – Optional space ID to create the private location in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the created private location (
id,label,agentPolicyId,isServiceManaged,isInvalid,tags,geo,spaces).- Raises:
BadRequestError – If the definition is invalid, the agent policy does not exist, or the agent policy is already used by another private location.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> location = await client.synthetics.create_private_location( ... label="Madrid DC", ... agent_policy_id="abc-123", ... geo={"lat": 40.4, "lon": -3.7}, ... ) >>> print(location.body["id"])
- async update_private_location(*, id, label, space_id=None, validate_spaces=None)[source]¶
Update a private location.
Update the label of a synthetics private location. The label is the only editable attribute.
- Parameters:
- Returns:
ObjectApiResponse with the updated private location.
- Raises:
NotFoundError – If no private location exists with the given ID.
BadRequestError – If the label is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> updated = await client.synthetics.update_private_location( ... id="e3134290-...", label="Madrid DC (rack 2)" ... ) >>> print(updated.body["label"]) Madrid DC (rack 2)
- async delete_private_location(*, id, space_id=None, validate_spaces=None)[source]¶
Delete a private location.
Delete a synthetics private location by ID. A location that still has monitors assigned to it cannot be deleted; delete or reassign the monitors first.
- Parameters:
- Returns:
ObjectApiResponse with an empty body on success.
- Raises:
NotFoundError – If no private location exists with the given ID.
BadRequestError – If monitors are still assigned to the location.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
- Return type:
Example
>>> await client.synthetics.delete_private_location(id="e3134290-...")