Monitory
← All guides

Guides

How to monitor an API endpoint

Check status, content, headers and speed of the endpoints your apps depend on, with rules, assertions and fewer false alarms.

A page that loads is not an API that works

An API can answer with a success code and still return the wrong data, or answer correctly but take ten seconds. Watching the homepage tells you nothing about the endpoints your apps depend on. Monitor them directly, with the same request your clients send.

What to check

  • The status code. Accept the codes you expect, such as 200, 201 or 2xx.
  • The content. Text the body must or must not contain, and JSON values such as data.status == ok or data.items.0.id exists.
  • Headers. Required response headers.
  • Speed. A maximum response time, and a warning when the endpoint suddenly becomes much slower than recent runs.

Set it up

  1. Enable the API check on the monitor and set the endpoint, an absolute URL or a path such as /api/health.
  2. Choose the method, headers and body. Valid JSON is sent as JSON, anything else as a form.
  3. Write your rules: expected status, text, headers and JSON assertions.
  4. Use {{timestamp}}, {{uuid}} or {{random}} in the endpoint, headers or body to get fresh values on every request, which bypasses caches.

Avoid false alarms

The check calls your endpoint every 5 minutes by default, and a failure is confirmed from other locations before it counts, so a single network hiccup does not alert you. You can also set how long the endpoint must fail before an alert, 2 minutes by default.

Choose what the endpoint proves

A good monitoring endpoint exercises what matters: a database read, a cache hit, a call to a dependency. A health endpoint that always returns ok only proves the web server is up.

Keep reading