Setting up monitoring and fetching data¶
In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class.
Enabling monitoring for one agent¶
Call agent.setup_monitoring()
to create monitoring resources and enable the features supported by one agent.
You need agent administration rights and access to the project and connection used for these resources.
agent = client.get_agent("production", "support-agent")
result = agent.setup_monitoring(
project_key="AGENTMONITORING",
connection_name="filesystem_managed",
partitioning="DAY",
run_first_fetch=True,
include_in_uptime_tests=True,
)
print(result["configuredAgentIds"])
print(result["warnings"])
The project and connection must already exist. Omit these parameters to use the configured defaults. Inspect warnings even when the request succeeds: an agent may not have been fully configured.
Initial data fetches and uptime tests run in the background. Use the operation history described in Asynchronous operations to follow them.
Enabling monitoring for several agents¶
Call platform.setup_monitoring()
to configure monitoring for several agents in one request. Pass agent IDs,
AgentListItem entries, or
Agent handles, all from the same platform.
from dataikuapi import AgentFilter
platform = client.get_platform("production")
agents = platform.list_agents(
agent_filter=AgentFilter().with_agent_ids("support-agent", "sales-agent")
)
if agents:
result = platform.setup_monitoring(
agents,
project_key="AGENTMONITORING",
connection_name="filesystem_managed",
)
print(result["warnings"])
Provide at least one agent, and do not repeat an agent ID. Use Setting up monitoring across platforms to apply this pattern across platforms.
See Asynchronous operations to track the initial fetches and tests started for the selected agents.
Fetching execution logs¶
For an agent that supports log fetching and has its monitoring resources configured:
agent = client.get_agent("production", "support-agent")
result = agent.start_fetch_logs().wait_for_result()
print(result)
See Asynchronous operations to follow collection progress and read the operation logs.
OpenTelemetry receiver agents receive traces sent to Agent Management. They do not support fetching logs from a remote platform. The summary returned by agent.get_status().get_light() includes capabilities["logFetch"].
To investigate collection failures, open the agent’s Activity > Logs page. These diagnostic logs are separate from the execution logs collected into monitoring datasets. See Accessing logs.
Fetching platform operational metrics¶
Some providers expose operational metrics separately from execution logs. Use this operation when capabilities["operationalMetricsFetch"] is true.
result = agent.start_fetch_platform_operational_metrics().wait_for_result()
print(result)
The fetch returns an operation handle. See Asynchronous operations to monitor it and inspect failures.
Scheduling data collection¶
Periodic fetches are configured on the platform. Per-agent settings select whether scheduled log and operational metric fetches are enabled.
platform = client.get_platform("production")
settings = platform.get_settings()
settings.raw["periodicFetchEnabled"] = True
settings.raw["periodicFetchScheduleMode"] = "MINUTES"
settings.raw["periodicFetchFrequencyMinutes"] = 60
settings.save()
settings = agent.get_settings()
settings.get_raw()["configuration"]["scheduledLogFetchEnabled"] = True
settings.save()
For operation status and failures, see Asynchronous operations. For retrieving collected values, see Retrieving metrics.
Reference documentation¶
Classes¶
Agent filter accepted by search, metric retrieval and bulk action methods. |
Functions¶
|
Returns a handle to an 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 the settings of this platform. |
|
Returns status information about this agent. |
|
|
Lists agents on this platform. |
|
Saves the settings of this agent, checking |
|
Saves the settings of this platform, using |
|
Enables monitoring for this agent and provisions its monitoring resources. |
|
Enables monitoring for one or several agents on this platform in one pass. |
Starts fetching execution logs for the agent. |
|
Starts fetching platform operational metrics for the agent. |
|
Waits for this operation to complete successfully and returns its result. |
|
|
