AI-Powered Health Assistant with Complete Datadog Observability
- Overview
- Features
- Architecture
- Tech Stack
- Quick Start
- Environment Setup
- API Documentation
- Datadog Integration
- Deployment
- Screenshots
- Contributing
- License
HealthBot Monitor is a production-ready AI health assistant that demonstrates complete observability using Datadog. It combines the power of Google's Gemini AI for intelligent health-related conversations with comprehensive monitoring, metrics, and alerting capabilities.
- π€ Smart Health Assistant: Leverages Google Gemini for accurate, helpful health information
- π Real-time Monitoring: Complete observability with Datadog APM, metrics, and logging
- π¨ Intelligent Alerts: Proactive detection of anomalies and performance issues
- π¨ Beautiful UI: Modern, responsive React interface
- π³ Production Ready: Docker-based deployment with health checks
| Feature | Description |
|---|---|
| π¬ AI Chat | Natural language health conversations powered by Gemini |
| π Live Metrics | Real-time performance monitoring dashboard |
| β±οΈ Response Tracking | Track response times, token usage, and errors |
| π Smart Alerts | Configurable alerts for performance thresholds |
| π Analytics | Historical data and trend analysis |
- β Custom Metrics (response time, token usage, error rate)
- β APM Tracing (distributed tracing across services)
- β Log Management (structured JSON logging)
- β Detection Rules (anomaly detection)
- β Dashboard Templates (pre-built visualizations)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Browser β
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend (Port 3000) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Chat UI β β Dashboard β β Alerts β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β HTTP/REST
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Backend (Port 8000) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Chat API β β Metrics API β β Alerts API β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
β β β β β
β ββββββββΌββββββββ ββββββββΌββββββββββββββββββΌββββββββ β
β βGemini Serviceβ β Datadog Config β β
β ββββββββ¬ββββββββ β β’ Custom Metrics β β
β β β β’ APM Tracing β β
β β β β’ Monitor/Alerts β β
β β β β’ Structured Logging β β
β β ββββββββ¬ββββββββββββββββββββββββββ β
βββββββββββΌββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββ
β Google Gemini β β Datadog β
β API β β ββββββββββββββ βββββββββββββββββββββ β
β (AI Responses) β β β Metrics β β Monitors/Alerts β β
ββββββββββββββββββββ β β Dashboard β β β’ High Response β β
β ββββββββββββββ β β’ Error Rate β β
β β β’ Token Spike β β
β ββββββββββββββ β β’ Service Down β β
β β APM β βββββββββββββββββββββ β
β β Tracing β β
β ββββββββββββββ β Email/Webhook Alerts β
ββββββββββββββββββββββββββββββββββββββββββββ
- User Query: User sends health question via React Chat UI
- API Request: Frontend sends POST to
/chatendpoint - AI Processing: Backend forwards query to Google Gemini API
- Metrics Collection: Response time, tokens, errors tracked
- Datadog Push: Metrics sent to Datadog in real-time
- Alert Evaluation: Datadog monitors check thresholds
- Response: AI response returned to user with metrics
- FastAPI - High-performance Python web framework
- Google Generative AI - Gemini API for LLM capabilities
- ddtrace - Datadog APM integration
- datadog-api-client - Custom metrics submission
- structlog - Structured JSON logging
- React 18 - Modern UI library
- Recharts - Beautiful charts and graphs
- Axios - HTTP client
- CSS Variables - Custom theming
- Docker - Containerization
- Docker Compose - Multi-container orchestration
- Nginx - Production web server
- Python 3.10+
- Node.js 18+
- Git
- Docker (optional)
git clone https://github.com/yourusername/healthbot-monitor.git
cd healthbot-monitorcp .env.example .env
# Edit .env with your API keyscd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python main.py# In a new terminal
cd frontend
npm install
npm start- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Go to Google AI Studio
- Click "Get API Key"
- Create new API key
- Copy to
.envasGOOGLE_API_KEY
- Sign up at Datadog
- Go to Organization Settings β API Keys
- Create new API Key β Copy to
DD_API_KEY - Go to Application Keys
- Create new App Key β Copy to
DD_APP_KEY
# Google Gemini API Key
GOOGLE_API_KEY=your_gemini_api_key_here
# Datadog Configuration
DD_API_KEY=your_datadog_api_key_here
DD_APP_KEY=your_datadog_app_key_here
DD_SITE=datadoghq.com
# Service Configuration
DD_SERVICE=healthbot-monitor
DD_ENV=development
DD_VERSION=1.0.0
# Application Settings
PORT=8000
HOST=0.0.0.0
DEBUG=true
FRONTEND_URL=http://localhost:3000| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
API information |
GET |
/health |
Health check |
POST |
/chat |
Send message to AI |
GET |
/metrics |
Get current metrics |
GET |
/dashboard |
Dashboard data |
GET |
/stats |
Detailed statistics |
GET |
/alerts |
Get active alerts |
POST |
/alerts/setup |
Setup Datadog monitors |
DELETE |
/conversation/{id} |
Clear conversation |
POST /chat
{
"message": "What are the symptoms of common cold?",
"conversation_id": "optional_id"
}{
"response": "Common cold symptoms include...",
"conversation_id": "conv_abc123",
"tokens_used": 150,
"response_time_ms": 1234.56,
"timestamp": "2024-01-15T10:30:00Z"
}GET /alerts
{
"alerts": [
{
"type": "warning",
"name": "Elevated Response Time",
"message": "Average response time is 3500ms (> 3000ms)",
"value": 3500
}
],
"total_alerts": 1,
"critical_count": 0,
"warning_count": 1
}| Metric | Type | Description |
|---|---|---|
healthbot.response_time_ms |
Gauge | API response latency |
healthbot.tokens_used |
Gauge | Tokens per request |
healthbot.request_count |
Gauge | Total request count |
healthbot.error_count |
Gauge | Total errors |
healthbot.error_rate |
Gauge | Error percentage |
HealthBot Monitor includes a comprehensive alerting system that can be configured to send notifications via email or webhook.
| Alert Name | Condition | Threshold |
|---|---|---|
| High Response Time | Avg response > 5s | Critical: 5000ms, Warning: 3000ms |
| High Error Rate | Error rate > 5% | Critical: 5%, Warning: 2% |
| Token Usage Spike | Tokens > 10000/min | Critical: 10000, Warning: 5000 |
| Service Down | No requests in 10min | Critical threshold |
# Setup alerts with email notification
curl -X POST "http://localhost:8000/alerts/setup?email=your@email.com"
# Response
{
"message": "Datadog alerts configured successfully",
"monitors_created": 4,
"monitors": [...]
}- Log in to Datadog
- Go to Dashboards β New Dashboard
- Add widgets with metrics prefixed
healthbot.* - Configure time range and refresh interval
Create these alerts in Datadog:
-
High Response Time
- Metric:
healthbot.response_time_ms - Alert when: avg > 5000 for 5 minutes
- Metric:
-
High Error Rate
- Metric:
healthbot.error_rate - Alert when: > 5% for 5 minutes
- Metric:
-
Token Usage Spike
- Metric:
healthbot.tokens_used - Alert when: anomaly detected
- Metric:
We provide an automated deployment script:
# Make script executable (first time only)
chmod +x deploy.sh
# Run deployment
./deploy.shThe script will:
- Build Docker images for frontend and backend
- Push to Google Container Registry
- Deploy to Cloud Run
- Configure environment variables
- Output the live URLs
# Production (full stack with Datadog agent)
docker-compose up -d
# Development (backend only)
docker-compose -f docker-compose.dev.yml up -dcd backend
# Build and submit
gcloud builds submit --tag gcr.io/PROJECT_ID/healthbot-backend
# Deploy with environment variables
gcloud run deploy healthbot-backend \
--image gcr.io/PROJECT_ID/healthbot-backend \
--region us-central1 \
--allow-unauthenticated \
--set-env-vars "GOOGLE_API_KEY=xxx,DD_API_KEY=xxx,DD_APP_KEY=xxx"cd frontend
# Option 1: Vercel
npm run build
vercel deploy --prod
# Option 2: Cloud Run
gcloud builds submit --tag gcr.io/PROJECT_ID/healthbot-frontend
gcloud run deploy healthbot-frontend \
--image gcr.io/PROJECT_ID/healthbot-frontend \
--region us-central1 \
--allow-unauthenticatedFor automated deployments on every push:
# Connect repository to Cloud Build
gcloud builds submit --config=cloudbuild.yaml \
--substitutions=_GOOGLE_API_KEY="xxx",_DD_API_KEY="xxx",_DD_APP_KEY="xxx"Modern chat UI with health queries and AI responses.
Real-time metrics with response time graphs, success rates, and token usage.
Custom dashboard showing all tracked metrics and alerts.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini - AI capabilities
- Datadog - Observability platform
- FastAPI - Python web framework
- React - UI library
Built with β€οΈ for the Hackathon
Made by [Your Name]