Menu

Post image 1
Post image 2
1 / 2
0

Monitoring and Alerting for Video Platform Infrastructure with Go

DEV Community·ahmet gedik·23 days ago
#ZhKWo5k7
Reading 0:00
15s threshold

Why Roll Your Own Monitoring? Managed monitoring like Datadog is excellent — and expensive. For a self-hosted video platform like TopVideoHub , a 200-line Go binary can cover 90% of what you need: uptime checks, latency histograms, error rate alerts, and a Grafana dashboard wired to Prometheus. Health Check Endpoints package main import ( "database/sql" "encoding/json" "net/http" "time" ) type HealthStatus struct { Status string `json:"status"` Checks map [ string ] string `json:"checks"` Uptime string `json:"uptime"` Ts time . Time `json:"ts"` } var startTime = time . Now () func healthHandler ( db * sql . DB ) http . HandlerFunc { return func ( w http . ResponseWriter , r * http . Request ) { checks := map [ string ] string {} overall := "ok" if err := db . Ping (); err != nil { checks [ "database" ] = "error: " + err . Error () overall = "degraded" } else { checks [ "database" ] = "ok" } status := HealthStatus { Status : overall , Checks : checks , Uptime : time . Since ( startTime ) . Round ( time .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More