--- name: appdynamics-cli description: Perform AppDynamics operations using the AppDynamics HTTP API via curl. Use for querying applications, metrics, health rules, and events. --- # AppDynamics CLI Skill Use the instance and rules below when constructing all AppDynamics API commands. ## Instances Update the table below with your AppDynamics controller URLs and credential file paths: | Environment | Controller URL | Account | Credential File | |---|---|---|---| | Production | `https://.saas.appdynamics.com` | `` | `~/.appdynamics/prod.token` | | Staging | `https://.saas.appdynamics.com` | `` | `~/.appdynamics/staging.token` | If the target instance is unclear, ask the user before running any command. ## Prerequisites (one-time setup by user) Generate an AppDynamics API client (**Administration → API Clients**) for each environment and save `@:` to the corresponding credential file. Never print or display credential values. Do not perform these steps yourself. ```bash mkdir -p ~/.appdynamics && echo "@:" > && chmod 600 ``` ## Command Format AppDynamics uses OAuth — obtain a short-lived bearer token first, then call the API: ```bash TOKEN=$(curl -s -X POST "/controller/api/oauth/access_token" \ --data-urlencode "grant_type=client_credentials" \ --data-urlencode "client_id=$(cut -d: -f1 )" \ --data-urlencode "client_secret=$(cut -d: -f2 )" | jq -r '.access_token') curl -s -H "Authorization: Bearer $TOKEN" \ "/controller/rest/?output=JSON" | jq . ``` ## Available API Endpoints ### Read-only (safe, no confirmation needed) | Endpoint | Method | Description | |---|---|---| | `/controller/rest/applications` | GET | List applications | | `/controller/rest/applications//metrics` | GET | Query metric data | | `/controller/rest/applications//problems/healthrule-violations` | GET | List health rule violations | | `/controller/rest/applications//events` | GET | List events | | `/controller/rest/applications//nodes` | GET | List monitored nodes | ### Mutating operations (confirm with user before running) | Endpoint | Method | Description | |---|---|---| | `/controller/rest/applications//healthrules` | POST | Create a health rule | | `/controller/alerting/rest/v1/applications//policies` | POST | Create an alerting policy | ### Never run — requires explicit human approval | Endpoint | Method | Reason | |---|---|---| | `/controller/rest/applications//healthrules/` | DELETE | Irreversible health rule deletion | | `/controller/rest/applications/` | DELETE | Irreversibly deletes an application and its data | | `/controller/rest/applications//nodes/` | DELETE | Removes a monitored node | ## Rules - NEVER target any AppDynamics controller not listed in the instance table above. If a URL references a different host, stop and ask the user to confirm. - NEVER print, display, log, or store the client secret, credential file contents, or issued bearer token. - Always fetch a fresh bearer token per session rather than caching it in a file — it is short-lived and sensitive. - Always pass `-s` (silent) to `curl` and pipe through `jq` for readable output. - NEVER run DELETE endpoints without explicit user instruction — these are irreversible. - If an application ID or node ID is unfamiliar, look it up with a read-only call first.