New Relic Synthetics best practices guide

5 Tips for Monitoring Websites, Business Transactions, and API Endpoints

New Relic Synthetics—powered by a Selenium-driven Chrome browser—allows you to monitor and test your apps and address issues before they affect your end users. Here are five tips to help you take immediate advantage of the full power of Synthetics.

Synthetics will be available for accounts hosting data in the EU region data center in late 2019.

1. Match your monitor type to monitoring need

Synthetic monitors are virtual browsers that measure the performance of your website, recording each check in detail. They also capture aggregate numbers for load time, uptime, and average download size, as well as an overview, detailed statistics for each page resource, and downtime incidents.

There are four types of Synthetics monitors; the ones you deploy will depend on the things you want to monitor:

  • Ping monitors—to ensure that your site is accessible.
  • Simple Browser monitors—to ensure end-user performance.
  • Scripted Browsers—to ensure that particular resources are present.
  • API monitors—to ensure that your app server works as well as your website.

How to do it:

  1. To add a monitor, go to synthetics.newrelic.com and specify monitor type, name, and URL.
  2. Optional: Add a validation string (available for Ping and Simple Browser) or Advanced options, which enable substring monitoring for the following types of response validation:
    • 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). This option skips the default HEAD request and instead uses the GET verb with a ping check.
    • Redirect is Failure (for Ping). If a redirect result occurs when Redirect is Failure is enabled, Synthetics categorizes it as a failure (rather than following the redirect and checking the resulting URL).
  3. Select the locations where you want your monitor to run.
  4. Choose a frequency to determine how often each location will run your monitor.
  5. Optional: Set up alert notifications.
  6. Select Create my monitor to confirm.
  7. Wait a few minutes; then from the Monitors Index check your monitor.

2. Bookmark the Synthetics Overview page

Continuous application performance monitoring is essential to ensure that web services are in place, working correctly, and error-free. Synthetics provides this type of assurance by performing automated tests on your web application for each selected location—noting downtime instances (“violations”) and collecting aggregate numbers, results, and detailed statistics for each page resource.

Go to the Synthetics Overview page to view trends based on this data—including load times, availability (uptime), slowest results, and failures.

How to do it:

  1. To access your monitor’s Overview page, go to synthetics.newrelic.com and from the Monitors drop-down menu, select your monitor.
  2. Select Monitor > Overview.

3. View individual monitor results

It’s not enough to understand how your web apps are performing for your West Coast customers; you need to be able to view how they’re performing across the country and around the globe. By taking advantage of Synthetics monitors and visiting your Results page, you can see how everything from development to production affects user experience. You can locate interesting results by sorting the list to identify slow, fast, or other unusual results. Or filter by location to understand how monitor performance varies with geography. (The “Network timings” graph below provides a snapshot of webpage performance over a given period.)

How to do it:

  1. Go to synthetics.newrelic.com and from the Monitors drop-down menu, select your monitor.
  2. Select Monitor > Results.
  3. Gain an up-to-the-minute view of the slowest page loads for every monitored location.

4. Understand the load-time impact of each resource on your website

Visit the Synthetics Resources page to see how each resource on your website—including CSS, JavaScript, images, HTML and more—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.

How to do it:

  1. Go to synthetics.newrelic.com and from the Monitors drop-down menu, select your monitor.
  2. Select Monitor > Resources.

5. Configure and develop a scripted browser test

Using scripted browsers, you can build complex monitoring workflows using the Selenium JavaScript Webdriver bindings. For instance, you can log in to the application, navigate to a particular link, and wait for a page element to load and add an assertion.

How to do it:

  1. Go to synthetics.newrelic.com.
  2. Choose your monitor type (for example, Scripted Browser).
  3. Enter the name and details of your monitor (for example, Sitename.com Scripted Browser)
  4. Select the locations from which you want your monitor to run (for example, Mumbai, Seoul, Columbus, and Montreal).
  5. Choose a frequency to determine how often each location will run your monitor (for example, five minutes).
  6. Set a notification method to alert your team when performance violations occur.
  7. You are now ready to write your script. (Below is an example of a script used to test the performance of a main navigation page).
var assert = require('chai').assert;
// script-wide timeout for all wait and waitandfind functions (in ms)
var default_element_timeout = 190000;   //3 mins
var default_pageload_timeout = 240000; //4 mins
var navlinks = ["css-locator-1","css-locator-2"];

//sets element load timeout to 3 mins
$browser.manage().timeouts().implicitlyWait(default_element_timeout);
//sets page load timoeout to 4 mins
$browser.manage().timeouts().pageloadTimeout(default_pageload_timeout);

//test all the main nav page performances
$browser.get("http://www.sitename.com").then(function(){
return $browser.findelement($driver.by.classname("site-theme-example"));
}).then(function(){
  //verifies the nav list has loaded
  return $browser.findelement($driver.by.classname("site-nav-list-example"));
}).then(function(){
  //loops through the navlinks array
  navlinks.foreach(function(val, i, arr){
  //finds and navigates to each navlink page
  return
$browser.findelement($driver.by.classname(navlinks[i])).click().then(function(){
  //verifies that the nav list loaded before moving on
  return $browser.findelement($driver.by.classname("site-nav-list-example")).then(function(){
    //verifies that the page logo footer at bottom of page has loaded
    return $browser.findelement($driver.by.classname("site-footer-logo"));
    })
   })
 })
});

Want more user tips?

You can also download this document as a PDF (373 KB).

Recommendations for learning more: