Skip to main content

Monitoring

Monitor SHIELD production for issues and performance.

Vercel Analytics

Enable in Dashboard:
  • Web Vitals
  • Traffic insights
  • Error tracking

Database Monitoring

Neon Dashboard

Monitor:
  • Query performance
  • Connection count
  • Storage usage

Alerts

Set up alerts for:
  • High latency (> 500ms)
  • Connection limit
  • Storage threshold

Smart Contract Monitoring

Tenderly

Set up Tenderly for:
  • Transaction monitoring
  • Alert rules
  • Gas usage tracking

Custom Alerts

Watch for:
  • Failed createPolicy calls
  • Failed logAttempt calls
  • Unusual activity patterns

Error Tracking

Sentry

// sentry.client.config.ts
import * as Sentry from '@sentry/nextjs';

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  tracesSampleRate: 1.0,
});

Logging

Structured logging in API routes:
console.log(JSON.stringify({
  level: 'info',
  message: 'Policy created',
  policyId,
  sender,
  timestamp: new Date().toISOString(),
}));

Health Checks

Create /api/health:
export async function GET() {
  // Check database
  // Check IPFS
  // Check contract

  return Response.json({
    status: 'healthy',
    timestamp: Date.now(),
    checks: {
      database: 'ok',
      ipfs: 'ok',
      contract: 'ok',
    },
  });
}

Alert Thresholds

MetricWarningCritical
API errors> 1%> 5%
Avg response time> 500ms> 1000ms
DB connections> 80%> 95%
Failed txs> 5%> 10%

Runbooks

Document responses to common issues:
  • High error rate
  • Database connection issues
  • Contract call failures
  • IPFS upload failures