Testing common user behaviors on your site, especially if you have a strong global customer base, can be a major challenge, especially given the rapid pace demanded by continuous integration and deployment. Synthetics monitoring provides a solution, allowing you to routinely evaluate your website using simulated global user behavior. You can even create alerts to let you know when performance flags, so you can resolve issues faster.
Your synthetic monitor sends real, Selenium-powered Google Chrome browsers to your site from locations around the world to ensure your content is always up, everywhere. A possible element in your integration testing, monitors can be quickly assembled in New Relic using a set of no-code steps that capture user behavior. Ready to learn how? Let’s review the types of monitoring capabilities provided in New Relic.
Synthetic monitoring in New Relic
New Relic offers the listed synthetic monitoring capabilities:
- Availability: Ensures your site is reachable.
- SSL certificate expiration: Sends an alert when your SSL certificate is about to expire.
- Page link crawler: Automatically checks every link on a page.
- Page load performance: Tests your end user experience.
- Endpoint availability: Tests API endpoints.
- User flow/functionality: Tests full user journeys.
- Step monitor: Test full user journeys using a no-code step by step process.
Be sure to watch this video to find out more about what each one of these capabilities entails:
To test specific user interactions on a page, you can use one of the last two in the list: user flow/functionality or step monitors, which allow you to set the individual steps users will take on your site. Let’s get started setting up a step monitor in New Relic.
If you don’t have a New Relic account yet, sign up for free.
Set up a no code synthetic monitor
Let’s set up a step monitor, which requires no coding. These steps are for a very common user flow: logging in with your email address and password to New Relic at https://login.newrelic.com/login. You can follow the written steps, which combine the steps from these two short videos: testing complex workflows with no code and securing sensitive information with synthetics. You'll need a New Relic account to follow along.
Set up your secure credentials
In the first part of this tutorial, you’ll save your personal login information to your New Relic account as secure, encrypted credentials. This will keep your information safe so it can’t be viewed, updated, or deleted without explicit permission. Normally you would set up a test account and not use personal information in synthetic testing, but for this tutorial, you’ll use your own information to see how to set up secure credentials.
1. Sign in to your New Relic account. From the top level Explorer menu, select Synthetics.
2. Navigate to Secure credentials in the menu found underneath the search bar.
3. Select Create a secure credential for your email. Let’s call it LOGIN_EMAIL. Type your email into the field and save.
4. To create a second credential, select the plus sign or UI element that indicates you can create a secure credential.
5. Enter a name for your credential as the key, like LOGIN_PASSWORD. Type your password into the value field. Select save.
Create your monitor
Now that you have established your secure credentials, you can create a monitor that walks through the flow of a user entering their email and password and signing in to New Relic.
1. If you’re navigating from the credentials page, Select Explorer and choose Synthetics. You can also select Synthetics from the top level Explorer menu on the main page of New Relic if you have navigated away from the credentials page.
2. Select Create Monitor.
3. From the list of monitors you can create, select User step execution.
4. Provide a name for your monitor in the provided field. You’ll notice that within this same step, you can also set the frequency with which your monitor will run. By default, this is set to 15 minutes but you can adjust it if you like.
5. Next, select the locations which you would like to test. This example shows South America (São Paulo, Brazil), but you can test any location you want.
6. In the Navigate field, input a URL you’d like to monitor. Enter https://login.newrelic.com/login.
7. From the list of steps you can add, select Secure Credential. Within this box, you’ll need to provide the email address field by ID and the corresponding secure credential. New Relic’s application shows an email field, which has an ID of login_email. You can find this by inspecting the element in the browser.
Don’t forget to select the corresponding secure credential, LOGIN_EMAIL.
8. Next, create a third step by adding Click Element. This step represents a user clicking the Next button after providing an email address, which has an ID of login_submit. Enter login_submit as the ID in the provided field. Your user flow steps should look similar to the following image.
9. Now you can simulate the user typing in their password by adding another Secure Credential step to the flow. The password field on the site has an ID of login_password and you’ll utilize the other secure credential you created, LOGIN_PASSWORD. Enter these into the provided fields.
10. Finally, users must click a button that says Log in. You’ll again create a Click Element step. The button’s ID is login_submit, so enter this into the field. You’ll see steps three and four as in the following image.
11. Near the end of the page, you’ll see options to save, validate, or cancel your monitor. Choose validate and wait until the validation is completed, which may take a few minutes. You’ll see a dashboard with results of your monitor’s completed validation and you can choose to save it if you like. That’s it, you’ve created your synthetic monitor!
Want an example step monitor or work off of one that’s already been written? There’s an entire library of open-sourced pre-built synthetics monitoring scripts here.
Set up alerts for your synthetic monitor
The last thing you need to do is set up alerts so you can get an email or page when a user journey breaks or a performance threshold is crossed.
1. Sign in to your New Relic account. Select Alerts and AI > Policies. If you have no alert policies, select Create new alert policy. You’ll then need to give it a name and pick an alert method, which you can adjust to your own preferences.
2. Select the alert policy you would like to add synthetics monitoring alerts to, by scrolling the list or using the search box.
3. Open the policy, then select Add a condition.
4. Select Synthetics and then select the monitor you created earlier in this tutorial.
5. Fill out the remaining settings and select Create condition.
Synthetics monitoring is best when used in conjunction with real user monitoring (RUM), which tells you about real issues encountered by your customers. When combined, you’ll be able to better understand which user flows to test in your synthetic monitors, as well as be alerted to any real time issues right away. To learn more about RUM, check out our blog about setting up New Relic’s Browser Agent.
The views expressed on this blog are those of the author and do not necessarily reflect the views of New Relic. Any solutions offered by the author are environment-specific and not part of the commercial solutions or support offered by New Relic. Please join us exclusively at the Explorers Hub (discuss.newrelic.com) for questions and support related to this blog post. This blog may contain links to content on third-party sites. By providing such links, New Relic does not adopt, guarantee, approve or endorse the information, views or products available on such sites.