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"))
}
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)
}
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)
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"}
Step 4: Set Up Vigilmon Monitoring
- Sign up at vigilmon.online — free, no credit card
- Click Add Monitor → HTTP Monitor
- URL:
https://your-echo-app.com/health - Check interval: 60 seconds
- Expected status code: 200
- Alert channels: email or webhook
- 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)
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
}
}
Docker Compose:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 5s
retries: 3
Summary
- Add
GET /healthto your Echo application - Return
200 OKwith 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)