Skip to main content

Multi-environment monitoring

Collections also enable you to run same monitoring checks on multiple environments(like Dev/Staging/Prod) without duplicating code or having to maintain multiple tests.

For example, if you have an API monitor for checking you Create User API. The same monitor can be used to run the checks on your Dev/Staging/Prod environments.

Adding Monitors

If you are adding monitors or tests which need to be executed on multiple environments, identify the variables that change between your environments.

The variables can be your URLs, usernames, passwords or any other information specific to each environment.

For example: your dev environment URL can be https://dev.example.com and your staging environment url can be https://stage.example.com

All such variables need to be externalized from your monitors to Environment variables.

These variables can then be accessed in your tests at runtime. Refer Using Environment Variables for more details about using Environment variable in your API monitors or Synthetic Tests.

Once your monitors are created with all the variables externalized, they can be easily executed against multiple environments.

Using Collections for running monitoring checks

To create a set of monitoring checks that should be executed in an environment:

  1. Navigate to Collections page from the left navigation menu.
  2. Create a new Collection and associate the Environment you'd like to use for the monitoring checks.

Create Collection with an Environment

info

If your individual monitoring checks already have an associated Environment, the variables with the same from from Collection's Environment will override the Monitor level Environment variables at runtime. Refer this section for more details about Environment variables.

  1. Click Save
  2. You will be navigated to Edit Collection screen for the newly created Collection.
  3. Click Collection Steps tab.
  4. Add all the API Monitors and/or Synthetic Tests that would like to run part of this Collection.
  5. Click the Run Collection button to run the checks.

All the monitors/tests that are part of this Collection are now executed using the Environment variables associated to the Collection.

Once you are satisfied with the run for one environment, create a new Collection and associate a different Environment with that Collection.

This way the same underlying API Monitors and Synthetic Tests can be executed against multiple environments.

Dealing with application changes

Often times with your application changes, the monitors will also require changes so they are up to date.

Here is an example scenario:

Imagine you have a Create User API monitor that's currently asserting the HTTP response = 200. And the same test is running on your Dev and Prod environments.

Couple of months later, you have changed your backend to respond with HTTP 201 and you rolled out the change to your Dev environment.

This will result in test failure in your Dev environment, while your Prod environment test is still passing with HTTP 200 response.

We recommend the following process to deal with such changes:

  1. Clone your existing Create User API monitor and fix the test.
  2. Ensure the test is passing against your Dev Environment.
  3. Navigate to the Collection that's running this monitor.
  4. Delete the failing Create User check (which is asserting HTTP 200) from this Collection.
  5. Add the newly created monitor to the Collection.
  6. Both your Dev and Prod environment tests should now pass. Your Dev environment is now asserting HTTP 201, while your Prod is asserting HTTP 200 using the old monitoring check.
  7. Once your application changes are rolled out to Production, repeat steps 3-5 in your Prod Collection.
  8. You can now disable/delete your old Create User API monitor.