Session filtering
Session filters enable you to query the set of connected client sessions on the Diffusion™ server based on their session properties.
To perform an action on a subset of the connected client sessions, you can create a query expression that filters the set of connected client sessions by the values of their session properties. Filter query expressions are parsed and evaluated by the Diffusion server .
The query expression used to filter the session is made up of one or more clauses chained together by boolean operators.
Creating a single search clause
keyoperator 'value'
- key
- The key name of the session property to be tested. The key name is case sensitive. Not required with the HASROLES operator.
- operator
- The operator that defines the test to be performed. The operator is not case sensitive.
- value
- The test value to be compared to the session property value. This value is a string and must be contained in single or double quotation marks. Any special characters must be escaped with Java™ escaping. The value is case sensitive.
Operator | Description |
---|---|
IS | Tests whether the session property value associated with the property key matches the test value. |
EQ | Equals. Tests whether the session property value associated with the property key matches the test value. Equivalent to 'IS'. |
NE | Not equal. Tests whether the session property value associated with the key is not equal to the test value. |
IN | Tests whether the value of a session property belongs to a set, which you provide after the operator. |
HASROLES | Tests whether a session has any one of a set of security roles, which you provide after the operator. |
all
The 'all' clause can be useful when creating a session metric collector.
Examples: single search clause
$Principal IS 'Ellington'
$Transport EQ 'WEBSOCKET'
$Country NE 'GB'
Location IS "San Jose"
Status EQ 'Active'
Tier NE 'Premium'
$COUNTRY in ['UK', 'DE', 'FR']
hasRoles ["operator", "trading desk"]
Chaining multiple clauses
Chain individual clauses together using boolean operator or use the NOT operator to negate a search clause. Boolean operators are not case sensitive.
Operator | Description |
---|---|
AND | Specifies that both joined search clauses must be true. |
OR | Specifies that at least one of the joined search clauses must be true. |
NOT | Specifies that the following search clause or set of search clauses must not be true. |
Use parentheses to group sets of clauses and indicate the order of precedence for evaluation. If no order of precedence is explicitly defined, the AND operator takes precedence over the OR operator.
Examples: multiple search clauses
$Principal IS 'Fitzgerald' OR $Principal IS 'Gillespie' OR $Principal IS 'Hancock'
$Transport EQ 'WEBSOCKET' AND $Country IS 'FR' AND Status EQ 'Active'
$Country EQ 'US' AND NOT ($Principal IS 'Monk' OR $Principal IS 'Peterson')
NOT (Status IS 'Inactive' AND Tier IS 'Free')