Managing agents¶
An agent is identified by its platform ID and agent ID. Agents on different platforms may have the same agent ID.
In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class.
Listing agents¶
Use client.list_agents() to list all agents you can read:
for item in client.list_agents():
print(item.platform_id, item.id, item.display_name, item.state)
Use platform.list_agents() to list agents on one platform:
platform = client.get_platform("production")
agents = platform.list_agents()
By default, list_agents() returns a list of AgentListItem objects.
Call item.to_agent() to get an Agent object without making another API request,
or pass as_type="objects" to list_agents() to get these objects directly.
Retrieving status and capabilities¶
agent = client.get_agent("production", "support-agent")
# Equivalent: client.get_platform("production").get_agent("support-agent")
status = agent.get_status()
print(status.get_light())
print(status.get_heavy())
print(status.platform_activation_state)
The summary includes capabilities describing whether log fetching, platform operational metrics fetching, and uptime tests are available. The detailed status includes monitoring resource references. Available capabilities depend on the provider and agent configuration.
For diagnostic logs, open the agent’s Activity > Logs page. See Accessing logs for the available logs and required privileges.
Updating metadata¶
You need write access to the agent to retrieve and update its settings. Configuring access and monitoring also requires agent administration permission.
settings = agent.get_settings()
configuration = settings.get_raw()["configuration"]
configuration["displayName"] = "Customer support agent"
configuration["description"] = "Answers customer support questions"
configuration["tags"] = ["production", "customer-support"]
settings.save()
Changing tags replaces the previous list. Keep fetchedRevision from the retrieved settings so that concurrent edits are detected when saving.
Management state and remote activation¶
The server tracks each agent’s management state: DISCOVERED, MANAGED, IGNORED, or ARCHIVED. Editing an agent’s metadata does not enable monitoring. To create the required monitoring resources, follow Setting up monitoring and fetching data.
An agent’s management state is independent of whether it is enabled on its remote platform. See Enabling and disabling agents to change its remote activation status, or Searching and filtering agents to filter agents by management state.
Adding an OpenTelemetry agent¶
Most providers discover agents through scans. Manual creation is supported for OpenTelemetry receiver platforms. This example assumes that otel-production and the monitoring project and dataset connection already exist.
platform = client.get_platform("otel-production")
agent = platform.create_agent(
agent_id="support-agent",
display_name="Customer support agent",
description="Support agent sending OpenTelemetry traces",
tags=["production"],
configuration={
"serviceName": "support-agent",
"serviceInstanceId": "production",
"projectKey": "AGENTMONITORING",
"connectionName": "filesystem_managed",
},
)
The service identifiers must match the OpenTelemetry resource attributes sent by the agent. Creation also attempts to create monitoring resources; inspect the agent status to check the resulting configuration.
Deleting an agent record¶
client.get_agent("otel-production", "unused-agent").delete()
This removes the Agent Management record. To disable execution on a remote platform, use the activation methods in Enabling and disabling agents.
Reference documentation¶
Classes¶
A monitored Agent Management agent. |
|
An agent listing entry returned by the client's or platform's |
|
The status of a monitored agent. |
|
The settings of a monitored agent. |
Functions¶
|
Creates an agent manually and returns a handle to it. |
|
Deletes the agent. |
|
Returns a handle to an agent. |
|
Returns a handle to an agent on this platform. |
Gets the 'heavy' (full) status of this agent. |
|
Gets the 'light' (summary) status of this agent. |
|
|
Returns a handle to an Agent Management platform. |
|
Returns the raw settings of this agent. |
Returns the settings of this agent. |
|
Returns status information about this agent. |
|
|
Lists readable agents matching an optional filter. |
|
Lists agents on this platform. |
|
Saves the settings of this agent, checking |
|
Return a |
