What is a Smart Variable; how is it used in conditions and actions?
Short answer
A Smart Variable enables a value that is calculated while the traffic is processed (such as the client IP, Host, path, cookie or a random number) to be written into a field instead of a fixed value. It is added with the fx button in the fields that support variables and can optionally be transformed with functions. In conditions, it is used in the Dynamic Condition, Dynamic List and AGS Condition types; in actions, it is used in fields such as the redirect address, the header content, the new path, the traffic variable value and the Traffic Mirroring sampling key.
How Does It Work?
- The fx button next to the field that supports variables is clicked; the Add Variable window opens.
- The variable is selected; if the variable requires an argument, it is entered (e.g. Random max. for Random Number).
- If needed, transformation functions are added with Add Functions (functions).
- The Summary is checked and the variable is added to the field with Submit. Fixed text and variables can be combined in the same field.
- While the traffic is processed, the variable is filled with the real value of that request or response.
Where Is It Used in TR7?
| Place | Field |
|---|---|
| Dynamic Condition | Query key; the comparison value only in some operators (comparison value field) |
| Dynamic List | Key to search (default Client IP address) |
| AGS Condition | Query key; only the variables that belong to AGS are listed |
| Location Redirection | Redirect location |
| Add HTTP Header · Set HTTP Header | Header content |
| Set Path · Set Path + Query | New path info |
| Create Traffic Variable | Variable value |
| Traffic Mirroring | Sampling key |
All the places of use are listed in the docs under the in which sections it is encountered heading. The other condition types such as Path, HTTP header and Source IP work with a fixed value; no variable is selected in these conditions.
Variables by Protocol and Stage
The variables offered in the list are filtered according to the protocol (HTTP / L7 TCP) and the stage (On Request / On Response) of the field. For example, Host and path are listed only in HTTP, and the response status code only at the response stage. Details: Variables · Which Variables a Field Lists.
Carrying Values Between Actions
The Create Traffic Variable action writes a value to a named traffic variable; the subsequent conditions and actions read this variable. The action that reads the variable must be ordered after the action that writes it (In what order do Actions run; how do I change the order?). To carry whether an action has run to the subsequent rules, the Set Variable on Hit field of the action is used.
Common Misconceptions
- "A variable can be used in every condition field." A variable is selected only in the Dynamic condition, Dynamic list and AGS condition types; the other condition types take a fixed value.
- "Response variables can also be selected in request actions." The list is filtered by stage; response variables appear only at the response stage.
- "A variable value is carried between actions on its own." To carry a value, Create Traffic Variable or Set Variable on Hit is used.
How it is done in the documentation
