DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Your Echo Framework Application with Vigilmon

How to Monitor Your Echo Framework Application with Vigilmon

Echo is a high-performance, minimalist Go web framework. It's used in everything from small personal projects to large-scale APIs. This guide shows you how to add proper health monitoring to any Echo application using Vigilmon.

The Problem with Internal Monitoring Only

Echo doesn't ship with built-in health dashboards, and internal process checks miss a key scenario: what if the server is running but not accepting connections? Or your load balancer stopped routing traffic? External monitoring catches what internal checks miss.

Step 1: Add a Health Check Endpoint

Echo makes routing straightforward:

package main

import (
    "net/http"
    "github.com/labstack/echo/v4"
    "github.com/labstack/echo/v4/middleware"
)

func main() {
    e := echo.New()
    e.Use(middleware.Logger())

    // Health check
    e.GET("/health", func(c echo.Context) error {
        return c.JSON(http.StatusOK, map[string]string{
            "status": "ok",
        })
    })

    e.Logger.Fatal(e.Start(":8080"))
}
Enter fullscreen mode Exit fullscreen mode

For a more thorough check with dependency validation:

type HealthResponse struct {
    Status   string `json:"status"`
    Database string `json:"database"`
    Cache    string `json:"cache"`
}

func healthCheck(c echo.Context) error {
    resp := HealthResponse{Status: "ok"}

    if err := db.Ping(); err != nil {
        resp.Database = "unreachable"
        return c.JSON(http.StatusServiceUnavailable, resp)
    }
    resp.Database = "ok"

    if err := redisClient.Ping(c.Request().Context()).Err(); err != nil {
        resp.Cache = "unreachable"
        return c.JSON(http.StatusServiceUnavailable, resp)
    }
    resp.Cache = "ok"

    return c.JSON(http.StatusOK, resp)
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Group Health Routes (Best Practice)

Keep health endpoints separate from your API routes:

// Health group — no auth middleware
health := e.Group("/")
health.GET("health", healthCheck)
health.GET("ready", readinessCheck)

// API group — with auth middleware
api := e.Group("/api", middleware.JWT(secret))
api.GET("/users", getUsers)
Enter fullscreen mode Exit fullscreen mode

Step 3: Test Locally

# Start your Echo server
go run main.go

# Test health endpoint
curl http://localhost:8080/health
# {"status":"ok","database":"ok","cache":"ok"}
Enter fullscreen mode Exit fullscreen mode

Step 4: Set Up Vigilmon Monitoring

  1. Sign up at vigilmon.online — free, no credit card
  2. Click Add MonitorHTTP Monitor
  3. URL: https://your-echo-app.com/health
  4. Check interval: 60 seconds
  5. Expected status code: 200
  6. Alert channels: email or webhook
  7. Select monitoring regions for global coverage

Vigilmon pings your endpoint from multiple geographic regions — if any region reports your Echo app is down, you get an alert immediately.

Echo-Specific Tip: Middleware Exclusions

Make sure your health endpoint bypasses rate limiting and authentication middleware:

e := echo.New()

// Rate limit applies to everything...
e.Use(middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(20)))

// ...but skip it for health
e.GET("/health", healthCheck, skipMiddleware)
Enter fullscreen mode Exit fullscreen mode

Or use route groups where the health route is registered before middleware is applied.

Deployment Platform Integration

Most platforms that run Echo apps support health check configuration:

Railway:

{
  "deploy": {
    "healthcheckPath": "/health",
    "healthcheckTimeout": 10
  }
}
Enter fullscreen mode Exit fullscreen mode

Docker Compose:

healthcheck:
  test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
  interval: 30s
  timeout: 5s
  retries: 3
Enter fullscreen mode Exit fullscreen mode

Summary

  • Add GET /health to your Echo application
  • Return 200 OK with a JSON body — check real dependencies
  • Skip auth/rate-limit middleware on the health route
  • Connect the URL to Vigilmon for external monitoring

Echo is fast. Your monitoring should be too.

Top comments (0)