Searching and filtering agents

AgentFilter selects agents for inventory searches, metric queries, operation searches, alert searches, and bulk actions.

In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class.

Combining filters

An agent must match at least one value in each filter criterion (OR within a criterion, AND between criteria). This example selects managed agents on either of two platforms, with the production tag.

from dataikuapi import AgentFilter

selection = (
    AgentFilter()
    .with_platform_ids("production", "production-eu")
    .with_states(AgentFilter.STATE_MANAGED)
    .with_tags("production")
)
agents = client.list_agents(agent_filter=selection)
for item in agents:
    print(item.platform_id, item.id, item.display_name)

Filter methods accept separate values: use with_agent_ids(*agent_ids) when starting from a list. Repeating a filter for the same criterion replaces its previous values.

Selecting by scope and platform type

Use the ID of an existing scope to select its agents, then restrict the selection to provider types such as Dataiku or Bedrock. Scope IDs are distinct from display names; platform types are distinct from platform IDs.

selection = (
    AgentFilter()
    .with_scope_ids("scope-id")
    .with_platform_types("Dataiku", "Bedrock")
)
agents = client.list_agents(agent_filter=selection)

Searching text and retrieving facets

client.search_agents() returns a dictionary containing the matching agent data as a list of dictionaries in agents, and counts for the available filter values in facets.

result = client.search_agents(
    agent_filter=AgentFilter().with_text_filter("support")
)
print(result["agents"])
print(result["facets"])

To retrieve Agent objects instead, call client.list_agents(as_type="objects").

Finding agents without tags or risk sign-off

untagged = client.list_agents(
    agent_filter=AgentFilter().with_tags(AgentFilter.NO_TAGS)
)
awaiting_sign_off = client.list_agents(
    agent_filter=AgentFilter().with_risk_sign_offs(
        AgentFilter.RISK_NOT_SIGNED_OFF
    )
)

Finding favorite agents

Favorites belong to the authenticated user. Use a personal API key to access the same favorites as in the UI. A non-personal API key does not use its creator’s favorites.

favorites = client.list_agents(
    agent_filter=AgentFilter().with_favorites()
)

Reusing a selection

The same filter can select the agents whose metrics or alerts you want to retrieve. Searches return only objects you have permission to read.

available_metrics = client.get_available_metric_ids(agent_filter=selection)
open_alerts = client.search_triggered_alerts(
    agent_filter=selection,
    states=["OPEN"],
)

A platform method such as platform.list_agents(agent_filter=selection) restricts the selection to that platform, replacing any platform IDs in the supplied filter.

Filtering by ownership and dynamic fields

Use with_ownership() and with_dynamic_field() to combine owner and dynamic field criteria. For example, with a configured dynamic field named business_unit:

selection = (
    AgentFilter()
    .with_ownership(AgentFilter.OWNERSHIP_MY_AGENTS)
    .with_dynamic_field("business_unit", "support", "sales")
)
agents = client.list_agents(agent_filter=selection)

with_ownership() accepts AgentFilter.OWNERSHIP_MY_AGENTS for agents owned by the caller’s user or groups, AgentFilter.OWNERSHIP_NO_OWNER for agents without an owner, and user:<login> or group:<name> for an explicit owner. Explicit owner filters follow the caller’s user and group visibility restrictions.

with_dynamic_field() matches exact values expressed as strings. Values within a field are combined with OR; different fields and other criteria are combined with AND. Repeated calls for the same field replace its accepted values.

Reference documentation

Classes

dataikuapi.agentmanagement.agent.AgentFilter()

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

Functions

get_available_metric_ids([agent_filter])

Lists the metric identifiers supported by readable agents matching the filter.

list_agents([as_type, agent_filter])

Lists readable agents matching an optional filter.

list_agents([as_type, agent_filter])

Lists agents on this platform.

search_agents([agent_filter])

Lists the readable agents matching a filter.

search_triggered_alerts([agent_filter, ...])

Searches readable Agent Management triggered alerts matching the supplied filters.

with_agent_ids(*agent_ids)

with_favorites([favorites])

Filters on the authenticated user's favorite agents.

with_platform_ids(*platform_ids)

with_platform_types(*platform_types)

with_risk_sign_offs(*risk_sign_offs)

with_scope_ids(*scope_ids)

with_states(*states)

with_tags(*tags)

with_text_filter(text_filter)