Docs » Configure your tests » Create and use Global Variables

Create and use Global Variables 🔗

Global Variables are pre-saved, reusable variables you can define once and use across all your Browser and API tests.

How can you use Global Variables? 🔗

Global Variables are stored securely in the Splunk Synthetic Monitoring platform, but the keys and values of all Global Variables in your account are visible to all users with Manager or Administrator access.

To preserve your account’s security, don’t use production credentials, real credit card information, or other sensitive data in Global Variables for your checks. Instead, try using placeholder credentials to test workflows that require information to be entered during a test.

To use data such as test login credentials, API keys, or other test information, you can permanently conceal the value of a Global Variable from all users of your account.

What happens when you conceal a Global Variable? 🔗

When you conceal a Global Variable, its value is permanently concealed from all users of the account. This lets you create and save variables such as test login credentials, API keys, and other sensitive information to use in Browser and API tests.

To preserve security, the value of a concealed Global Variable is never revealed to any user of the account after it has been created and saved. It is scrubbed from the Splunk Synthetic Monitoring UI, from test results, and from alert messages.

Prerequisites 🔗

You need administrator access in Splunk Synthetic Monitoring to create and reference Global Variables.

Create a new Global Variable 🔗

There are two ways to create a new Global Variable:

  1. Add a new Global Variable in the Global Variables vault:

    1. From the Splunk Synthetic Monitoring landing page, select Synthetics Configuration. The Synthetics Configuration page opens, on the Global Variables tab.

    2. Select + Add to open the creation dialog box.

  2. Add a new Global Variable while editing a test:

    1. In the right-hand Variables column, scroll to Global Variables and select Add.

Once you’re in the Add Global Variable dialog box, enter the following:

  1. In the env field, enter the name of the variable. You will use this key to access your variable within a test.

  2. In the value field, enter the value that will replace the variable when the test is run.

  3. (Optional) In the Description field, enter a description to explain the purpose of the variable for future reference. A description is particularly helpful when you conceal the variable and cannot reveal its value.

  4. (Optional) Select Conceal value to permanently conceal the value to all users. See What happens when you conceal a Global Variable? to learn more.

  5. Once you’re satisfied with your Global Variable, select Add.

Edit a Global Variable 🔗

To edit the key or description of a Global Variable, visit the Global Variables page and edit within the field. Select Save when you’re finished editing.

Editing the value of a saved Concealed Global Variable clears the previous value. You must provide a new value and select Save to apply it.

Use a Global Variable in a synthetic test 🔗

You can use a Global Variable to fill in fields in the Steps and synthetic transactions of a Browser test, or in the requests of an API test. Global Variables cannot be used in cookies.

While creating or editing a test, the right-hand Variables tab provides list of built-in variables and Global Variables you can use. Select the name of a variable to copy it to your keyboard.

Use a Global Variable in a Browser test 🔗

Follow these steps to add a variable to your Browser test:

  1. While creating or editing a transactional Browser Test, go to your Steps.

  2. Under Action, select Fill in field from the dropdown menu.

  3. Under Value, enter the key for the Global Variable you want to use, preposed by the env. prefix and enclosed in double curly braces. For example, to reference a Global Variable with the key dev-username, enter {{env.dev-username}} in the Value field.

  4. Finish editing or creating the test.

  5. Save your test.

Use a Global Variable in an API Test 🔗

You can also use a Global Variable to fill in any field in an API test. For instance, you can use a Global Variable to provide a URL for any request, a header value, or any other value.

Follow these steps to add a variable to your API test:

  1. While creating or editing an API test, go to your Requests.

  2. In a variable field for any setup, request, or validation step, enter the key for the Global Variable you want to use, preposed by the env. prefix and enclosed in double curly braces. For example, to reference a Global Variable with the key staging-url, enter {{env.staging-url}} in the field.

  3. Finish editing or creating the test.

  4. Save your test.