GraphQL makes it incredibly easy for teams to request any data that they need to build a feature. This flexibility is great for shipping fast, but when you get into production, you need to be able to respond in a flexible way, however your schema is being used. Wouldn’t it be great if you had a tool that would proactively tell you when your service was slowing down or was running into errors? With Apollo Engine’s new Alerts feature, now you do!
How alerts work
Apollo Engine gives you insight into how your GraphQL API is performing. You can get a service-wide birds-eye view, or look into each GraphQL operation in detail. Engine alerts allow you to set thresholds on this expansive set of timing data, and send notifications to Slack or PagerDuty when problems arise.
Alerts can be configured on a number of different thresholds:
- Request rate — requests per minute
- Request duration — p50/p95/p99 service time
- Error rate — errors per minute
- Error percentage — the number of requests with errors divided by total requests
Engine lets you configure these thresholds on the entire service, or on individual operations. That pesky front page feed query will never be slow again with Engine on guard.
The triggers you select are evaluated on a rolling five minute window. This means that if you have an alert configured to trigger when the
HomeFeed operation’s error rate exceeds 5%, and 6 out of the 100 requests that were sent through Engine in the last five minutes resulted in an error, then the alert will trigger with an error rate of 6%. Once you have put out the fire with the information provided by Engine, the alert will resolve after the five minute rate falls back into acceptable levels.
How to set up alerts
Setting up alerts in your Engine account couldn’t be easier! There is a new ALERTS tab when you look at your service. I know you have been dying to click on it, now is your time to shine!
After turning on alerts, you will be greeted by a friendly prompt to setup your first alert channel. Choose either Slack or PagerDuty and put in your connection information.
Now Engine will suggest a couple handy alerts as a way to get started. By default it includes a performance alert for your entire service, and a critically helpful error rate trigger. You don’t want to be in production without Engine by your side!
Monitor what matters
The default alerts are great starting point, but the real value of this feature is to keep an eye on what matters most to your users. Using Engine’s performance data and error tracking, you should pick trigger values that matter for your entire service and for key operations. That
HomeFeed query from earlier should always be fast, but the
SignUp mutation should never fail! So let Engine help keep those goals in check without you having to watch dashboards all day long.
Setting up per operation triggers in Engine is just as easy as service wide ones. You can either set them up on the service level by clicking the operation name in the list, or go to the operation you want to alert on and setup the alert there.
Often times, you expect a certain operation to be slower than the rest or be more prone to errors. Other times, you want to have a more stringent alert on a critical operation. In these cases, you can configure more appropriate alerts for these operations individually. The service level triggers are great safety nets to make sure schema wide things are running smoothly.
No one wants to be woken up at 3 am because a developer in a different timezone forgot a closing bracket on an operation in GraphiQL. In the same vein, if error rates spike suddenly, a slack mesage when everyone is out to lunch won’t do much good. With Engine you can select the channel of notification that you want for each alert. This means its easy to warn the product team that things are looking slow in Slack but also super simple to wake up the on call team when things are on fire
Try it out today
Alerts are part of the new paid Engine Standard and Pro plans. You can easily try things out on any of your Engine services with a free trial, without putting in a credit card. Turn them on and rest easy knowing that Engine is watching your app for you!
Apollo Engine is a GraphQL gateway that helps you operate and understand your GraphQL API in production with features like performance tracing, error tracking, and result caching. If you haven’t added Engine to your API yet, read the setup directions here or learn more about what it does on the website.
James Baxley III
Normally found on his farm working his bee hives or tending his flock of sheep, James is a believer in cultivating happy and healthly communities. He is a lover of design systems, roses, and fixing old land rovers.
Stay in our orbit!
Become an Apollo insider and get first access to new features, best practices, and community events. Oh, and no junk mail. Ever.
Make this article better!
Was this post helpful? Have suggestions? Consider so we can improve it for future readers ✨.