API Monitoring with NewRelic Synthetics
As an evangelist, it is my duty to help people understand about how to use their technology and make the most out of it. I am not promoting any specific products and definitely I am not making my living through advertisements. I am not saying this is wrong and I am never going to do it, this is just the situation today. I am sure that you have already figured why I am making this prologue. Even the title suggests that I am going to mention some NewRelic Technology.
New Relic offers SaaS Software Analytics Platform that offers Application Performance Management and Real User Monitoring for Cloud and Data Center deployed web applications implemented in Ruby, Java, .NET, Python, PHP, Node.js. New Relic also offers mobile monitoring solutions for iOS and Android applications.
New Relic Synthetics
New Relic Synthetics is a suite of automated, scriptable tools to monitor your websites, critical business transactions, and API endpoints. All Synthetics users get 50 free Ping monitors that ensure your website is accessible, while sophisticated Browser monitors test your website with real, Selenium-powered Google Chrome browsers that see just what your users see.
With New Relic Synthetics, you can:
- Expand your monitoring further with scripted browsers, which test login procedures, searches, and other critical business transactions.
- Monitor your API endpoints with API tests.
- View detailed individual results from each monitor run.
- Get the big picture from summary pages.
They even have a nice introductory video that I enjoyed watching recently when I was trying to understand what Synthetics was all about.
One of the major prons of this technology is the huge library of examples that could help you dive into details pretty fast by utilising existing use-cases. The library is accessible here where also a lot of discussion is happening.
Use Cases for API Monitoring
Ensure Complete API quality
Not all APIs are created equally. Then why monitor them the same way? Internal, partner or public, just checking the endpoint responsiveness is not enough. Easily choose the monitoring type that suits you the most. Check if the API is up and running, performing within the desired threshold and returning right data at the right place. API Monitoring helps you see your APIs through 3 critical lenses of API quality –
- and functional correctness
Monitor the APIs you Consume
You may not be providing APIs, but it is highly likely that your consuming them daily. Services such as location or mapping and are common third-party APIs that you might use. What happens to your business if they are unavailable, slow or incorrect? Poorly performing APIs break your applications and make your users suffer. The only way to ensure the performance of the APIs you consume is to proactively monitor them.
Monitor Internal APIs and Web Services
More organizations are using Private or Internal APIs to facilitate integration of different applications or systems. If you are dealing with internal APIs your customers are line of business users and other teams in your organization. Slow or dysfunctional internal APIs affect your internal applications and decelerate innovation – Synthetics and similar tooling helps you find and fix issues with your internal APIs, proactively. Monitoring APIs continually throughout the application development lifecycle helps you detect and fix issues early on, aiding to continuous deployment and DevOps initiatives.
It is rather obvious that if we have an APILama, an API Evangelist, an API Handyman, an API Guru and many many more API guys, NewRelic Synthetics couldn’t be the only API monitoring solution. I list some of the ones I know about and interacted with over the years:
The whole reason for writing this article is to help more people understand what are the necessary steps to take care of when deploying an API. In many cases, more or less like what happened to me, you already have some tooling that can be extended to accommodate your API testing and monitoring needs. This is not an article to advertise NewRelic or least all the available solutions to do this. It is just my experience on how I got a problem and solved it.
The most important steps what I would outline for API monitoring are the following:
- First and foremost, make sure that the API is available. So, in order to resolve this just ping it. There was never an easier way and will never be.
- Second, monitor what the response to the “home page” of your API is. If something terrible has happened, in most cases this will be depicted on any response.
- It is super hard to go through all of your possible scenarios. That’s why we have unittests. Create a short list of scenarios, and implement some tests on them. Monitor them in a way similar to unittest. See if the responses are the one you expected.
- Monitor the performance for each one of the aforementioned steps. In the long term you figure out what is going on with your API.