DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Your Payload CMS API with Vigilmon

How to Monitor Your Payload CMS API with Vigilmon

Payload CMS is a TypeScript-first headless CMS built on top of Express and MongoDB (or Postgres). It's rapidly gaining adoption for its code-first approach and powerful querying capabilities. If your Next.js app, e-commerce store, or custom frontend depends on the Payload API, you need uptime monitoring. Here's how to set it up with Vigilmon.

Payload API Endpoints to Monitor

Endpoint Purpose
https://your-payload.com/api/globals/settings Global settings (often public)
https://your-payload.com/api/posts?limit=1 Collection endpoint
https://your-payload.com/admin Admin panel

Step 1: Add a Custom Health Endpoint to Payload

Payload doesn't have a built-in /_health endpoint (unlike Strapi or Directus), so you need to add one. In Payload v2+:

// payload.config.ts
import { buildConfig } from 'payload/config'

export default buildConfig({
  // ... your config
  endpoints: [
    {
      path: '/health',
      method: 'get',
      root: true, // Accessible at /health, not /api/health
      handler: async (req, res) => {
        try {
          // Check database connectivity
          await req.payload.find({
            collection: 'users',
            limit: 0,
          })
          res.status(200).json({ status: 'ok', db: 'connected' })
        } catch (error) {
          res.status(503).json({ status: 'error', message: error.message })
        }
      }
    }
  ]
})
Enter fullscreen mode Exit fullscreen mode

Now GET https://your-payload.com/health returns 200 when Payload and MongoDB/Postgres are healthy.

Step 2: Set Up Vigilmon

  1. Sign up at vigilmon.online (free, no credit card)
  2. Add Monitor → enter https://your-payload.com/health
  3. Expected status: 200
  4. Check interval: 5 minutes (free) or 1 minute (paid)
  5. Enable multi-region consensus: 2+ regions must confirm failure before alerting

Step 3: Monitor the Admin Panel Separately

Payload's admin panel is a React app. It can fail independently if Webpack bundles are corrupted or the admin build is missing. Add a second monitor:

URL: https://your-payload.com/admin
Expected: 200
Enter fullscreen mode Exit fullscreen mode

Deploying Payload: Platform-Specific Tips

Vercel (Payload v3 with Next.js)

Payload v3 runs inside Next.js — monitor your Next.js app URL and the /health route.

// app/health/route.ts (Next.js App Router)
import { getPayloadHMR } from '@payloadcms/next/utilities'
import config from '@payload-config'

export async function GET() {
  try {
    const payload = await getPayloadHMR({ config })
    await payload.find({ collection: 'posts', limit: 0 })
    return Response.json({ status: 'ok' })
  } catch (error) {
    return Response.json({ status: 'error' }, { status: 503 })
  }
}
Enter fullscreen mode Exit fullscreen mode

Railway

Deploy Payload as a Node.js service. Set health check path to /health in Railway service settings.

Render

Set the health check path in the Render service dashboard. Render will restart your service if the health check fails — complementing Vigilmon's alerting.

Common Failure Scenarios

Failure Symptom Vigilmon Catches?
MongoDB connection lost 503 from health route ✅ Yes
Payload process crash 502 Bad Gateway ✅ Yes
Out of memory OOM kill, 502 ✅ Yes
Admin build missing 404 on /admin ✅ Yes
JWT secret misconfiguration 401 errors ⚠️ Only if auth endpoint monitored

Webhook Alerts for Your Team

{
  "url": "https://hooks.slack.com/services/YOUR/WEBHOOK",
  "events": ["down", "up"]
}
Enter fullscreen mode Exit fullscreen mode

Public Status Page

Share with your content team:

https://vigilmon.online/status/your-payload-cms
Enter fullscreen mode Exit fullscreen mode

Conclusion

Payload CMS is a powerful choice for TypeScript-first projects. With a custom health endpoint and Vigilmon:

  • ✅ Database connectivity monitoring (MongoDB or Postgres)
  • ✅ Multi-region consensus prevents false alerts
  • ✅ Free tier: 5 monitors, no credit card
  • ✅ Public status page for your content team

Start monitoring your Payload CMS at vigilmon.online.

Top comments (0)