Splunk AppDynamics

Extract User list with roles

ArunkumarKarmeg
Explorer

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. 

Labels (1)
0 Karma
1 Solution

livehybrid
Super Champion

Hi @ArunkumarKarmeg 

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:

  1. GET /controller/api/rbac/v1/users - to retrieve a list of users
  2. GET /controller/api/rbac/v1/users/{userId}/roles - to retrieve the roles associated with a specific user

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:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

View solution in original post

livehybrid
Super Champion

Hi @ArunkumarKarmeg 

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:

  1. GET /controller/api/rbac/v1/users - to retrieve a list of users
  2. GET /controller/api/rbac/v1/users/{userId}/roles - to retrieve the roles associated with a specific user

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:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

ArunkumarKarmeg
Explorer

@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

 

  1. GET /controller/api/rbac/v1/users/{userId}/roles - to retrieve the roles associated with a specific user

 

Could you check and let me know on this. 

 

 

0 Karma

livehybrid
Super Champion

Hi @ArunkumarKarmeg 

This is it within the docs, are you able to see this page?

https://docs.appdynamics.com/appd/24.x/latest/en/extend-splunk-appdynamics/splunk-appdynamics-apis/r...

livehybrid_0-1746601941339.png

 

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma

ArunkumarKarmeg
Explorer

@livehybrid 

 

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.

0 Karma

livehybrid
Super Champion

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:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma

ArunkumarKarmeg
Explorer

@livehybrid 

 

Thanks again. Karma added to the post 🙂 

 

Could you help or suggest on the connection time out error with the python script.

0 Karma

livehybrid
Super Champion

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...

 

0 Karma

ArunkumarKarmeg
Explorer

@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 = ''

users_response = requests.get(f'https://<Controller URL>/controller/api/rbac/v1/users/5',auth=(username,password))
 
Do we need to include the Account name as well in the authentication?
 
0 Karma

livehybrid
Super Champion

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

0 Karma

ArunkumarKarmeg
Explorer

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. 

 

for user in users:
    user_id = user['name']
    roles_response = requests.get(f'{controller_url}/controller/api/rbac/v1/users/{user_id}' , headers = headers)
    roles = roles_response
    print(f"User: {user['name']}, Roles: {roles}")

 

 

0 Karma

ArunkumarKarmeg
Explorer

@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.

livehybrid
Super Champion

Hi @ArunkumarKarmeg 

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:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma
Get Updates on the Splunk Community!

.conf25 Registration is OPEN!

Ready. Set. Splunk! Your favorite Splunk user event is back and better than ever. Get ready for more technical ...

Detecting Cross-Channel Fraud with Splunk

This article is the final installment in our three-part series exploring fraud detection techniques using ...

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...