Skip to content
RU

API uptime monitoring

Key idea:

API uptime ≠ landing-page uptime. Check a health endpoint (not /), expect 200 OK + json {"status":"ok"}, 10 s timeout, 60 s interval (no rarer — you will miss 5-min incidents). Multi-region checks rule out "your ISP is down, not our API". Alert after 3 consecutive fails, not the first.

Below: details, example, related terms, FAQ.

Check your site's headers →

Details

  • A /health endpoint should check DB + Redis + critical deps (not just `return "ok"`)
  • Do not check the root (/) — the landing page is slower, has caches — false-positive ↑
  • Expected code: 200, not 2xx (so a 301 is not counted as up)
  • Body check: assert "status: ok" substring — guards against accidental 200 with empty body
  • Multi-region: 3 points (ru-msk, eu-de, us-east) — alert only when 2+ register DOWN

Example

# A good /health endpoint (PHP)
<?php
header('Content-Type: application/json');
$checks = [
    'db'    => @$pdo->query('SELECT 1') !== false,
    'redis' => @$redis->ping() === '+PONG',
    'disk'  => disk_free_space('/') > 1024 * 1024 * 1024, // 1 GB free
];
$ok = !in_array(false, $checks, true);
http_response_code($ok ? 200 : 503);
echo json_encode(['status' => $ok ? 'ok' : 'degraded', 'checks' => $checks]);

# In enterno.io: monitor type=http, URL=https://api.example.com/health,
# expected_code=200, interval=60s, regions=ru-msk+eu-de, fail_threshold=3

Related

TL;DR: Monitoring API Uptime

To monitor API uptime effectively, implement an HTTP check that regularly pings the API endpoint, checks HTTP status codes, and manages timeouts. Tools like curl or monitoring services such as Pingdom can automate these checks. Aim for a response time under 500ms and configure alerts for any non-200 status codes to maintain optimal uptime.

Setting Up HTTP Checks for API Monitoring

Monitoring API uptime begins with setting up HTTP checks to continuously evaluate the API's availability. This involves sending periodic requests to the API endpoint to verify that it responds as expected. The following steps outline how to set up these checks:

  1. Choose a Monitoring Tool: Select a tool that supports HTTP checks. Popular options include Pingdom, Uptime Robot, and Datadog.
  2. Define the API Endpoint: Identify the URL of the API you want to monitor. For example, https://api.example.com/v1/status.
  3. Set Check Frequency: Determine how often the API should be checked. A common interval is every 1 minute for critical services.
  4. Configure Alerting: Set up alerts to notify you when the API returns a non-200 status code or exceeds a response time threshold.

For a practical implementation using curl, you can use the following command to check the status code:

curl -o /dev/null -s -w "%{http_code}" https://api.example.com/v1/status

This command retrieves the HTTP status code from the specified API endpoint without displaying the response body. A response code of 200 indicates that the API is functioning correctly.

Understanding Status Codes and Timeouts

When monitoring API uptime, understanding HTTP status codes and managing timeouts is crucial for effective monitoring. Here's a breakdown of the most relevant status codes and timeout configurations:

Common HTTP Status Codes

  • 200 OK: The request has succeeded. The API is functioning correctly.
  • 301 Moved Permanently: The resource has been moved to a new URL. Ensure that your monitoring tool follows redirects.
  • 400 Bad Request: The server could not understand the request due to invalid syntax. This may indicate issues with the API implementation.
  • 401 Unauthorized: Authentication is required and has failed or has not yet been provided. Monitor API key expiration and validity.
  • 404 Not Found: The server could not find the requested resource. This may indicate a problem with the endpoint URL.
  • 500 Internal Server Error: The server encountered a situation it doesn't know how to handle. This requires immediate attention.

Configuring Timeouts

Timeout settings are essential for ensuring that your monitoring tools do not wait indefinitely for a response. A commonly recommended timeout setting is 5 seconds. This can be configured in most monitoring tools and can also be set in curl commands as follows:

curl --max-time 5 -o /dev/null -s -w "%{http_code}" https://api.example.com/v1/status

This command sets the maximum time allowed for the API call to 5 seconds. If the API does not respond within this time, it will return an error. By monitoring these status codes and configuring appropriate timeouts, you can maintain a high level of API uptime and quickly react to any issues that arise.

Learn more

Frequently Asked Questions

Why 60 s interval, not 5 s?

API uptime means "works on average", not "works right now". A 5-sec check × millions = perf hit on the API + your monitor plan limits. 60 s with a 3-fail threshold = ~3-min incident detection — usually enough.

What if the health endpoint is always 200?

Useless — only verifies PHP-FPM is alive. A real health endpoint pings DB, Redis, S3, queues. Cost: ~10-50 ms per check. Benefit: catches partial degradations.

Is multi-region required?

No, but recommended for production. Single-region = one ISP network glitch kills your on-call at night. Multi-region + 2-of-3 rule = >95% accuracy.

Try the live tool that powered this guide

Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.