Survey banner
The Dataiku Community is moving to a new home! We are temporary in read only mode: LEARN MORE

List users all instances

Solved!
john_fhm
Level 2
List users all instances

Hi,

 

I'm have 3 instances running in parallel (PRE, PROD and an Event server). I want to make a dashboard about the users activity across all the instances. I want to list all the users in each instance and when was the last activity of each user.

 

I tried this code:

import dataiku
client = dataiku.api_client()
dss_users = client.list_users()

user_list = []
# Grab list of users where they have active web socket sessions
for user in dss_users:
    if user['activeWebSocketSesssions'] != 0:
        user_list.append(user['displayName'])
print(user_list)


but there's only info about an instance in that instance and i want to locate all the info on the Event server.

 

How can a get the list of the users acroos all the instances and send to the Event server to make the dashboard?

 

Thanks

BR


Operating system used: Windows

0 Kudos
1 Solution

Then you need to use the method:

 client.list_users_activity()

 to extract the information.

import dataiku
import pandas as pd

client = dataiku.api_client()
for user in client.list_users_activity():
    print(f"User {user.activity['login']} last activity was on {pd.Timestamp(user.activity['lastSessionActivity'], unit='ms')}")

Then you can use the client from other instances, to check instance by instance.

View solution in original post

0 Kudos
4 Replies

Hello @john_fhm

we use the dataikuapi library to check users (and other things) in different instances, and then you can iterate over the clients. Using your script:

import dataikuapi
client_02 = dataikuapi.DSSClient('http://instance02.url.dom:port', api_key='instance02APIKeyadm')
client_03 = dataikuapi.DSSClient('http://instance02.url.dom:port', api_key='instance03APIKeyadm')

dss_users02 = client02.list_users()
dss_users03 = client03.list_users()

# Grab list of users where they have active web socket sessions
for li_users in [dss_users02, dss_users03]:
    user_list = []
    for user in li_users:
        if user['activeWebSocketSesssions'] != 0:
            user_list.append(user['displayName'])
    print(user_list)

 

Of course, you have to provide your own instance URLs and API keys.

I hope this helps!

0 Kudos
john_fhm
Level 2
Author

Hi @Ignacio_Toledo ,

Thanks for the reply.

If I put the condition:

user['activeWebSocketSesssions'] != 0

Checks if the user has active WebSocket sessions. What I need is to check not only the online users but all users and when was their last connection. 

Many thanks!

0 Kudos

Then you need to use the method:

 client.list_users_activity()

 to extract the information.

import dataiku
import pandas as pd

client = dataiku.api_client()
for user in client.list_users_activity():
    print(f"User {user.activity['login']} last activity was on {pd.Timestamp(user.activity['lastSessionActivity'], unit='ms')}")

Then you can use the client from other instances, to check instance by instance.

0 Kudos
john_fhm
Level 2
Author

This works perfectly!