.do

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 logs

Tail logs in real-time:

mdxe logs --follow

Filter by level:

mdxe logs --level error

Performance Monitoring

Response Times

Monitor API response times:

mdxe metrics response-time

Request Volume

Monitor request volume:

mdxe metrics requests

Error Rate

Monitor error rate:

mdxe metrics errors

Analytics Dashboard

View analytics dashboard:

mdxe dashboard

Or 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 list

View error details:

mdxe errors view abc123

Error Notifications

Configure error notifications:

mdxe notifications add --email [email protected]
mdxe notifications add --slack webhook-url

Error 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 check

Uptime Status

View uptime:

mdxe uptime

Configure uptime alerts:

mdxe uptime alert --threshold 99.9

Database 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-rate

AI Usage Monitoring

Token Usage

Monitor AI token usage:

mdxai usage

View by model:

mdxai usage --model gpt-5

Cost Tracking

Track AI costs:

mdxai costs

Set budget alerts:

mdxai costs alert --threshold 100

Custom 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 7d

Alerts

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 1h

Alert Channels

# Email
mdxe alert channel add --email [email protected]

# Slack
mdxe alert channel add --slack webhook-url

# PagerDuty
mdxe alert channel add --pagerduty api-key

Distributed 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 abc123

Performance Profiling

CPU Profiling

Profile CPU usage:

mdxe profile cpu --duration 60s

Memory Profiling

Profile memory usage:

mdxe profile memory --duration 60s

Integration with Observability Tools

Datadog

mdxe integration add datadog --api-key xxx

New Relic

mdxe integration add newrelic --license-key xxx

Sentry

mdxe integration add sentry --dsn xxx

Prometheus

Export metrics in Prometheus format:

mdxe metrics export prometheus

Incident Response

View Active Incidents

mdxe incidents list

Incident Details

mdxe incidents view abc123

Create Incident

mdxe incidents create --title "High error rate" --severity high

Resolve Incident

mdxe incidents resolve abc123

Audit Logs

View audit logs:

mdxe audit logs

Filter by action:

mdxe audit logs --action deploy
mdxe audit logs --action publish

Filter 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

  1. Set up alerts: Configure alerts for critical metrics
  2. Monitor error rate: Keep error rate below 1%
  3. Track performance: Monitor p95 and p99 latency
  4. Review logs: Regularly review error logs
  5. Use tracing: Enable distributed tracing for complex operations
  6. Set budgets: Set AI usage budgets to control costs
  7. Dashboard review: Review dashboard weekly
  8. Incident response: Have clear incident response procedures