Hi Team,
I need to extract the complete User list and their associated roles and groups in AppDynamics. Looks like there is no straight approach within AppD. Could you let me know any other option to get this list.
With API , I am able to extract only the user list. But I need it with the roles assigned to them.
To extract the complete User list with their associated roles and groups in AppDynamics, you can leverage the AppDynamics REST API. Although you've mentioned that you're able to extract the user list using the API, you can then use the API to fetch the roles associated with each user.
The AppDynamics API provides endpoints to retrieve user information and their associated roles. You can use the following API endpoints:
You can use a scripting language like Python to make API calls to these endpoints, first fetching the list of users and then iterating through the list to fetch the roles for each user.
Here's a sample Python code snippet you could use a starting point:
import requests # AppDynamics controller details controller_url = 'https://your-controller-url.com' username = 'your-username' password = 'your-password' # Get the list of users users_response = requests.get(f'{controller_url}/controller/api/rbac/v1/users', auth=(username, password)) users = users_response.json() # Iterate through the users and fetch their roles for user in users: user_id = user['id'] roles_response = requests.get(f'{controller_url}/controller/api/rbac/v1/users/{user_id}', auth=(username, password)) roles = roles_response.json() print(f"User: {user['name']}, Roles: {roles}")
Depending on your end-goal you can update the python accordingly, e.g. create a CSV or list out as required.
For more information on the AppDynamics REST API, refer to the AppDynamics documentation.
🌟 Did this answer help you? If so, please consider:
Your feedback encourages the volunteers in this community to continue contributing
To extract the complete User list with their associated roles and groups in AppDynamics, you can leverage the AppDynamics REST API. Although you've mentioned that you're able to extract the user list using the API, you can then use the API to fetch the roles associated with each user.
The AppDynamics API provides endpoints to retrieve user information and their associated roles. You can use the following API endpoints:
You can use a scripting language like Python to make API calls to these endpoints, first fetching the list of users and then iterating through the list to fetch the roles for each user.
Here's a sample Python code snippet you could use a starting point:
import requests # AppDynamics controller details controller_url = 'https://your-controller-url.com' username = 'your-username' password = 'your-password' # Get the list of users users_response = requests.get(f'{controller_url}/controller/api/rbac/v1/users', auth=(username, password)) users = users_response.json() # Iterate through the users and fetch their roles for user in users: user_id = user['id'] roles_response = requests.get(f'{controller_url}/controller/api/rbac/v1/users/{user_id}', auth=(username, password)) roles = roles_response.json() print(f"User: {user['name']}, Roles: {roles}")
Depending on your end-goal you can update the python accordingly, e.g. create a CSV or list out as required.
For more information on the AppDynamics REST API, refer to the AppDynamics documentation.
🌟 Did this answer help you? If so, please consider:
Your feedback encourages the volunteers in this community to continue contributing
@livehybrid , Thanks much for your prompt response on this.
The API shared for getting roles assigned to individual users is not working and also I am not able to find this API in the document. There is only APIs for getting complete Roles and not specific to user
Could you check and let me know on this.
This is it within the docs, are you able to see this page?
🌟 Did this answer help you? If so, please consider:
Your feedback encourages the volunteers in this community to continue contributing
Yeah got it, after replying to your comment checked the docs again. The last portion on the URL /roles should be removed and it worked.
Thanks a lot for this.
In the python script I am getting connection timed out error, but it is working fine in the browser. I am trying from the same domain only, getting connection timed out error for both Python and curl method.
Any idea what would have been missed.
Ahh yes, my apologies I got my wires crossed too. I'll update the original python sample incase others want to use it.
Glad you've been able to make some progress on this!
If you get a moment please consider marking one of the posts as an accepted solution and/or adding Karma 🙂
🌟 Did this answer help you? If so, please consider:
Your feedback encourages the volunteers in this community to continue contributing
Thanks again. Karma added to the post 🙂
Could you help or suggest on the connection time out error with the python script.
Sorry I missed the bit about the timeout - Are you running the python/curl from the same machine as the browser call? First thing that comes to mind is perhaps an egress/connection issue...
@livehybrid Passed that error now, looked to be connectivity issue.
After resolving that issue, I am getting response as 401. Looks to be unauthorized error.
I am passing the credentials in this format.
Username = ''
Password = ''
In my haste I used user/pass combination in the requests example but I think you actually need to provide an Authorization header; such as in curl:
--header 'Authorization: Bearer <yourToken>'
You can get a token via the Admin web UI: https://docs.appdynamics.com/appd/24.x/latest/en/extend-splunk-appdynamics/splunk-appdynamics-apis/a...
Does this work? (Sorry, I dont have access to an AppD environment at the moment to check!)
Will
Hi @livehybrid ,
First API worked successfully and the User list has been extracted. But fetching the ID from the user list and passing it to the next API throws error.
Need some input on the python script.
Getting "TypeError: string indices must be integers" error , when checked the response received in in DICT format.
@livehybrid , Thanks a lot for your help on this.
Finally able to get the complete data of user list and their roles.
Still as a suggestion, this is very frustrating that to get a simple report there is no out of the box option.
Thanks again.
Sorry missed the last reply but I'm pleased you got it working!
Ye - in terms of APIs it doesnt make a lot of sense to have to query all users - If you have lots of users then this would be a lot of API calls just to get the groups. You'd think you would be able to get the role from a user list, or the user list from a role!
🌟 Did this answer help you? If so, please consider:
Your feedback encourages the volunteers in this community to continue contributing