DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Your Contentful CMS APIs with Vigilmon

Contentful is the leading headless CMS powering thousands of Jamstack and enterprise sites. When your Contentful Content Delivery API goes down or slows down, your website renders blank content, your SSR responses time out, and your users see broken pages.

This guide shows you how to monitor your Contentful-backed site with Vigilmon—a free external uptime monitor that catches API problems before your users do.

What Can Go Wrong with Contentful?

Contentful is reliable, but here's what can still break:

  1. Content Delivery API (CDA) outages — your site's main data source goes dark
  2. Content Preview API issues — your preview environments stop working
  3. GraphQL API timeouts — complex queries time out under load
  4. Webhook delivery failures — your build system never gets notified of content changes
  5. CDN edge node problems — content loads from origin instead of edge (much slower)
  6. Rate limiting — spikes in traffic hit CDA rate limits, causing 429 errors

None of these show up on your Contentful dashboard—they need to be caught from the outside.

Creating a Contentful Health Check Endpoint

The cleanest approach is a dedicated health check on your application that probes Contentful:

Next.js API Route

// pages/api/health.js or app/api/health/route.js
import { createClient } from 'contentful';

const client = createClient({
  space: process.env.CONTENTFUL_SPACE_ID,
  accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
});

export default async function handler(req, res) {
  try {
    // Lightweight check: fetch a single entry
    const response = await client.getEntries({
      content_type: 'blogPost', // use your content type
      limit: 1,
    });

    res.status(200).json({
      status: 'healthy',
      contentful: 'connected',
      entryCount: response.total,
      timestamp: new Date().toISOString(),
    });
  } catch (error) {
    res.status(500).json({
      status: 'unhealthy',
      error: error.message,
      timestamp: new Date().toISOString(),
    });
  }
}
Enter fullscreen mode Exit fullscreen mode

Gatsby / Static Site Health Check

For static Gatsby sites, add a serverless function:

// netlify/functions/health.js
const { createClient } = require('contentful');

exports.handler = async (event, context) => {
  const client = createClient({
    space: process.env.CONTENTFUL_SPACE_ID,
    accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
  });

  try {
    await client.getSpace();
    return {
      statusCode: 200,
      body: JSON.stringify({ status: 'healthy', contentful: 'connected' }),
    };
  } catch (error) {
    return {
      statusCode: 500,
      body: JSON.stringify({ status: 'unhealthy', error: error.message }),
    };
  }
};
Enter fullscreen mode Exit fullscreen mode

Monitoring the Contentful API Directly

You can also monitor the Contentful Content Delivery API directly (for public content):

https://cdn.contentful.com/spaces/{SPACE_ID}/environments/master/entries?limit=1
Enter fullscreen mode Exit fullscreen mode

Add your access token as a query param:

https://cdn.contentful.com/spaces/abc123/environments/master/entries?limit=1&access_token=YOUR_TOKEN
Enter fullscreen mode Exit fullscreen mode

Set up a Vigilmon HTTP check:

  • URL: The endpoint above
  • Method: GET
  • Expected status: 200
  • Keyword check: "sys" (present in every Contentful response)
  • Timeout: 10 seconds

Setting Up Vigilmon Monitors for Contentful

  1. Go to vigilmon.online and create a free account
  2. Create Monitor 1: Your Website

    • URL: https://yoursite.com
    • Type: HTTP
    • Method: GET
    • Keyword: Something from your homepage content
  3. Create Monitor 2: Health Check Endpoint

    • URL: https://yoursite.com/api/health
    • Type: HTTP
    • Expected status: 200
    • Keyword: "healthy"
  4. Create Monitor 3: Contentful CDA (optional)

    • URL: https://cdn.contentful.com/spaces/YOUR_SPACE/entries?limit=1&access_token=YOUR_TOKEN
    • Type: HTTP
    • Expected status: 200
  5. Set up alerts:

    • Email for immediate notification
    • Slack webhook for team notification

Monitoring Contentful Webhooks

Contentful webhooks trigger your build pipeline when content changes. If webhooks fail silently, your content updates never reach production.

To monitor webhook reliability, add a webhook endpoint that logs receipt and exposes a recent-activity check:

// pages/api/contentful-webhook.js
import { appendFileSync } from 'fs';

export default function handler(req, res) {
  if (req.method === 'POST') {
    // Log webhook receipt
    const timestamp = new Date().toISOString();
    appendFileSync('/tmp/webhook-log.txt', `${timestamp}\n`);
    res.status(200).json({ received: true, timestamp });
  } else {
    // Health check - show last webhook time
    res.status(200).json({ status: 'webhook endpoint active' });
  }
}
Enter fullscreen mode Exit fullscreen mode

Contentful-Specific Alert Thresholds

Scenario Recommended Setting
CDA API timeout 10 seconds
GraphQL queries 15 seconds
Check frequency 1 minute
Alert after 2 consecutive failures
Multi-region Yes (US, EU required)

What Breaks When Contentful Is Down

Understanding the impact helps you prioritize monitoring:

App Type Contentful Down Impact
Next.js ISR Stale content served from cache
Next.js SSR Every page request fails with 500
Gatsby static Build fails, stale content served
React SPA (client-fetch) White screen on load
Nuxt SSR 500 errors on page load

For SSR applications, Contentful outages = immediate user-facing errors. Vigilmon will alert you within 60 seconds.

Monitor Your Whole Contentful Stack

Vigilmon Monitors:
├── Main Website
│   └── https://yoursite.com → HTTP 200, keyword check
├── API Health Check
│   └── https://yoursite.com/api/health → JSON "healthy"
├── Preview Environment
│   └── https://preview.yoursite.com → HTTP 200
└── Contentful CDA (direct)
    └── https://cdn.contentful.com/spaces/... → HTTP 200
Enter fullscreen mode Exit fullscreen mode

Get started free at vigilmon.online — 5 monitors free, no credit card required.

Top comments (0)