DrDroid

VMs / EC2 High API Error Rate

The API hosted on the VM/EC2 instance is returning a high number of errors.

Debug vms-ec2 automatically with DrDroid AI →

Connect your tools and ask AI to solve it for you

Try DrDroid AI

Understanding Prometheus and Its Purpose

Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. It is now a standalone open-source project and maintained independently of any company. Prometheus is designed to monitor the performance and health of applications and infrastructure, providing real-time metrics and alerting capabilities. It is widely used for monitoring cloud environments, including VMs and EC2 instances.

Symptom: High API Error Rate

The Prometheus alert High API Error Rate indicates that the API hosted on your VM or EC2 instance is returning a significant number of errors. This can affect the performance and reliability of your application, leading to poor user experience.

Details About the Alert

This alert is triggered when the error rate of your API exceeds a predefined threshold. The error rate is typically calculated based on the number of error responses (such as HTTP 4xx and 5xx status codes) compared to the total number of requests over a specific period. A high error rate can be caused by various factors, including application bugs, misconfigurations, or external dependencies failing.

Common Causes of High API Error Rate

  • Code bugs or exceptions not handled properly.
  • Database connectivity issues or timeouts.
  • External service dependencies failing or slow responses.
  • Resource exhaustion, such as CPU or memory limits being reached.

Steps to Fix the Alert

To resolve the High API Error Rate alert, follow these steps:

1. Investigate API Logs

Start by examining the API logs to identify any error messages or stack traces that can provide insight into the root cause. Look for patterns or recurring errors that might indicate a specific issue.

ssh -i your-key.pem ec2-user@your-ec2-instancesudo tail -f /var/log/your-api-log.log

2. Check Application Code

Review the application code for any potential bugs or unhandled exceptions. Ensure that all error conditions are properly logged and handled. Consider implementing retry logic for transient errors.

3. Monitor Resource Utilization

Use monitoring tools to check the resource utilization of your VM/EC2 instance. Ensure that CPU, memory, and disk usage are within acceptable limits. Consider scaling your infrastructure if resources are consistently maxed out.

topfree -mdf -h

4. Test External Dependencies

If your API relies on external services, verify their availability and performance. Use tools like cURL to test API endpoints and check for response times and error messages.

curl -I https://external-service-endpoint.com

Conclusion

By following these steps, you can diagnose and resolve the High API Error Rate alert in your Prometheus monitoring setup. Regularly reviewing logs, monitoring resource usage, and testing dependencies will help maintain the health and performance of your API. For more detailed guidance, refer to the Prometheus Documentation.

Frequently asked questions

What causes High API Error Rate? +

The API hosted on the VM/EC2 instance is returning a high number of errors.

Get root cause analysis in minutes

  • Connect your existing monitoring tools
  • Ask AI to debug issues automatically
  • Get root cause analysis in minutes
Try DrDroid AI