DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Your Gin Framework API with Vigilmon (Free Uptime + Health Checks)

How to Monitor Your Gin Framework API with Vigilmon (Free Uptime + Health Checks)

Gin is one of the most popular HTTP frameworks in Go — fast, minimal, and widely used in production APIs. But Gin itself doesn't tell you when your service goes down. That's where external uptime monitoring comes in.

This guide shows you how to add a health check endpoint to your Gin app and connect it to Vigilmon for free, multi-region uptime monitoring.

Why External Monitoring Matters for Gin APIs

Your Gin server can silently fail in ways you won't notice:

  • The process crashes and systemd doesn't restart it
  • Memory leak causes the server to stop accepting connections
  • Your deployment pipeline broke a dependency
  • Your cloud provider's network had a blip

External monitoring pings your API from outside your infrastructure — so you find out before your users do.

Step 1: Add a Health Endpoint to Your Gin App

Gin makes this trivial:

package main

import (
    "net/http"
    "github.com/gin-gonic/gin"
)

func main() {
    r := gin.Default()

    // Health check endpoint
    r.GET("/health", func(c *gin.Context) {
        c.JSON(http.StatusOK, gin.H{
            "status": "ok",
        })
    })

    // Your actual routes
    r.GET("/api/users", handleGetUsers)

    r.Run(":8080")
}
Enter fullscreen mode Exit fullscreen mode

For a more detailed health check that verifies database connectivity:

func healthHandler(c *gin.Context) {
    // Check database connectivity
    if err := db.Ping(); err != nil {
        c.JSON(http.StatusServiceUnavailable, gin.H{
            "status": "error",
            "message": "database unreachable",
        })
        return
    }

    c.JSON(http.StatusOK, gin.H{
        "status":  "ok",
        "version": "1.0.0",
    })
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Verify Your Health Endpoint Locally

curl http://localhost:8080/health
# Expected: {"status":"ok"}
Enter fullscreen mode Exit fullscreen mode

Step 3: Deploy and Set Up Vigilmon

  1. Go to vigilmon.online and create a free account
  2. Click Add Monitor
  3. Enter your URL: https://your-api.com/health
  4. Set check interval: 60 seconds (free plan)
  5. Select regions: US East, EU West, Asia Pacific
  6. Set expected status: 200
  7. Add your alert contact (email or webhook)

Vigilmon will check your endpoint from multiple regions every minute and alert you within seconds if it goes down.

Step 4: Add Kubernetes Liveness Probes (Optional)

If you're running Gin on Kubernetes, use the same endpoint for liveness and readiness probes:

livenessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 10

readinessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 3
  periodSeconds: 5
Enter fullscreen mode Exit fullscreen mode

Monitoring Multiple Gin Services

If you run multiple Gin microservices, add a monitor for each:

Service Monitor URL
User API https://users-api.example.com/health
Payment API https://payments-api.example.com/health
Auth Service https://auth.example.com/health

Group them in Vigilmon under one project for a unified status view.

What Vigilmon Checks For You

  • HTTP status codes — alerts if your /health returns anything other than 200
  • Response time — tracks latency trends across regions
  • SSL certificate expiry — warns 30 days before your cert expires
  • Response content — optionally verify the response body contains "status":"ok"

Free Plan

Vigilmon's free plan covers:

  • Up to 10 monitors
  • 60-second check intervals
  • Multi-region checks (3+ regions)
  • Email alerts
  • 90-day uptime history

No credit card required.

Summary

  1. Add a GET /health endpoint to your Gin app
  2. Return 200 OK with a JSON status body
  3. Optionally check your database/dependencies in the handler
  4. Connect the URL to Vigilmon — free setup takes 2 minutes

You'll know the moment your Gin API goes down, before your users notice.

Top comments (0)