DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor GraphQL APIs with Vigilmon

How to Monitor GraphQL APIs with Vigilmon

GraphQL APIs use a single endpoint (/graphql) for all operations — but that single endpoint can fail in ways that are invisible to standard uptime monitors. This guide explains how to monitor GraphQL APIs effectively with Vigilmon.

The Challenge with GraphQL Monitoring

A standard uptime monitor that sends a GET request to /graphql will usually see a 200 OK — even when the API is completely broken — because GraphQL servers often return 200 for all responses, including errors:

{
  "errors": [
    {
      "message": "Database connection failed",
      "locations": [{"line": 1, "column": 1}]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

HTTP status 200, but the API is down.

The solution: use a dedicated introspection query or a lightweight ping query as your health check, and verify the response body — not just the HTTP status code.

Option 1: Health Query Approach (Recommended)

Add a dedicated health query to your GraphQL schema:

type Query {
  _health: HealthStatus!
}

type HealthStatus {
  status: String!
  timestamp: String!
}
Enter fullscreen mode Exit fullscreen mode
// Resolver
const resolvers = {
  Query: {
    _health: async (_, __, context) => {
      // Optionally check database
      await context.db.raw('SELECT 1');

      return {
        status: 'ok',
        timestamp: new Date().toISOString(),
      };
    },
  },
};
Enter fullscreen mode Exit fullscreen mode

Now you can monitor with a POST request to /graphql with this body:

{"query": "{ _health { status timestamp } }"}
Enter fullscreen mode Exit fullscreen mode

The expected response:

{"data":{"_health":{"status":"ok","timestamp":"2026-08-04T..."}}}}
Enter fullscreen mode Exit fullscreen mode

Option 2: Introspection-Based Monitoring

If you can't modify the schema, use a minimal introspection query that any valid GraphQL server answers:

{"query": "{__typename}"}
Enter fullscreen mode Exit fullscreen mode

Expected response:

{"data":{"__typename":"Query"}}
Enter fullscreen mode Exit fullscreen mode

This is the lightest possible GraphQL query. If it fails, your GraphQL server is down.

Note: Some production schemas disable introspection. If yours does, create a health query (Option 1) or use a lightweight real query.

Setting Up a Vigilmon Monitor for GraphQL

Vigilmon supports custom POST requests with JSON bodies and response body matching:

  1. Log in at vigilmon.online
  2. Click Add Monitor
  3. Set URL to https://api.yourapp.com/graphql
  4. Set Monitor Type to HTTP/HTTPS
  5. Set HTTP Method to POST
  6. Set Request Body (Content-Type: application/json):
   {"query": "{ _health { status } }"}
Enter fullscreen mode Exit fullscreen mode

Or for introspection:

   {"query": "{__typename}"}
Enter fullscreen mode Exit fullscreen mode
  1. Set Expected Status Code to 200
  2. Set Response Body Must Contain to "status":"ok" (for health query) or "__typename" (for introspection)
  3. Add any required Request Headers (e.g., Authorization: Bearer your-token if the health query requires auth)
  4. Click Save

Handling Authentication

If your GraphQL health query requires authentication:

Bearer Token (Static)

Add a request header in Vigilmon:

Authorization: Bearer your-static-monitor-token
Enter fullscreen mode Exit fullscreen mode

Generate a dedicated monitoring service account token with minimal permissions.

API Key

X-API-Key: your-monitoring-api-key
Enter fullscreen mode Exit fullscreen mode

Anonymous Health Endpoint

The cleanest approach: make your _health query public (no authentication required) but return only non-sensitive status information. This avoids storing credentials in your monitoring tool.

Monitor Multiple GraphQL Operations

For a production GraphQL API, consider monitoring more than just the health query:

Monitor the Schema Introspection

{"query": "{__schema{queryType{name}}}"}
Enter fullscreen mode Exit fullscreen mode

Verifies the schema is complete and not partially broken.

Monitor a Real Query

For critical queries (e.g., product listings, user profile), create a monitor that executes a lightweight version of the real query:

{"query": "{ products(limit: 1) { id name } }"}
Enter fullscreen mode Exit fullscreen mode

Set Response Body Must Contain: "products" — verifies the resolver chain works end-to-end including database access.

GraphQL Subscriptions Monitoring

Vigilmon monitors HTTP/HTTPS endpoints, not WebSocket connections. For GraphQL subscriptions (WebSocket-based), monitor the underlying WebSocket server's HTTP upgrade endpoint:

https://api.yourapp.com/graphql
Enter fullscreen mode Exit fullscreen mode

Alternatively, monitor a REST health endpoint alongside your GraphQL API.

Multi-Region Consensus for GraphQL

Vigilmon's multi-region consensus model is especially valuable for GraphQL APIs:

  • GraphQL resolver chains can have partial failures (some resolvers work, some don't)
  • Single-region checks might miss transient resolver failures
  • Multi-region checks from 3+ global probes confirm that your API is genuinely unavailable, not just slow for one probe's network path

An alert fires only when 3+ independent probe nodes simultaneously report failure — eliminating false alerts from transient network issues.

Example: Full GraphQL Monitoring Stack

Monitor Endpoint Body Checks
Health query /graphql {"query": "{ _health { status } }"} Resolvers + DB
Schema check /graphql {"query": "{__typename}"} Schema integrity
Critical query /graphql {"query": "{ products(limit:1) { id } }"} Product resolver
SSL cert /graphql Auto via HTTPS monitor

Setting Up Alerts

  1. In Vigilmon → Alert ChannelsAdd Channel
  2. Add Email, Slack, PagerDuty, or custom webhook
  3. Configure: "Alert after 2 consecutive failures from 2+ regions"

When your GraphQL API starts returning errors (or truly goes unreachable), you'll know within 2 minutes — before users start filing tickets.

Heartbeat Monitoring for GraphQL Subscriptions Workers

If your app uses a separate process to maintain subscription connections or process GraphQL queues, add a Vigilmon heartbeat:

// In your subscription worker, after each successful cycle
await fetch(`https://vigilmon.online/api/heartbeat/${process.env.VIGILMON_HEARTBEAT_ID}`);
Enter fullscreen mode Exit fullscreen mode

Conclusion

GraphQL's single-endpoint architecture makes standard uptime monitoring misleading — a 200 OK doesn't mean your resolvers work. The right approach: monitor with a POST request that executes a real query and verify the response body contains valid data.

Vigilmon's support for custom POST bodies, response body matching, and custom headers makes it well-suited for GraphQL API monitoring.

Start monitoring your GraphQL API with Vigilmon — free tier, 2-minute setup.

Top comments (0)