Skip to main content
Proper monitoring ensures your SuperTokens deployment remains healthy, performant, and secure. This guide covers health checks, logging, metrics, and observability.

Health Checks

Basic Health Check

SuperTokens provides a /hello endpoint for basic health verification:
Expected response:
Status codes:
  • 200 OK - Service is healthy and database is accessible
  • 500 Internal Server Error - Service or database issue

Docker Health Check

Configure health checks in Docker Compose:
Or using curl:

Kubernetes Probes

Advanced Health Monitoring

Create a comprehensive health check script:

Logging

Log Configuration

Configure logging in config.yaml:

Log Levels

  • DEBUG: Detailed debugging information (verbose)
  • INFO: General informational messages (default)
  • WARN: Warning messages for potential issues
  • ERROR: Error messages for failures
  • NONE: Disable logging (not recommended)

Docker Logging

Send logs to stdout/stderr:
View Docker logs:

Log Rotation

Using logrotate (Linux): Create /etc/logrotate.d/supertokens:
Docker log rotation:

Centralized Logging

Elasticsearch + Fluentd + Kibana (EFK)

Loki + Promtail + Grafana

OpenTelemetry Integration

SuperTokens supports OpenTelemetry for distributed tracing and metrics.

Configuration

Or via environment variable:

OpenTelemetry Collector Setup

otel-collector-config.yaml:
docker-compose.yml:

Metrics and Monitoring

Key Metrics to Monitor

Application Metrics

  • Request Rate: Requests per second to SuperTokens
  • Response Time: Average/P95/P99 response times
  • Error Rate: Percentage of failed requests
  • Active Sessions: Number of active user sessions
  • Database Queries: Query count and latency

System Metrics

  • CPU Usage: Core CPU utilization percentage
  • Memory Usage: RAM consumption
  • Disk I/O: Read/write operations
  • Network I/O: Inbound/outbound traffic

Database Metrics

  • Connection Pool: Active/idle connections
  • Query Performance: Slow query count and duration
  • Database Size: Storage usage growth
  • Replication Lag: For replicated setups

Prometheus Configuration

prometheus.yml:

Grafana Dashboards

Import Dashboards

  1. Open Grafana: http://localhost:3000
  2. Navigate to Dashboards > Import
  3. Use these dashboard IDs:
    • PostgreSQL: 9628
    • MySQL: 7362
    • Docker: 179
    • Node Exporter: 1860

Custom SuperTokens Dashboard

Create a dashboard with panels for:
  • Request rate (requests/sec)
  • Response time (ms) - P50, P95, P99
  • Error rate (%)
  • Active sessions
  • Database query count
  • CPU and memory usage

Database Monitoring

PostgreSQL Exporter

MySQL Exporter

Container Monitoring

cAdvisor

Alerting

AlertManager Configuration

alertmanager.yml:

Alert Rules

alerts.yml:

Uptime Monitoring

Using External Services

Self-Hosted Options

Uptime Kuma

Access at http://localhost:3001

Performance Monitoring

Application Performance Monitoring (APM)

Integrate with APM tools:

Custom Performance Tracking

Troubleshooting with Monitoring

High CPU Usage

High Memory Usage

Slow Database Queries

Security Monitoring

Failed Authentication Attempts

Monitor error logs for patterns:

Rate Limiting

SuperTokens has built-in rate limiting. Monitor rate limit hits:

Audit Logging

For compliance, enable audit logging:

Best Practices

  1. Set up health checks on all deployment platforms
  2. Monitor key metrics continuously (response time, error rate, CPU, memory)
  3. Configure alerts for critical issues with appropriate thresholds
  4. Centralize logs for easier troubleshooting
  5. Test alerts regularly to ensure they work
  6. Document runbooks for common issues
  7. Review metrics regularly to identify trends
  8. Set up dashboards for at-a-glance status
  9. Monitor database health separately
  10. Keep retention policies for logs and metrics

Next Steps