Setting up monitoring across platforms

This helper groups the selected agents by platform. It creates their monitoring resources with one call per platform. You need administration rights on each selected agent and access to the chosen project and connection.

Helper definition

from collections import defaultdict

def setup_selected_agents(client, agent_filter, project_key, connection_name):
    by_platform = defaultdict(list)
    for item in client.list_agents(agent_filter=agent_filter):
        by_platform[item.platform_id].append(item.id)

    results = {}
    for platform_id, agent_ids in by_platform.items():
        platform = client.get_platform(platform_id)
        results[platform_id] = platform.setup_monitoring(
            agent_ids,
            project_key=project_key,
            connection_name=connection_name,
            run_first_fetch=True,
        )
    return results

Example use

client is an AgentManagementClient created as described in The main AgentManagementClient class. Use existing project and connection names.

from dataikuapi import AgentFilter

selection = (
    AgentFilter()
    .with_platform_ids("production", "production-eu")
    .with_tags("onboard-monitoring")
)
results = setup_selected_agents(
    client,
    selection,
    project_key="AGENTMONITORING",
    connection_name="filesystem_managed",
)
for platform_id, result in results.items():
    print(platform_id, result["configuredAgentIds"], result["warnings"])

A successful request can still report warnings for agents that could not be configured. Review the per-platform results before relying on the monitoring data. See Setting up monitoring and fetching data for setup options.

Initial data fetches and uptime tests run in the background. See Asynchronous operations to track them through the operation history.

Reference documentation

Classes

dataikuapi.agentmanagement.agent.AgentFilter()

Agent filter accepted by search, metric retrieval and bulk action methods.

Functions

get_platform(platform_id)

Returns a handle to an Agent Management platform.

list_agents([as_type, agent_filter])

Lists readable agents matching an optional filter.

setup_monitoring(agents[, run_first_fetch, ...])

Enables monitoring for one or several agents on this platform in one pass.

with_platform_ids(*platform_ids)

with_tags(*tags)