FastAPI ऐप्स के लिए स्टेटस पेज और अपटाइम मॉनिटरिंग
FastAPI endpoints और async workers मॉनिटर करें। JSON-path assertions FastAPI health schemas के साथ मेल खाती हैं। Hosted या headless।
FastAPI के लिए स्टेटस पेज लॉन्च करने के तीन तरीके
नियंत्रण का स्तर चुनें — zero-code, low-code, या पूर्ण headless।
Hosted
अपना FastAPI endpoint जोड़ें, CNAME को status.yourdomain.com पर point करें, हो गया। 5 मिनट में।
Headless
Public API का उपयोग करके अपनी FastAPI ऐप के अंदर अपनी UI बनाएं। डिज़ाइन और ब्रांडिंग पर पूरा नियंत्रण।
API देखेंएम्बेडेड badges
अपने README या landing page में SVG uptime और status badges डालें। हर 5 मिनट में auto-update।
इस health endpoint को अपनी FastAPI ऐप में जोड़ें
Copy, paste, PulseAPI को URL पर point करें। स्वस्थ पर 200, degraded पर 503 return करता है।
from fastapi import APIRouter, Response
from sqlalchemy import text
from .db import engine
from .redis import redis
router = APIRouter()
@router.get("/health")
async def health(response: Response) -> dict:
checks: dict[str, str] = {}
try:
async with engine.connect() as conn:
await conn.execute(text("SELECT 1"))
checks["database"] = "ok"
except Exception:
checks["database"] = "fail"
try:
pong = await redis.ping()
checks["cache"] = "ok" if pong else "fail"
except Exception:
checks["cache"] = "fail"
healthy = all(v == "ok" for v in checks.values())
response.status_code = 200 if healthy else 503
return {"status": "healthy" if healthy else "degraded", **checks}Router को main app पर mount करें। Partial failure पर 503 return करें ताकि degraded mark हो। JSON-path assertions returned schema पर natively काम करती हैं।
FastAPI ऐप्स में क्या टूटता है — और कैसे पकड़ें
Async deadlocks
भूला `await` या async context में sync call event loop को lock करता है। Response-time spikes यह तुरंत दिखाते हैं।
Pydantic v1→v2 migration bugs
Model validation changes चुपचाप endpoints तोड़ते हैं। JSON body assertions schema regressions पकड़ती हैं।
Upstream outages
Dependencies down होने पर endpoints 502 देते हैं। PulseAPI users के report से पहले alert करता है।
हमारा स्टेटस पेज पसंद नहीं? FastAPI में अपना बनाएं।
हमारी API वही data लौटाती है जो हमारी hosted UI उपयोग करती है। पूर्ण OpenAPI spec यहां api.pulseapi.tech/docs.
import httpx
from fastapi import APIRouter
router = APIRouter()
@router.get("/status")
async def status():
async with httpx.AsyncClient(timeout=5) as client:
r = await client.get("https://api.pulseapi.tech/status/acme")
r.raise_for_status()
return r.json()FastAPI मॉनिटरिंग — FAQ
क्या यह FastAPI, Starlette, और Quart के साथ काम करता है?
हां। तीनों standard HTTP expose करते हैं और एक ही तरह monitor होते हैं।
क्या background workers (Dramatiq, Arq, Celery) monitor कर सकता हूं?
हां। Worker के जरिए task round-trip करने वाला health endpoint बनाएं। Fail/timeout पर 503।
Pydantic v1 vs v2 responses कैसे handle करूं?
PulseAPI final JSON पर assert करता है। Asserted fields रहते हैं तो schema version change कर सकता है।
क्या FastAPI के अंदर स्टेटस पेज render कर सकता हूं?
हां। API fetch करें और Jinja2 से render करें, या frontend को JSON return करें। Structure OpenAPI spec में है।
अपनी FastAPI ऐप की मॉनिटरिंग 5 मिनट में शुरू करें
मुफ्त tier, कोई credit card नहीं। अपना endpoint जोड़ें और टूटने पर alerts पाएं।