---
title: "Keep up APIs Healthy with APISIX and Prometheus - API7.ai"
description: "Gain insights into API Health Check metrics with Apache APISIX and Prometheus."
url: "https://api7.ai/blog/api-health-with-prometheus-apisix"
---

[Blog](https://api7.ai/blog)

[Products](https://api7.ai/category/products)[Technology](https://api7.ai/category/technology)[Ecosystem](https://api7.ai/category/ecosystem)[Case Study](https://api7.ai/category/usercase)[Team & Community](https://api7.ai/category/community)

Search

⌘ + K

[Blog](https://api7.ai/blog)

Technology

# Keep up APIs Healthy with APISIX and Prometheus

[![Bobur Umurzokov](https://avatars.githubusercontent.com/u/14247607)](https://www.linkedin.com/in/boburumurzokov/)

[Bobur Umurzokov](https://www.linkedin.com/in/boburumurzokov/)

July 20, 2023

[Technology](https://api7.ai/category/technology)

API health checks are part of a proactive approach to monitoring the overall health of your APIs. A production design normally separates [API endpoint checks, liveness, readiness, and dependency checks](https://api7.ai/blog/tips-for-health-check-best-practices) from an API gateway's checks of its upstream nodes. In this article, we explore how [APISIX](https://apisix.apache.org/) and [Prometheus](https://prometheus.io/) work together to collect and analyze [upstream health-check metrics](https://apisix.apache.org/docs/apisix/tutorials/health-check/).

## Why does this matter to businesses?

The fact that establishing **Service Level Indicators** (SLIs) and **Service Level Objectives** (SLOs) has become a crucial component of site reliability engineering (SRE) best practices. They help the team set clear goals for how well a service (like a website or an app) should work. These goals can be for internal services (like an API used by the company's own apps) or for public products (used by customers). They provide teams with a quantifiable approach to managing the performance of a system. For example, common SLIs include **error rate, latency, throughput, and availability** or an SLO could be "*99.9% of API requests should complete in under 300ms*.”

[APISIX](https://apisix.apache.org/) API Gateway sits at the front of your API infrastructure and can be instrumental in measuring SLIs and SLOs. You do not have to figure out **what to measure** and **how to measure it** because it can get problematic, especially in today’s complex and distributed architectures. APISIX automatically tracks all necessary metrics such as **latency, unsuccessful requests, or throughput** for the upstream services consumed by your APIs. APISIX can perform health checks on the backend services, ensuring they are available to process requests and alert responsible teams to potential issues before they escalate to minimize downtime and improve system reliability.

## How does an API gateway health check work?

Generally, activating health checks for APIs is a straightforward process. Each service only requires a designated **health check API endpoint (**`/health`**)**. From there, you inspect the most relevant metrics for that service such as memory usage, database connectivity, response duration, and more. You can use observability platforms like Prometheus and Grafana to display the results and an alert system to immediately flag any issues.

One of the benefits of APISIX is that it makes **the process of configuration observability tools** even easier for multiple services. APISIX periodically send requests to the backend services they manage (also known as upstream nodes). If a healthy status is returned (typically a 200 OK HTTP status code), the service is considered healthy. The gateway might also evaluate the response time, treating a slow response as an indication of potential issues. If the service fails to respond within a specified timeframe, or if it returns an error status, it's marked as unhealthy. It will stop routing traffic to that service to prevent application errors or slowdowns and routes the traffic to a healthy node instead. Learn how to enable health check [here](https://apisix.apache.org/docs/apisix/tutorials/health-check/).

## Collecting health check data with the APISIX Prometheus plugin

APISIX integrates with Prometheus through a [plugin](https://apisix.apache.org/docs/apisix/plugins/prometheus/) called `prometheus`, offering an efficient way to **pull API metrics**, including those related to **the health status of upstream nodes** (multiple instances of a backend API service). Here's how it works:

1. When the APISIX Prometheus plugin is activated (See how to activate it [here](https://apisix.apache.org/docs/apisix/plugins/prometheus/#enabling-the-plugin)), it exposes a metrics URL, typically **`/apisix/prometheus/metrics`**. You can also customize the export **URI**, **add** **extra labels, the frequency of these scrapes, and other parameters** by configuring them in `conf/config.yaml`file.

```
plugin_attr:
  prometheus:
    export_uri: /metrics
```

2. Prometheus scrapes this URL at specific intervals, collecting time-series data associated with various performance parameters like **request count, request latency, upstream latency, and status codes**.
3. With the Prometheus **custom metrics functionality** we released in [APISIX 3.3.0](https://api7.ai/blog/apache-apisix-3-0-11-highlights-of-open-source-api-gateway) version, you can now expose more granular metrics data for your APIs. This mechanism allows APISIX to periodically check whether **upstream nodes are healthy or not** and adjust the routing accordingly. It can help prevent failures and improve the system's reliability, which is critical for any API-based infrastructure. The results of these health checks are **incorporated in the metrics that the Prometheus plugin exposes**, providing a comprehensive and real-time view of your APIs' performance. For example, if you send a simple request to the APISIX Gateway `/metrics` endpoint, you can observe the collected monitoring data and health check result status of upstream nodes.

```
curl <http://127.0.0.1:9091/metrics>

...
# HELP apisix_upstream_status Upstream status from health check
# TYPE apisix_upstream_status gauge
apisix_upstream_status{name="/apisix/upstreams/1",ip="172.27.0.5",port="443"} 0
apisix_upstream_status{name="/apisix/upstreams/1",ip="172.27.0.5",port="80"} 1
apisix_upstream_status{name="/apisix/upstreams/1",ip="172.27.0.7",port="443"} 0
apisix_upstream_status{name="/apisix/upstreams/1",ip="172.27.0.7",port="80"} 1
```

> A value of 1 represents healthy and 0 means the upstream node is unhealthy.

4. You can also see the output of the health check statuses of upstream nodes on the **Prometheus dashboard**:

![APISIX Prometheus plugin on dashboard](https://static.api7.ai/uploads/2023/07/20/OGBtqbDq_output.png?imageMogr2/format/webp)

5. APISIX Prometheus plugin is configured to connect [Grafana](https://grafana.com/) automatically to visualize these metrics.

Just as importantly, it is also possible to enable prometheus to [collect metrics](https://apisix.apache.org/docs/apisix/plugins/prometheus/#how-to-enable-it-for-tcpudp) for TCP/UDP. Because observability at the transport layer provides insights into how data is transmitted between services in your infrastructure, and can be pivotal in diagnosing issues and optimizing performance.

## Do customization on the Prometheus plugin

In the context of APISIX, the Prometheus plugin exposes several metrics by default. These metrics are configurable, and the plugin can be extended to **add additional metrics** based on specific requirements. [API7.ai](https://api7.ai/) team is always on hand to **answer any questions** you may have about API health checking and monitoring and our engineers are **actively supporting new APISIX users** to onboard and help them to modify the APISIX default configs according to their needs.

### Real-world use case: Fast-Food Giant Improves Server Health Monitoring with APISIX and Prometheus Integration

Assume that there is a leading global fast-food chain with thousands of branches worldwide (henceforth referred to as "Company X") was keen on achieving *active-active server* configuration. Their goal was to ensure that all servers or data centers can share the workload in real time without causing service disruptions.

The company's technology team had automated the switching process between servers or data centers. However, there were occasions when business traffic varied between the active servers, and the load was unevenly distributed. Some servers were overloaded, and others received less traffic, leading to operational inefficiencies. During peak times, this led to server crashes and service disruptions, affecting the company's digital operations.

APISIX allowed the company to continually monitor the health of its upstream servers/data centers and automatically switch traffic based on **server health status**. If a server is considered unhealthy, the system can automatically switch to another healthy server to maintain uninterrupted service. In specific scenarios where the traffic was unusually small or too large for a server to handle, Prometheus's alerting mechanism triggered alarms. This integration facilitated Company X's operations team to monitor server health statuses, traffic loads, and other critical metrics proactively.

## Wrap up

To sum up, integrating APISIX and Prometheus to gain health check data metrics can significantly improve your metrics ecosystem, giving you a deeper understanding of your APIs' health status. This can ultimately lead to better business outcomes, such as improved operational efficiency, higher customer satisfaction, and increased revenue. So, if you're looking to level up your metrics ecosystem, consider leveraging the strength of APISIX and Prometheus.

### Related resources

- [Monitoring API Metrics: How to Ensure Optimal Performance of Your API?](https://api7.ai/blog/api7-portal-monitor-api-metrics)
- [Monitoring Microservices with Prometheus and Grafana](https://api7.ai/blog/introduction-to-monitoring-microservices)

### Recommended content

- [Implementing resilient applications with API Gateway (Health Check)](https://dev.to/apisix/implementing-resilient-applications-with-api-gateway-health-check-338c)

Tags:

[API Health](https://api7.ai/tags/api-health)

[Health Check Endpoint](https://api7.ai/tags/health-check-endpoint)

[Prometheus plugin](https://api7.ai/tags/prometheus-plugin)

[API Metrics](https://api7.ai/tags/api-metrics)

[API Monitoring](https://api7.ai/tags/api-monitoring)

Share article link

Share

Related Posts

[![6 Common API Gateway Monitoring Mistakes](https://static.api7.ai/uploads/2025/04/03/RM33lRp3_6-common-monitoring-mistakes.webp)](https://api7.ai/blog/6-api-gateway-monitoring-mistakes)

## [6 Common API Gateway Monitoring Mistakes](https://api7.ai/blog/6-api-gateway-monitoring-mistakes)

[![How to Implement Real-Time Alerts for API Gateway Failures](https://static.api7.ai/uploads/2025/04/03/K0dDbqc3_implement-real-time-alerts.webp)](https://api7.ai/blog/how-to-implement-real-time-alerts)

## [How to Implement Real-Time Alerts for API Gateway Failures](https://api7.ai/blog/how-to-implement-real-time-alerts)

Table of Contents

- [Why does this matter to businesses?](#why-does-this-matter-to-businesses)

- [How does an API gateway health check work?](#how-does-an-api-gateway-health-check-work)

- [Collecting health check data with the APISIX Prometheus plugin](#collecting-health-check-data-with-the-apisix-prometheus-plugin)

- [Do customization on the Prometheus plugin](#do-customization-on-the-prometheus-plugin)

  - [Real-world use case: Fast-Food Giant Improves Server Health Monitoring with APISIX and Prometheus Integration](#real-world-use-case-fast-food-giant-improves-server-health-monitoring-with-apisix-and-prometheus-integration)

- [Wrap up](#wrap-up)

  - [Related resources](#related-resources)
  - [Recommended content](#recommended-content)

## Related Posts

[![API Observability Guide: Metrics, Logs, Traces, and SLOs](https://static.api7.ai/uploads/2025/03/02/vOr9l1UC_Built-in-Observability.avif)](https://api7.ai/blog/api-observability-guide)

Technology

July 13, 2026

#### [API Observability Guide: Metrics, Logs, Traces, and SLOs](https://api7.ai/blog/api-observability-guide)

Learn how metrics, logs, traces, analytics, and SLOs help teams monitor, troubleshoot, and improve API reliability across distributed systems.

[API Observability](https://api7.ai/tags/api-observability)

[API Monitoring](https://api7.ai/tags/api-monitoring)

[OpenTelemetry](https://api7.ai/tags/opentelemetry)

[![Gateway Logging Best Practices for High-Performing APIs](https://static.api7.ai/uploads/2025/05/20/UaIH7FIt_gateway-logs-for-troubleshooting-apis-1.webp)](https://api7.ai/blog/gateway-logging-best-practices)

Technology

May 20, 2025

#### [Gateway Logging Best Practices for High-Performing APIs](https://api7.ai/blog/gateway-logging-best-practices)

Discover API gateway logging best practices to enhance observability, security, and performance.

[API Monitoring](https://api7.ai/tags/api-monitoring)

[![Gateway Logs: Your Secret Weapon for Troubleshooting APIs](https://static.api7.ai/uploads/2025/05/20/Z2ycgYGQ_gateway-logs-for-troubleshooting-apis.webp)](https://api7.ai/blog/gateway-logs-for-troubleshooting-apis)

Technology

May 20, 2025

#### [Gateway Logs: Your Secret Weapon for Troubleshooting APIs](https://api7.ai/blog/gateway-logs-for-troubleshooting-apis)

Learn best practices for structured logging, monitoring, and observability to enhance API reliability and performance.

[API Monitoring](https://api7.ai/tags/api-monitoring)
