Start monitoring today and get 20% off on your first invoice. Available on all Uptrends plans.

Uptrends' Transaction and Multi-Step API monitor types allow you to traverse a flow consisting of several steps, either across a page on the web or by directly interacting with an API. In some cases, you may have a need to submit variable data. For example, a certain form in one of your transactions requires a timestamp, or you may need to generate a unique identifier to be used in one of the API requests. We support a number of automatic variables that we create for you. Most of them are actually functions that generate a value you can use in your HTTP requests, or fill out in textfields in your transaction monitors.

Generic automatic variables

The following automatic variables are available for both the Transaction and Multi-Step API monitor types:

  • {{@DateTime(format,offset)}}: The @DateTime variable generates dynamic date and/or time values, according to the format you specify. The date/time is always the current time expressed in the UTC timezone. It's possible to generate dates/times/timezones by specifying the optional offset parameter, which adds/subtracts the specified number of seconds. For example, to convert the current UTC time to Eastern Standard Time (UTC-5), specify -18000 (-5 * 60 * 60) as the offset. Similary, to calculate "this time tomorrow" in UTC, specify 86400 (24 * 60 * 60). If you omit the offset value, no offset is applied. For example, if right now is 24 February, 2018 22:30 UTC, the following expressions would yield these results:
    {{@DateTime(dd-MM-yyyy HH:mm)}} 24-02-2018 22:30 Now
    {{@DateTime(ISO)}} 2018-02-24T22:30:00.0000000Z ISO 8601 format
    {{@DateTime(UNIX)}} 1519511400 Unix epoch time
    {{@DateTime(MM/dd/yyyy,-86400)}} 02/23/2018 Yesterday
    {{@DateTime(MM/dd/yyyy,86400)}} 02/25/2018 Tomorrow
  • {{@RandomGuid}}: This variable produces a random value in the form AB0AD14D-9611-41A8-9C25-7D94B895CFF1. You can use this variable if you need to include a random value in your URL, POST data or HTTP header. If you use the @RandomGuid variable in multiple steps, each step will get a different random value. Each time the monitor is executed, you will get completely new random values.
  • {{@RandomInt(min,max)}}: This variable produces a random integer number, between the minimum and maximum values you specify (min and max included). For example, if you specify {{@RandomInt(0,100}}, this variable produces a number in the range 0..100.

Transaction-specific (legacy) variables

The following set of automatic variables are older, but may still be used. These variables are available only for Transaction monitors.

Timestamps

  • {timespan 0}{now dd-MM-yyyy}: To generate and set a timestamp (current date) in a text field on your page.
  • {timespan 1:0:0:0}{now dd-MM-yyyy}: To offset the day by 1 (tomorrow).
  • {timespan 0:1:0:0}{now dd-MM-yyyy}: Same as above, except offset by 1 hour.
  • {timespan 0:0:1:0}{now dd-MM-yyyy} and {timespan 0:0:0:1}{now dd-MM-yyyy}: Offset the current time by one minute or second, respectively.

Random value from an array

  • {random 1 2 3 4 5}: Set a random variable from an array. This function sets a random value from one to five.
  • {random apple banana orange}: This function sets a random string from the selected array: either apple, banana, or orange will be set.

Multi-Step API-specific variables

The following variables and information applies only to the Multi-Step API monitor type.

  • {{@ServerId}}: During execution of a Multi-step API monitor, this variable outputs a numeric value that identifies the Uptrends checkpoint location that is executing that check. For example, if the check is being executed on our checkpoint in Sydney, Australia, the variable will output 30. The list of checkpoint servers and their corresponding Server IDs is available through the Uptrends API at the Checkpointservers endpoint.
  • {{@RedirectUrl}}: In case any of the steps in your monitor are expected to return a redirect code, and you want to capture and test that redirect response, rather than automatically following it, this automatic variable will contain the URL the redirect is referring to. This will only happen if you choose not to auto-follow redirects, but set up an Assertion that checks for the appropriate redirect code. This procedure is explained in more detail here: How to handle redirects in multi-step monitoring.

Using an automatically generated value multiple times

Some of these variable functions (in particular the ones producing random and date/time values) are re-evaluated each time you use them, and will generate a new value every time. If you want to generate a particular value and use it multiple times throughout your multi-step scenario, you can define a predefined variable (as discussed in the Multi-step monitoring variables article) and use an automatic variable as its value.

Examples of predefined variables using automatic variables

Name Value Usage
SearchDate {{@DateTime(dd-MM-yyyy)}} A date value to be used as input for a search query.
UniqueEmail {{@RandomGuid}}@mycompany.com A random guid value combined with fixed text to generate an e-mail address that is different every time.
OrderAmount {{@RandomInt(1, 10)}} A random number between 1 and 10 to be used as the number of products to order. In a subsequent call, you could use this variable again to check the contents of a shopping cart and see if it does indeed contain this amount.