An API, application programming interface, is a collection of tools, protocols, and subroutines that can be used when building software programs or applications. APIs makes software development easier by providing reusable components and a set of clearly defined communication protocols. Recently APIs have come to mean web services, but there are also APIs for software and hardware libraries, operating systems and databases.
For Web APIs that support a web-based application in production, there are two main metrics to keep an eye on .
- Is your Web API behaving as expected?
- What’s happening with your API when it’s not?
Fortunately, we have Web API monitoring for API developers, letting us track both.
This guide discusses API monitoring, what you can track, some hints for effective monitoring, and how to get started monitoring your Web APIs.
What Is API Monitoring, and Why Do It?
Web API monitoring is the process of tracking, logging, and analyzing the performance and availability of a Web API. By monitoring availability, developers can identify and address issues before they cause significant problems, sometimes before customers realize it.
Additionally, API monitoring can help developers optimize their API’s performance by identifying potential areas for improvement, like low-performing request responses.
Many different tools and services are available for API monitoring, including open-source options. Ultimately, deciding which tool to use will depend on the project’s needs. However, all API monitoring tools share one common goal: to help developers build better APIs.
The Benefits of API Monitoring
There are many benefits to Web API monitoring, including:
- Monitoring uptime: Service-level agreements (SLAs) are at the heart of web-based services, and ensuring you meet them is vital to your business.
- Improving the quality of APIs: By monitoring APIs, organizations can identify areas where they need improvement and make changes to improve the quality.
- Tracking usage: API monitoring helps track trends and usage patterns for planning future updates, product releases, and potentially new product offerings.
- Tracking performance: API monitoring can track performance over time and make changes to improve it.
- Ensuring timely updates: One of the advantages of API monitoring is it can help organizations ensure their APIs are always up to date. API monitors can serve as a type of quality control for organizations.
- Debugging issues: API monitoring helps debug problems and identify potential errors.
- Reducing support costs: Organizations can save money on support costs by identifying and fixing problems with APIs before they cause significant issues.
Web API monitoring is an essential tool for any organization offering APIs. In many cases, it’s equally crucial to API development.
API Monitoring Tools
There are several Web API monitoring tools and services available to assist with monitoring and testing, including:
- Pingdom®: A professional, enterprise-grade API monitoring tool for tracking API uptime, response time, and availability.
- Prometheus®: An open-source monitoring tool providing enough functionality if your requirements are relatively low. It lacks some analysis capabilities and will only write logs to a local disk.
- Graphite®: Another open-source monitoring tool. It’s easy to install and allows you to track application deployments to narrow down the root cause.
- SoapUI®: A tool used to test the functionality of APIs, initially only for SOAP calls, but it has expanded to more types in recent years.
- Postman®: A tool for testing APIs including several features for working with APIs, such as making test requests and inspecting responses.
An API Monitoring Sample Plan
There are many ways to set up an Web API monitoring program. Below is a basic outline of steps to get you started:
- Define your goals, requirements, and metrics. Which metrics are important will vary depending on your specific business goals, but some standard metrics include availability, response time, error rates, and throughput.
- Choose an appropriate monitoring tool based on your goals, requirements, metrics, budget, and technical capabilities. Install it and train your people to use it.
- Establish monitoring criteria such as uptime, performance, or usage trends to produce meaningful information supporting business goals.
- Set up regular testing by a human to ensure the API is functioning as expected and your monitoring tool is accurate.
- Review the results regularly and adjust to improve the quality of your API monitoring program. If business goals change, change the metrics to support these changes.
- Repeat starting with No.3.
With the following tips, you can ensure your API monitoring program provides maximum value to your business.
API Monitoring Tips
Many variables go into API monitoring, but here are some things to keep in mind.
Monitor Everything
All of your Web APIs need coverage, including the one with only one customer using it once a month. Most likely, the API is critical to your customer’s business once a month, and you will hear about it when issues arise.
Monitor All the Time
Perform heartbeat checks every five to 15 minutes around the clock, 365 days a year. Your business is constantly moving, so your monitoring must keep up.
Ensure Accuracy
Whenever you have a human reviewing data or interacting with your Web API, there’s a chance for human error. Create automatic processes for testing wherever possible to avoid this issue. Additionally, validate the results you see in the monitoring tool with human-driven testing.
Prioritize
Not all metrics are created equal. Some will be more important to your business than others. Prioritize your most critical metrics and base your monitoring around them.
Test as Your Customer Uses the Service
Testing as your customer means accessing the Web API from outside your internal network, with the credentials and security exactly how a customer would use the system. And set up a test user in production with valid, dummy data.
Test Where Your Customer Uses the Service
Geography can affect service times. If the issues are beyond your control (such as inadequate local infrastructure), having the data to show customers can soothe heated conversations.
Go Beyond Testing Only the Return Codes
I can’t tell you how many ‘200’ responses I’ve seen with an error message in the body. You won’t get all of these alerts set up right away, but you can determine ways to detect anomalies in “correct” responses over time. Deeper testing is another reason for having a dummy customer with valid data in production.
Have the Business Review Your Checks
You need to monitor what is promised to customers, not what your technical team has delivered. If you aren’t providing something promised, it’s better for your team to discover it vs. your customer.
Don’t Only Monitor Averages
A group of alerts for a set of customers can show issues with the underlying code or infrastructure. For example, your one customer with 10 times the data with long wait times can help identify problems with your database queries or a need to build out a database cluster.
Don’t Sweat One-Off Anomalies
Ignoring alerts seems the opposite of the above point, but sometimes you’ll encounter sporadic unrepeated issues. A super-rare confluence of events could have caused the alert and is unlikely to occur again. Concentrate on replicable and reproducible problems, so you don’t spend time on issues distracting from your business goals.
API Monitoring First Steps
Luckily, it’s relatively easy to get started with a Web API monitoring tool.
First, go to a provider’s website and sign up for the service. Many paid providers, including Pingdom, give you a free 30-day trial to get a feel for their service.
Next, add your APIs to the dashboards.
Now set up your alerts.
All done. From this point forward, you’ll get real-time data on the status of your APIs.
Wrapping Up
Web API monitoring is a valuable tool for businesses and developers alike. Tracking Web API uptime, response time, availability, and other performance metrics will ensure your API functionality meets users’ expectations.
This post was written by Steven Lohrenz. Steven is an IT professional with 25-plus years of experience as a programmer, software engineer, technical team lead, and software and integrations architect. He blogs at StevenLohrenz.com about IT, programming, the cloud, and more.