Uptime Kuma Monitoring Internal Developer Platform คืออะไร
Uptime Kuma เป็น open-source self-hosted monitoring tool ที่ใช้ตรวจสอบ uptime ของ websites, APIs, DNS, TCP ports และ services ต่างๆ มี UI สวยงาม status pages และ notification ผ่านหลายช่องทาง Internal Developer Platform (IDP) คือแพลตฟอร์มภายในองค์กรที่ช่วย developers สร้าง deploy และจัดการ applications ได้ง่ายขึ้น ลด cognitive load และเพิ่ม productivity การรวม Uptime Kuma เข้ากับ IDP ช่วยให้ developers monitor services ของตัวเองได้ทันทีผ่าน self-service portal โดยไม่ต้องพึ่ง ops team
Uptime Kuma Setup & Features
# uptime_kuma.py — Uptime Kuma setup and features
import json
class UptimeKumaSetup:
DOCKER_SETUP = """
# docker-compose.yml — Uptime Kuma
version: '3'
services:
uptime-kuma:
image: louislam/uptime-kuma:1
container_name: uptime-kuma
volumes:
- ./data:/app/data
ports:
- "3001:3001"
restart: unless-stopped
# Run: docker compose up -d
# Access: http://localhost:3001
"""
MONITOR_TYPES = {
"http": "HTTP(S) — ตรวจสอบ URL response code + response time",
"tcp": "TCP Port — ตรวจสอบว่า port เปิดอยู่",
"ping": "Ping (ICMP) — ตรวจสอบว่า host reachable",
"dns": "DNS — ตรวจสอบ DNS resolution",
"docker": "Docker Container — ตรวจสอบ container status",
"grpc": "gRPC — ตรวจสอบ gRPC service health",
"keyword": "Keyword — ตรวจสอบว่า page มี/ไม่มี keyword ที่กำหนด",
"json_query": "JSON Query — ตรวจสอบ JSON response ด้วย JSONPath",
"push": "Push Monitor — service push heartbeat มาบอกว่ายังอยู่",
}
NOTIFICATIONS = {
"slack": "Slack — webhook notification",
"telegram": "Telegram — bot message",
"discord": "Discord — webhook",
"email": "Email (SMTP) — email alerts",
"webhook": "Generic Webhook — custom HTTP POST",
"pagerduty": "PagerDuty — incident management",
"teams": "Microsoft Teams — incoming webhook",
}
def show_setup(self):
print("=== Docker Setup ===")
print(self.DOCKER_SETUP)
def show_monitors(self):
print("=== Monitor Types ===")
for key, desc in self.MONITOR_TYPES.items():
print(f" [{key}] {desc}")
def show_notifications(self):
print(f"\n=== Notifications ===")
for key, desc in self.NOTIFICATIONS.items():
print(f" [{key}] {desc}")
setup = UptimeKumaSetup()
setup.show_setup()
setup.show_monitors()
setup.show_notifications()
IDP Architecture with Monitoring
# idp_architecture.py — Internal Developer Platform architecture
import json
class IDPArchitecture:
COMPONENTS = {
"portal": {
"name": "Developer Portal (Backstage/Port)",
"description": "Self-service UI — developers สร้าง services, ดู docs, monitor status",
"tools": ["Backstage (Spotify)", "Port", "Cortex", "OpsLevel"],
},
"templates": {
"name": "Service Templates (Golden Paths)",
"description": "Templates สำหรับสร้าง services ใหม่ — มี monitoring built-in",
"includes": ["Dockerfile", "CI/CD pipeline", "Uptime Kuma monitor config", "Alerts"],
},
"monitoring": {
"name": "Monitoring Layer (Uptime Kuma)",
"description": "Uptime monitoring ที่ auto-provision เมื่อ developer สร้าง service ใหม่",
"features": ["Auto-create monitors", "Status pages per team", "Alerting integration"],
},
"cicd": {
"name": "CI/CD Pipeline",
"description": "Automated build, test, deploy — พร้อม post-deploy health check",
"tools": ["GitHub Actions", "GitLab CI", "ArgoCD", "Flux"],
},
"infrastructure": {
"name": "Infrastructure Layer",
"description": "Kubernetes, cloud resources — managed ผ่าน IaC",
"tools": ["Terraform", "Crossplane", "Pulumi", "CDK"],
},
}
def show_architecture(self):
print("=== IDP Architecture ===\n")
for key, comp in self.COMPONENTS.items():
print(f"[{comp['name']}]")
print(f" {comp['description']}")
if 'tools' in comp:
print(f" Tools: {', '.join(comp['tools'])}")
print()
arch = IDPArchitecture()
arch.show_architecture()
Python Uptime Kuma API
# kuma_api.py — Uptime Kuma API integration
import json
class KumaAPI:
CODE = """
# kuma_client.py — Uptime Kuma API client for IDP integration
import requests
import json
from uptime_kuma_api import UptimeKumaApi
class KumaIDPClient:
def __init__(self, url="http://localhost:3001", username="admin", password=""):
self.api = UptimeKumaApi(url)
self.api.login(username, password)
def create_service_monitor(self, service_name, url, team, interval=60):
'''Auto-create monitor when developer deploys new service'''
monitor = self.api.add_monitor(
type="http",
name=f"[{team}] {service_name}",
url=url,
interval=interval,
retryInterval=30,
maxretries=3,
accepted_statuscodes=["200-299"],
notificationIDList=[1], # Default notification channel
tags=[
{"tag_id": 1, "value": team},
{"tag_id": 2, "value": service_name},
],
)
return monitor
def create_status_page(self, team, services):
'''Create team status page'''
groups = [{
"name": f"{team} Services",
"monitorList": [{"id": s["monitor_id"]} for s in services],
}]
page = self.api.add_status_page(
slug=f"{team}-status",
title=f"{team} Service Status",
)
self.api.save_status_page(
slug=f"{team}-status",
publicGroupList=groups,
)
return page
def get_service_uptime(self, monitor_id, hours=24):
'''Get uptime percentage for a service'''
beats = self.api.get_monitor_beats(monitor_id, hours)
total = len(beats)
up = sum(1 for b in beats if b['status'] == 1)
uptime_pct = (up / total * 100) if total > 0 else 0
avg_latency = sum(b.get('ping', 0) for b in beats) / total if total > 0 else 0
return {
'monitor_id': monitor_id,
'uptime_pct': round(uptime_pct, 3),
'avg_latency_ms': round(avg_latency, 1),
'total_checks': total,
'downtime_events': total - up,
}
def bulk_provision(self, services_config):
'''Bulk provision monitors from IDP config'''
results = []
for svc in services_config:
try:
monitor = self.create_service_monitor(
service_name=svc['name'],
url=svc['health_url'],
team=svc['team'],
interval=svc.get('interval', 60),
)
results.append({'service': svc['name'], 'status': 'created', 'id': monitor['monitorID']})
except Exception as e:
results.append({'service': svc['name'], 'status': 'error', 'error': str(e)})
return results
# client = KumaIDPClient("http://kuma:3001", "admin", "password")
# client.create_service_monitor("payment-api", "https://api.example.com/health", "payments")
"""
def show_code(self):
print("=== Kuma API Client ===")
print(self.CODE[:600])
api = KumaAPI()
api.show_code()
IDP Service Template
# service_template.py — IDP service template with monitoring
import json
class ServiceTemplate:
BACKSTAGE_TEMPLATE = """
# backstage-template.yaml — Backstage template with Uptime Kuma
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: microservice-with-monitoring
title: Microservice with Auto-Monitoring
description: Create a new microservice with built-in Uptime Kuma monitoring
spec:
owner: platform-team
type: service
parameters:
- title: Service Details
properties:
serviceName:
title: Service Name
type: string
team:
title: Team
type: string
enum: [payments, users, search, orders]
port:
title: Service Port
type: number
default: 8080
monitorInterval:
title: Monitor Interval (seconds)
type: number
default: 60
steps:
- id: scaffold
name: Scaffold Service
action: fetch:template
input:
url: ./skeleton
values:
serviceName: }
team: }
- id: create-repo
name: Create Repository
action: publish:github
input:
repoUrl: github.com?owner=myorg&repo=}
- id: create-monitor
name: Create Uptime Monitor
action: http:backstage:request
input:
method: POST
path: /api/kuma/monitors
body:
name: }
url: https://}.internal/health
team: }
interval: }
- id: register
name: Register in Catalog
action: catalog:register
"""
def show_template(self):
print("=== Backstage Template ===")
print(self.BACKSTAGE_TEMPLATE[:600])
def golden_path(self):
print(f"\n=== Golden Path: New Service ===")
steps = [
"1. Developer เข้า Backstage Portal → New Service",
"2. เลือก template 'Microservice with Monitoring'",
"3. กรอกชื่อ service, team, port",
"4. Backstage scaffold code + create repo + create CI/CD",
"5. Auto-create Uptime Kuma monitor + status page",
"6. Developer push code → auto-deploy → monitoring active",
]
for s in steps:
print(f" {s}")
template = ServiceTemplate()
template.show_template()
template.golden_path()
Dashboard & Alerting
# dashboard.py — Monitoring dashboard and alerting
import json
import random
class MonitoringDashboard:
ALERT_CONFIG = """
# alert_config.py — Alert configuration for IDP
ALERT_RULES = {
"service_down": {
"condition": "monitor status == DOWN for 3 consecutive checks",
"severity": "critical",
"notify": ["slack:#incidents", "pagerduty", "email:oncall@team.com"],
},
"high_latency": {
"condition": "response_time > 2000ms for 5 minutes",
"severity": "warning",
"notify": ["slack:#monitoring"],
},
"cert_expiring": {
"condition": "SSL certificate expires within 14 days",
"severity": "warning",
"notify": ["slack:#security", "email:security@team.com"],
},
"uptime_sla": {
"condition": "monthly uptime < 99.9%",
"severity": "high",
"notify": ["slack:#sre", "pagerduty"],
},
}
"""
def show_alerts(self):
print("=== Alert Configuration ===")
print(self.ALERT_CONFIG[:500])
def sample_dashboard(self):
print(f"\n=== Team Dashboard ===")
services = [
{"name": "Payment API", "status": "UP", "uptime": f"{random.uniform(99.5, 100):.3f}%", "latency": f"{random.randint(15, 80)}ms"},
{"name": "User Service", "status": "UP", "uptime": f"{random.uniform(99.8, 100):.3f}%", "latency": f"{random.randint(10, 50)}ms"},
{"name": "Search API", "status": "UP", "uptime": f"{random.uniform(99.0, 100):.3f}%", "latency": f"{random.randint(30, 150)}ms"},
{"name": "Order Service", "status": random.choice(["UP", "UP", "DOWN"]), "uptime": f"{random.uniform(98.0, 100):.3f}%", "latency": f"{random.randint(20, 100)}ms"},
]
print(f" {'Service':<18} {'Status':<8} {'Uptime':<10} {'Latency'}")
for s in services:
print(f" {s['name']:<18} {s['status']:<8} {s['uptime']:<10} {s['latency']}")
dash = MonitoringDashboard()
dash.show_alerts()
dash.sample_dashboard()
FAQ - คำถามที่พบบ่อย
Q: Uptime Kuma กับ Datadog/New Relic ต่างกันอย่างไร?
A: Uptime Kuma: ฟรี, self-hosted, เน้น uptime monitoring + status pages — ง่าย เบา Datadog/New Relic: paid SaaS, full observability (APM, logs, traces, metrics) — ครบครัน ใช้ Uptime Kuma: สำหรับ basic uptime monitoring, status pages, ทีมเล็ก/budget จำกัด ใช้ Datadog: สำหรับ full observability, enterprise, ต้องการ APM + distributed tracing รวมกัน: Uptime Kuma สำหรับ external monitoring + Datadog สำหรับ internal observability
Q: IDP จำเป็นสำหรับทุกองค์กรไหม?
A: ไม่จำเป็นสำหรับทุกองค์กร: เหมาะ: 50+ developers, หลาย teams, หลาย services (microservices) ไม่จำเป็น: ทีมเล็ก < 10 คน, monolith, ไม่มี DevOps complexity เริ่มจาก: documentation + templates + basic automation แล้วค่อย evolve เป็น full IDP ROI: ลด onboarding time, ลด cognitive load, เพิ่ม developer velocity
Q: Uptime Kuma รองรับ High Availability ไหม?
A: ไม่ native — Uptime Kuma เป็น single instance application แก้ไข: ใช้ Docker + volume backup + health check restart หรือ: รัน 2 instances คนละ location → ดู external availability จากหลายมุม สำหรับ HA monitoring: พิจารณา Prometheus + Alertmanager, Grafana OnCall
Q: Auto-provision monitors ทำได้จริงไหม?
A: ได้ — ใช้ uptime-kuma-api Python library หรือ Uptime Kuma REST API วิธี: CI/CD pipeline สร้าง monitor หลัง deploy สำเร็จ หรือ Backstage plugin เรียก API เมื่อ scaffold service ใหม่ ข้อควรระวัง: จัดการ monitor lifecycle — ลบ monitor เมื่อ decommission service อย่าลืม: tag monitors ด้วย team + service name สำหรับ filtering
