• English日本語한국어
  • Log inStart now

Synthetic monitoring best practices guide

With synthetic monitoring, you can monitor and test your apps and address issues before they affect your end users. Here are five tips so you can take advantage of its full power.

1. Choose your synthetic monitor

Synthetic monitors are virtual browsers that measure the performance of your website and capture aggregate numbers for load time, uptime, and average download size. You'll also have access to detailed statistics about downtime incidents and each page resource.

We have seven types of synthetic monitors to choose from, depending on what you want to monitor and how you'd like to do it. For example, a step monitor is a great way to create what essentially functions as a scripted browser without writing code. If you're looking for automated management of your synthetic monitors, our NerdGraph API lets you create, update, and delete your synthetic monitors through API calls.

Add your synthetic monitor

  1. To add a monitor, go to one.newrelic.com > All capabilities > Synthetic Monitoring. (If you have an EU-based account, go to one.eu.newrelic.com.) Click Create monitor.
  1. Select a monitor type, then fill in all required fields.

  2. You can add tags, change the period, or select a different runtime version. For ping and simple browser monitors, you can add a validation string. You can use the advanced options to enable substring monitoring for the following types of response validations:

    • Verify SSL (for ping and simple browser). This option verifies the validity of the SSL certificate chain. It can be duplicated by running the following syntax:

      openssl s_client -servername {YOUR_HOSTNAME} -connect {YOUR_HOSTNAME}:443 -CApath /etc/ssl/certs > /dev/null
    • Bypass HEAD request (for ping monitors). This option skips the default HEAD request and instead uses the GET verb with a ping check. GET requests will always happen if the HEAD request fails.

    • Redirect is Failure (for ping). If a redirect result occurs when Redirect is Failure is enabled, your synthetic monitors categorize it as a failure rather than following the redirect and checking the resulting URL.

  3. Select the locations from where you want your monitor to run. We recommend choosing at least three locations to avoid false positives. In other words, if at least one location returns a successful result then the endpoint must be up and triggering of an alert can be avoided.

  4. Depending on the monitor type, you'll be prompted to either Save monitor, Validate, or Write script.

  5. View your results as they're received in the summary page.

2. View the summary page for your synthetic monitors

On the summary page, you'll see information about the status of your synthetic monitor. If something created an active incident that triggered an alert, then click the critical alert for this monitor to open in a new tab. You can also access all your alert policies for your monitors when you click to manage alert policies for all monitors at the top of the page.

3. Get an overview of your application's performance

To ensure that web services are in place, working as expected, and error-free, you'll want continuous access to the results of your application's performance. Synthetic monitoring gives this type of assurance by performing automated tests on your web application for each selected location. Your synthetic monitors will note downtime instances (called "violations") and collect the aggregated numbers, results, and detailed statistics for each page resource.

To get quickly discover failing monitors, you can use the index of synthetic monitors page to see which monitors have open violations, success rate over 24 hours, number of failing locations, the monitor period, and monitor type. Clicking on a monitor, you'll be taken to the Summary page where you'll be presented with information to assess where that particular monitor is failing, why it is failing (last error message, error response codes, duration by domain), and more, to give you a deeper insight into your application's performance over time.

View your monitors in your list of entities

4. View individual monitor results

You need to view the performance of your web apps as they're accessed from different parts of the globe. Your Results page shows how everything from development to production affects user experience. You can sort what's listed to better identify problem areas or unusual results. Try filtering by location to compare monitor performance from different locations. To do this, you'll:

  1. Go to one.newrelic.com > All capabilities > Synthetic Monitoring.
  2. From theone.newrelic.com > All capabilities >
  3. Click Monitor, then click Results.

Results gives you an up-to-the-minute view of the slowest page loads for every monitored location.

5. Understand the load-time impact of each resource

The synthetics resources page shows how the different components of your website (for example, CSS, JavaScript, images, HTML, etc.) is affecting your overall load. You can drill into detailed metrics collected at run time, locate performance information for time spent by third-party resources, and identify HTTP response codes for each resource. To do this, you'll:

  1. Go to one.newrelic.com, then click Synthetic Monitoring.
  2. From the Monitors dropdown menu, select your monitor.
  3. Click Monitor, then click Resources.

6. Configure and develop a scripted browser test

Using scripted browsers, you can build complex monitoring workflows with the Selenium JavaScript Webdriver bindings. For example, you can log in to the application, navigate to a particular link, and wait for a page element to load and add an assertion. To do this, you'll:

  1. Go to one.newrelic.com > All capabilities > Synthetic Monitoring.
  2. Click the Create Monitor button
  3. Enter the name and details of your monitor (for example, sitename.com scripted browser)
  4. Select the locations from where you want your monitor to run (for example, Mumbai, Seoul, Columbus, and Montreal).
  5. Choose a frequency for how often your monitor will run from this (for example, five minutes).
  6. Set a notification method to alert your team when performance incidents occur.
  7. You are now ready to write your script. (Below is an example script to test performance of newrelic.com and check that certain elements have loaded.)
* Script Name: Best Practices - Chrome 100
* Author: New Relic
* Version: 1.4
* Purpose: best practices example
* Reference: https://docs.newrelic.com/docs/synthetics/synthetic-monitoring/scripting-monitors/synthetic-scripted-browser-reference-monitor-versions-chrome-100/
// -------------------- CONSTANTS
const SCRIPT_NAME = "Best Practices - Chrome 100" // name to record in script log
const IMPLICIT_TIMEOUT = 3000 // default implicit timeout is 10 seconds, 4 seconds x 14 findElement operations = 42 seconds, assuming all operations time out
const PAGE_LOAD_TIMEOUT = 60000 // default page load timeout is 60 seconds, fail early to prevent long duration timeouts
const SCRIPT_TIMEOUT = 20000 // default script timeout is 30 seconds
const USER_AGENT = "default" // set the user agent for Chrome
const PROTOCOL = "https://" // set the protocol
const USERNAME = "" // username:
const PASSWORD = "" // password@
const DOMAIN = "docs.newrelic.com" // your domain
const PATH = "/docs/new-relic-solutions/get-started/intro-new-relic/" // path to main page
const CHECK = "Need some inspiration first? Check out this intro video." // text to match on page
// -------------------- DEPENDENCIES
var assert = require("assert")
// -------------------- CONFIGURATION
await $webDriver.manage().setTimeouts({
implicit: IMPLICIT_TIMEOUT, // sets element load timeout
pageLoad: PAGE_LOAD_TIMEOUT, // sets page load timeout
script: SCRIPT_TIMEOUT // sets script timeout
// -------------------- VARIABLES
var By = $selenium.By
var loc = {
video: By.css("#gatsby-focus-wrapper > div.css-1uz5ayg > div > main > div > article > div > div > div:nth-child(1) > div > p:nth-child(2)"),
start: By.css("#gatsby-focus-wrapper > div.css-1uz5ayg > div > main > div > h1"),
e: [
{ step: 'signup', selector: By.css("#sign-up-for-new-relic-if-you-havent-already") },
{ step: 'ingest', selector: By.css("#ingest-some-data") },
{ step: 'dashboards', selector: By.css("#check-out-some-dashboards") },
{ step: 'data', selector: By.css("#add-more-data") },
{ step: 'alerting', selector: By.css("#set-up-alerting") },
{ step: 'users', selector: By.css("#add-users") }
// -------------------- FUNCTIONS
// for backwards compatibility with legacy runtimes
async function waitForAndFindElement(locator, timeout) {
const element = await $webDriver.wait(
"Timed-out waiting for element to be located using: " + locator
await $webDriver.wait(
"Timed-out waiting for element to be visible using ${element}"
return await $webDriver.findElement(locator)
// -------------------- START OF SCRIPT
console.log("Starting synthetics script: " + SCRIPT_NAME)
// confirm timeouts are set
const {implicit, pageLoad, script} = await $webDriver.manage().getTimeouts()
console.log("Timeouts are set to:")
console.log(" IMPLICIT: " + implicit / 1000 + "s")
console.log(" PAGE LOAD: " + pageLoad / 1000 + "s")
console.log(" SCRIPT: " + script / 1000 + "s")
// Setting User Agent is not then-able, so we do this first (if defined and not default)
if (USER_AGENT && 0 !== USER_AGENT.trim().length && USER_AGENT != "default") {
$headers.add("User-Agent", USER_AGENT)
console.log("Setting User-Agent to " + USER_AGENT)
// if an error happens at any step, script execution is halted and a failed result is returned
console.log("1. get: " + MAIN_URL)
await $webDriver.get(MAIN_URL)
console.log("2. waitForAndFindElement: " + loc.video)
const textBlock = await waitForAndFindElement(loc.video, IMPLICIT_TIMEOUT)
console.log("3. getText: " + CHECK)
const text = await textBlock.getText()
console.log("4. assert.equal: " + text)
assert.equal(text, CHECK, "validation text not found")
console.log("5. waitForAndFindElement: " + loc.start)
const platformMenu = await waitForAndFindElement(loc.start, IMPLICIT_TIMEOUT)
console.log("6. takeScreenshot")
await $webDriver.takeScreenshot()
console.log("7. findElement")
loc.e.forEach(async function (nr, i) {
let n = i + 1
// verify each asset has loaded
console.log(" " + n + ". " + nr.step + ": " + nr.selector)
await $webDriver.findElement(nr.selector)
console.error("Failure in Step 7." + n)
throw exception
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.