cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2125
Views
12
Helpful
3
Replies

API filtering on ClientSessions data

Dave Lewis
Level 1
Level 1

Hello,

When using the GUI page "Monitor/Clients and Users" if I filter on profile name 'voice' I get 3,652 results which is about right. If I use an API call on /data/ClientSessions?profileName="voice"&.maxResults=20000 I get 20,000 results of which vast majority are duplicates (client MAC). I'm guessing this call is showing me historical sessions as well as current/latest 'live' sessions? I don't see any parameter related to connection status to filter on to only return current or latest session data so I can get the same results as via the GUI - any help appreciated.

Running PI 3.1.4.

Thanks,


Dave

1 Accepted Solution

Accepted Solutions

Spencer Zier
Cisco Employee
Cisco Employee

Yes, the GET data/ClientSessions resource shows all client sessions that have not yet been pruned from the PI database.  To see which clients are live and which are not, you can use either the sessionEndTime parameter to identify sessions that have ended or the policyTypeStatus to see which clients are DISASSOCIATED and which are not.

View solution in original post

3 Replies 3

Spencer Zier
Cisco Employee
Cisco Employee

Yes, the GET data/ClientSessions resource shows all client sessions that have not yet been pruned from the PI database.  To see which clients are live and which are not, you can use either the sessionEndTime parameter to identify sessions that have ended or the policyTypeStatus to see which clients are DISASSOCIATED and which are not.

Thanks Spencer,

One more question then if I may - can I combine multiple filters using both 'and' and 'or' matching? For example if I want to use ClientSessions to return ((profileName="voice" OR vlan="101") AND policyTypeStatus="RUNNING") so I retrieve only active sessions but need to catch endpoints either in vlan 101 or using profile name voice? Or am I better off collecting all the associated sessions first and then filtering that myself?

Cheers,

Dave

Unfortunately, no, we don't support this.  You can either have all the filter criteria ANDed together (the default behavior).  Or you can specify .or_filter=true and have them ORed together.  But you can't mix and match.

I'd recommend either sweeping up all of the client sessions into your own data warehouse, indexing the values of interest to you, then doing your filtering there.  Alternatively, you could use OR filters to ensure you get every possible match, then drop the ones that don't meet your filter expression precisely.