Monitor
Monitor MDXLD applications in production
Monitor
Monitor your MDXLD applications in production with real-time analytics, error tracking, and performance metrics.
Real-Time Logs
View deployment logs:
mdxe logsTail logs in real-time:
mdxe logs --followFilter by level:
mdxe logs --level errorPerformance Monitoring
Response Times
Monitor API response times:
mdxe metrics response-timeRequest Volume
Monitor request volume:
mdxe metrics requestsError Rate
Monitor error rate:
mdxe metrics errorsAnalytics Dashboard
View analytics dashboard:
mdxe dashboardOr visit: https://dashboard.do/your-app
Metrics include:
- Requests: Total requests per time period
- Errors: Error count and rate
- Latency: p50, p95, p99 latency
- Traffic: Geographic distribution
- Devices: Device and browser breakdown
- Pages: Most visited pages
Error Tracking
View Errors
List recent errors:
mdxe errors listView error details:
mdxe errors view abc123Error Notifications
Configure error notifications:
mdxe notifications add --email [email protected]
mdxe notifications add --slack webhook-urlError Grouping
Errors are automatically grouped by:
- Error message
- Stack trace
- File and line number
- User agent
- Geographic location
Uptime Monitoring
Health Checks
Configure health check endpoint:
// health.ts
export default function health() {
return {
status: 'ok',
timestamp: new Date().toISOString(),
version: '1.0.0'
}
}Monitor health:
mdxe health checkUptime Status
View uptime:
mdxe uptimeConfigure uptime alerts:
mdxe uptime alert --threshold 99.9Database Monitoring
Query Performance
Monitor MDX database query performance:
import { search } from 'mdxdb'
const results = await search('TypeScript', {
metrics: true
})
console.log(`Query took ${results.metrics.duration}ms`)
console.log(`Scanned ${results.metrics.scanned} documents`)
console.log(`Returned ${results.length} results`)Cache Hit Rate
Monitor cache hit rate:
mdxe metrics cache-hit-rateAI Usage Monitoring
Token Usage
Monitor AI token usage:
mdxai usageView by model:
mdxai usage --model gpt-5Cost Tracking
Track AI costs:
mdxai costsSet budget alerts:
mdxai costs alert --threshold 100Custom Metrics
Define Custom Metrics
import { track } from 'mdxe'
// Track document views
await track('document.view', {
docId: '/blog/my-post',
timestamp: Date.now()
})
// Track user actions
await track('user.action', {
action: 'share',
docId: '/blog/my-post'
})Query Custom Metrics
mdxe metrics custom document.view --range 7dAlerts
Configure Alerts
# Error rate alert
mdxe alert add --metric error-rate --threshold 1 --period 5m
# Response time alert
mdxe alert add --metric response-time --threshold 1000 --period 1m
# Usage alert
mdxe alert add --metric requests --threshold 10000 --period 1hAlert Channels
# Email
mdxe alert channel add --email [email protected]
# Slack
mdxe alert channel add --slack webhook-url
# PagerDuty
mdxe alert channel add --pagerduty api-keyDistributed Tracing
Enable Tracing
import { trace } from 'mdxe'
await trace('mdx.render', async () => {
const doc = await get('/blog/my-post')
return render(doc)
})View Traces
mdxe traces list
mdxe traces view abc123Performance Profiling
CPU Profiling
Profile CPU usage:
mdxe profile cpu --duration 60sMemory Profiling
Profile memory usage:
mdxe profile memory --duration 60sIntegration with Observability Tools
Datadog
mdxe integration add datadog --api-key xxxNew Relic
mdxe integration add newrelic --license-key xxxSentry
mdxe integration add sentry --dsn xxxPrometheus
Export metrics in Prometheus format:
mdxe metrics export prometheusIncident Response
View Active Incidents
mdxe incidents listIncident Details
mdxe incidents view abc123Create Incident
mdxe incidents create --title "High error rate" --severity highResolve Incident
mdxe incidents resolve abc123Audit Logs
View audit logs:
mdxe audit logsFilter by action:
mdxe audit logs --action deploy
mdxe audit logs --action publishFilter by user:
mdxe audit logs --user [email protected]Programmatic Monitoring
Monitor via TypeScript API:
import { metrics, logs, errors } from 'mdxe'
// Get metrics
const responseTime = await metrics.get('response-time', { range: '1h' })
const errorRate = await metrics.get('error-rate', { range: '1h' })
// Get logs
const recentLogs = await logs.list({ limit: 100, level: 'error' })
// Get errors
const recentErrors = await errors.list({ limit: 10 })
// Track custom event
await metrics.track('document.generated', {
type: 'BlogPost',
model: 'gpt-5'
})Best Practices
- Set up alerts: Configure alerts for critical metrics
- Monitor error rate: Keep error rate below 1%
- Track performance: Monitor p95 and p99 latency
- Review logs: Regularly review error logs
- Use tracing: Enable distributed tracing for complex operations
- Set budgets: Set AI usage budgets to control costs
- Dashboard review: Review dashboard weekly
- Incident response: Have clear incident response procedures