# Monitoring {#monitoring}


Application monitoring, error tracking, and health checks.


## Health Checks {#health-checks}


```bash
# API Health
GET /api/health

# Response
{
  "status": "ok",
  "info": {
    "database": { "status": "up" }
  }
}
```


## Sentry Integration {#sentry-integration}


```bash
SENTRY_DSN=https://key@sentry.io/project-id
SENTRY_TRACES_SAMPLE_RATE=0.1
SENTRY_HTTP_TRACING_ENABLED=true
SENTRY_POSTGRES_TRACING_ENABLED=true
```

Sentry captures:

- Unhandled exceptions
- API performance traces
- Database query performance
- Frontend errors


## Logging {#logging}


```bash
LOG_LEVEL=info    # error, warn, log, debug, verbose
```


### Structured Logging {#structured-logging}


```typescript
this.logger.log("Employee created", {
  employeeId: employee.id,
  tenantId: employee.tenantId,
  action: "create",
});
```


## Key Metrics to Monitor {#key-metrics-to-monitor}


| Metric                  | Alert Threshold |
| ----------------------- | :-------------: |
| API Error Rate          |      > 1%       |
| API Response Time (p95) |      > 1s       |
| Database Connections    |   > 80% pool    |
| Memory Usage            |      > 80%      |
| CPU Usage               | > 70% sustained |
| Disk Usage              |      > 85%      |


## Related Pages {#related-pages}


- [Performance Overview](https://sourcey-gauzy.pages.dev/performance/performance-overview/index.md)
- [Deployment Overview](https://sourcey-gauzy.pages.dev/deployment/deployment-overview/index.md)
