DX APM - REST API to import and delete Management Module
search cancel

DX APM - REST API to import and delete Management Module

book

Article ID: 145459

calendar_today

Updated On:

Products

CA Application Performance Management (APM / Wily / Introscope)

Issue/Introduction

How can to list, update, delete, import, export management modules using a REST API?

Environment

APM 20x

Resolution

1: Get the Temp Token

Login to ATC, Security, generate a new token
Select Public API, Never expires
For example: ey-MyToken-blablabla

NOTE: 
You can obtain below <apm-server> from ATC url for example:
http://10-426317.10.109.33.74.nip.io/apm/appmap/private/module/query 


2: List management modules

Syntax:
curl -X GET -H "Authorization: Bearer <token>" http://<apm-server>.nip.io/apm/appmap/private/mgmtmod

Example:
curl -X GET -H "Authorization: Bearer ey-MyToken-blablabla" http://10-426317.10.109.33.74.nip.io/apm/appmap/private/mgmtmod

Output:
[{"description":"","domainName":"SuperDomain","jarFileName":"SaaSMM.jar","agentExpressions":["(.*)\\|(.*)\\|(.*)"],"factive":true,"fbundleName":"SaaS","externalId":"SuperDomain:SaaS"},{"description":null,"domainName":"SuperDomain","jarFileName":"test.jar","agentExpressions":[".*"],"factive":true,"fbundleName":"CA APM For WebServers","externalId":"SuperDomain:CA APM For WebServers"}]


3. Obtain details of Mgmt Modules

This method would return the details of the selected module. It will have the description, active status, count of elements i.e. alert, calculator etc. defined in this mgmt module.

Syntax:
curl -X POST -H "Authorization: Bearer <token>" -H "Accept: application/json" -H "Content-Type: application/json"  http://<apm-server>.nip.io/apm/appmap/private/module/query -d "{}"

Example:
curl -X POST -H "Authorization: Bearer ey-MyToken-blablabla" -H "Accept: application/json" -H "Content-Type: application/json"  http://10-426317.10.109.33.74.nip.io/apm/appmap/private/module/query -d "{}"

Output:
{"offset":0,"limit":0,"total":2,"mgmtModules":[{"domainName":"SuperDomain","jarFileName":"test.jar","bundleName":"CA APM For WebServers","agentExpressions":[".*"],"alertCount":10,"metricGroupingCount":13,"id":"SuperDomain:CA APM For WebServers","active":true},{"domainName":"SuperDomain","jarFileName":"SaaSMM.jar","bundleName":"SaaS","agentExpressions":["(.*)\\|(.*)\\|(.*)"],"alertCount":166,"metricGroupingCount":168,"id":"SuperDomain:SaaS","active":true}],"totals":{"totalAlerts":176}}


4. Import a new Mgmt Module.

Syntax:
curl -X POST -H "Authorization: Bearer <token>" -F "file=@<managementmodule full path>.jar" http://<apm-server>.nip.io/apm/appmap/private/mgmtmod

Example:
curl -X POST -H "Authorization: Bearer ey-MyToken-blablabla" -F "file=@/test.jar" http://10-426317.10.109.33.74.nip.io/apm/appmap/private/mgmtmod

Output:
{"status":"SUCCESS","fileName":"test.jar","fileSize":"33736"}[root@muntest000472 ~]#


5. Export a Mgmt Module.

Syntax:
curl -X POST -H "Authorization: Bearer <token>" http://<apm-server>.nip.io/apm/appmap/private/mgmtmod/<mm.jar> --output “<mm-full-path.jar>”

Example:
curl -X GET -H "Authorization: Bearer ey-MyToken-blablabla" http://10-426317.10.109.33.74.nip.io/apm/appmap/private/mgmtmod/SaaSMM.jar --output "/tmp/SaaSMM.jar"

Output:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  110k    0  110k    0     0   415k      0 --:--:-- --:--:-- --:--:--  416k


6. Delete a Mgmt Module.

Syntax:
curl -X DELETE -H "Authorization: Bearer <token>" http://10-426317.10.109.33.74.nip.io/apm/appmap/private/module?externalId=<id>

Example:
curl -X DELETE -H "Authorization: Bearer ey-MyToken-blablabla" http://10-426317.10.109.33.74.nip.io/apm/appmap/private/module?externalId=SuperDomain:CA%20APM%20For%20WebServers
NOTE: spaces needs to be replaced by %20

Output:
None, if there is no error.