DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Your Symfony Application with Vigilmon

How to Monitor Your Symfony Application with Vigilmon

Symfony is one of the most popular PHP frameworks for building APIs, web apps, and complex enterprise systems. This guide shows how to add uptime monitoring to a Symfony application with Vigilmon.

Why Monitor a Symfony App?

Symfony apps can fail for many reasons:

  • PHP-FPM process exhaustion
  • Doctrine/ORM database connection failures
  • Cache backend (Redis/Memcached) timeouts
  • Queue worker (Messenger component) crashes
  • Third-party API dependencies timing out

Vigilmon checks your app every minute from multiple regions and alerts you the moment something breaks.

Quick Start

  1. Sign up at vigilmon.online
  2. Click Add Monitor
  3. Enter your Symfony app URL
  4. Set interval to 1 minute
  5. Add Slack or email alerts

No code changes needed for basic uptime monitoring.

Creating a Health Check Controller

For deeper monitoring, add a health check endpoint to your Symfony app:

<?php
// src/Controller/HealthController.php

namespace App\Controller;

use Doctrine\DBAL\Connection;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;

class HealthController
{
    public function __construct(
        private readonly Connection $connection
    ) {}

    #[Route('/health', name: 'health_check', methods: ['GET'])]
    public function check(): JsonResponse
    {
        try {
            $this->connection->executeQuery('SELECT 1');
            $dbStatus = 'ok';
        } catch (\Exception $e) {
            $dbStatus = 'error';
        }

        $status = $dbStatus === 'ok' ? 'ok' : 'degraded';
        $httpCode = $status === 'ok' ? 200 : 503;

        return new JsonResponse([
            'status' => $status,
            'database' => $dbStatus,
            'timestamp' => (new \DateTime())->format(\DateTime::ISO8601),
        ], $httpCode);
    }
}
Enter fullscreen mode Exit fullscreen mode

Add the route to your Symfony configuration if you're using YAML routing:

# config/routes.yaml
health_check:
    path: /health
    controller: App\Controller\HealthController::check
    methods: [GET]
Enter fullscreen mode Exit fullscreen mode

Then monitor https://yourapp.com/health in Vigilmon with keyword check "status":"ok".

Using Symfony's Health Check Bundle

The symfony/health-check-bundle (or liip/monitor-bundle) provides structured health checks:

composer require liip/monitor-bundle
Enter fullscreen mode Exit fullscreen mode

Register checks in config/packages/liip_monitor.yaml:

liip_monitor:
    checks:
        doctrine_dbal:
            connection: default
        redis:
            host: 127.0.0.1
            port: 6379
        php_extensions:
            - mbstring
            - pdo_mysql
Enter fullscreen mode Exit fullscreen mode

Access the health endpoint at /monitor/health and monitor it with Vigilmon.

Monitoring the Symfony Messenger Queue

If your app uses Symfony Messenger for async processing, your workers are critical infrastructure. Monitor them via a custom health check:

#[Route('/health/queue', name: 'health_queue', methods: ['GET'])]
public function queueHealth(
    \Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface $transport
): JsonResponse {
    try {
        // Check if we can enumerate pending messages
        $messageCount = iterator_count($transport->get());

        return new JsonResponse([
            'status' => 'ok',
            'pending_messages' => $messageCount,
        ]);
    } catch (\Exception $e) {
        return new JsonResponse([
            'status' => 'error',
            'message' => 'Queue unavailable',
        ], 503);
    }
}
Enter fullscreen mode Exit fullscreen mode

Monitoring Symfony on PHP-FPM

If you run Symfony behind Nginx + PHP-FPM, monitor the status page:

# nginx.conf
server {
    location /fpm-status {
        fastcgi_pass php-fpm:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        allow 127.0.0.1;
        deny all;
    }
}
Enter fullscreen mode Exit fullscreen mode

For Vigilmon monitoring from outside, use your app's health endpoint (which implicitly verifies PHP-FPM is working).

Monitoring Symfony on Docker

If your Symfony app runs in Docker:

# docker-compose.yml
services:
  app:
    image: your-symfony-app
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/health"]
      interval: 30s
      timeout: 10s
      retries: 3
Enter fullscreen mode Exit fullscreen mode

And set up Vigilmon to monitor the public URL of the container.

Cache and Session Monitoring

If your app uses Redis for cache and sessions, add a Redis check:

#[Route('/health/cache', name: 'health_cache')]
public function cacheHealth(\Symfony\Contracts\Cache\CacheInterface $cache): JsonResponse
{
    try {
        $item = $cache->getItem('health_check');
        $item->set('ok');
        $item->expiresAfter(60);
        $cache->save($item);

        return new JsonResponse(['status' => 'ok', 'cache' => 'redis']);
    } catch (\Exception $e) {
        return new JsonResponse(['status' => 'error', 'cache' => 'down'], 503);
    }
}
Enter fullscreen mode Exit fullscreen mode

SSL Certificate Monitoring

Vigilmon monitors your SSL certificate automatically. For Symfony apps using Let's Encrypt, you'll get alerts 30, 14, and 7 days before expiry — giving you time to renew before users see SSL errors.

Alert Configuration for Symfony

Recommended Vigilmon settings for production Symfony apps:

  • Check interval: 1 minute
  • Alert after: 2 consecutive failures (avoids single transient failures)
  • Timeout: 10 seconds
  • Alert channels: Slack + email for daytime; PagerDuty for 24/7

Summary

Symfony powers some of the most critical PHP applications on the web. Vigilmon ensures you're the first to know when your Symfony app goes down, not your users. Add a /health endpoint with database and cache checks, then monitor it in Vigilmon for complete coverage.

Start free at vigilmon.online.

Top comments (0)