Task log Retrieval API

Overview

This guide demonstrates how to orchestrate multiple APIs for automated configuration deployment. It covers the sequence and data flow between API calls, identifying which data from one API feeds into the next to ensure a successful deployment and verification loop.

Prerequisites

  • Controller Version: Minimum version 26.1.0.
  • Permissions: AGENT_MANAGEMENT_READ and AGENT_MANAGEMENT_WRITE.
  • Base URL: Your AppDynamics controller endpoint (e.g., https://<company>.saas.appdynamics.com).
  • OAuth Credentials: Client ID and Client Secret with API access.

Obtain OAuth Access Token

Before making any API calls, authenticate to obtain a Bearer token.

Endpoint: POST /controller/api/oauth/access_token

BASH
curl -X POST "https://<controller-url>/controller/api/oauth/access_token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=your-client-id@your-account" \
  -d "client_secret=your-client-secret"

Next Step: Save the access_token for the Authorization: Bearer header in subsequent calls.

Query Agent Inventory

Query the inventory to find smart agents matching your criteria. Available since version 26.1.0.

Endpoint: POST /controller/rest/v2/agent-management/inventory/query

JSON
{
  "agentType": "SMART_AGENT",
  "filters": [
    {
      "field": "HOST_NAME",
      "value": ["ip-10-115-85-44", "ip-10-115-85-45"]
    }
  ]
}

Key Output: Extract the agentInstanceId values from the response data.

Deploy Configuration

Deploy the configuration file to the target agents. Available since version 26.1.0.

Endpoint: POST /controller/rest/agent-management/v2/configuration/deploy

Field Type Description
agentInstanceIds List<String> IDs from Step 2 (max 1000).
configFiles List<Object> Contains fileName and JSON-escaped fileContent.

Key Output: Save the task id for polling.

Monitor Task Status

Poll the task status API to monitor deployment progress until completion.

Endpoint: POST /controller/restui/agent-management/inventory/tasks/ids

Table 1. Deployment Status Values
Status Meaning
TRIGGERED Deployment has been initiated.
SUCCESS Deployment completed successfully.
FAILED Deployment failed; review task logs.
Tip: Poll every 5-10 seconds to avoid throttling.

Verify Effective Configuration

Retrieve the effective configuration that agents are actually using. Available since version 26.1.0.

Endpoint: POST /controller/rest/agent-management/v2/configuration/retrieve

Important: Wait 5-10 minutes after task completion before calling this API to allow agents to process and report the configuration.
JSON
{
  "agentInstanceIds": ["smart-agent-1", "smart-agent-2"],
  "agentType": "SMART_AGENT",
  "configFileNames": ["ld_preload.json"]
}

Verification: Compare the checksum field in the response with your deployed content to ensure a match.

Troubleshooting

Problem Solution
401 Unauthorized OAuth token expired. Request a new token.
429 Too Many Requests Increase polling interval to 10-15 seconds.
Smart agent is dead Agent is offline. Verify connectivity on the host.