Uptime tests¶
Uptime tests send a configured question to an agent and record its response status and response time. The provider must support uptime tests, and the agent must be included in them.
In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class.
Configuring a test question¶
Configure the platform question and enable the schedule. This example runs tests every 15 minutes on a platform that supports them.
platform = client.get_platform("production")
settings = platform.get_settings()
settings.raw["canaryQuestion"] = "Reply with a short greeting."
settings.raw["scheduledCanaryQueriesEnabled"] = True
settings.raw["periodicCanaryQueriesScheduleMode"] = "MINUTES"
settings.raw["periodicCanaryQueriesFrequencyMinutes"] = 15
settings.save()
agent = platform.get_agent("support-agent")
settings = agent.get_settings()
settings.get_raw()["configuration"]["inheritCanaryScanFromInfra"] = False
settings.get_raw()["configuration"]["includeInCanaryScan"] = True
settings.save()
The API field names use canary for uptime test configuration. The user configured to run operations on the platform must have permission to call the agents.
Running tests on demand¶
operation = platform.start_run_uptime_tests(agent_ids=["support-agent"])
result = operation.wait_for_result()
print(result)
Omit agent_ids to test all eligible agents on the platform.
See Asynchronous operations to follow test progress and inspect logs and failures.
Retrieving individual results¶
for result in agent.get_uptime_results():
print(result["timestamp"], result["status"], result["responseTimeMs"])
To query a time range using datetimes that include a timezone, use agent.get_metric_time_series() with reliability.uptime_test_status and performance.uptime_test_response_time_ms. For aggregated uptime percentages and counts, use agent.get_metric_buckets(). See Retrieving metrics.
Reference documentation¶
Functions¶
|
Returns a handle to an agent on this platform. |
|
Returns bucketed metrics for this agent. |
|
Returns stored time-series values for this agent. |
|
Returns a handle to an Agent Management platform. |
|
Returns the raw settings of this agent. |
Returns the settings of this platform. |
|
Returns the settings of this agent. |
|
|
Returns the agent uptime test results. |
|
Saves the settings of this platform, using |
|
Saves the settings of this agent, checking |
|
Starts uptime tests for this platform. |
Waits for this operation to complete successfully and returns its result. |
