This procedure is part of a lab that teaches you how to get started with New Relic to monitor your application.
Each procedure in the lab builds upon the last, so make sure you've completed the last procedure, Query custom Business Data, before starting this one.
With your app reporting server and browser-side performance data, you now have full visibility in your application. Happy with your current experinece, you came to know about New Relic alerts, and you've decided to add them.
With alerts, you monitor your services and receive notifications about problems that you're interested in, so that you can react fast to troubleshoot and resolve them.
Create an alert policy
Before you set alert conditions, you must create a policy.
If you're not already logged in, navigate to New Relic, and sign in with your account.
From Alerts & AI, go to Alert conditions (Policies) from the left-hand navigation. Here, you see different options to create a new alert policy or browse pre-built ones.
Click Browse pre-built alerts.
Under Application monitoring, choose Node.js alert policy.
This alert policy help you monitor your Node.js applications and provide you folloiwng pre-configured alert conditions:
- High CPU Utilization
- Memory Usage
- Transaction Errors
- Apdex score
On the next page, select your account from the dropdown and click Done since your Node.js application is already running.
This will create your alert policy. Click View alert policy.
Rename your alert policy to "Relicstaurants alert policy".
Your Relicstaurants alert policy is now setup. Next you add a custom alert condition to this policy.
Create alert conditions
You're going to add a "High page load time" alert condition to your newly created policy.
Create a high page load time condition
From Alert conditions (Policies), click New alert condition.
This takes you to Create an alert condition page where you use NRQL to define your alert condition.
NRQL is New Relic's SQL-like query language. Read our documentation to know more about what it is and when to use it.
Name your condition High page load time.
Use the following NRQL to set up alert for high load load time.
SELECT average(duration) FROM BrowserInteraction WHERE appName='Relicstraunts'
You want New Relic to alert you when your page takes longer than 1.5 seconds to load at least once in 2 minutes. Scroll down to Set your condition thresholds to adjust thresholds.
Under Connect your condition to a policy, choose "Relicstaurants alert policy" from the dropdown and click Save condition.
Your "High page load time" condition is not added to existing Relicstaurants alert policy.
Add a notification workflow
To receive notifications for any opened violations, you also need to create a notification workflow.
First, move to the Notification settings tab, and click Create workflow.
This takes you to Create a new workflow to get notified page. From the list of channel options, click Email.
Enter the email you want to receive your notifications on, update the Email subject and click Save.
This takes you back to Create a new workflow to get notified page where you see the notification channel is now added. Next, click Activate workflow.
You see the workflow under Notification settings now.
During this procedure, you created an alert policy and added a "high page load time" conditions to it. You also added a notification channel to receive notifications about any opened violations.
This procedure is part of a lab that teaches you how to get started with New Relic to monitor your application. Now that you've set up alerts, see your data in action.