Monitoring & Logs
APSO provides built-in monitoring and logging to help you understand your service’s performance and diagnose issues.
Logs
Accessing Logs
From the dashboard:
- Navigate to your service
- Click the Logs tab
- View real-time log stream
Log Levels
| Level | Description | Color |
|---|---|---|
debug | Detailed debugging info | Gray |
info | General information | Blue |
warn | Warnings | Yellow |
error | Errors | Red |
Filtering Logs
Filter by:
- Level — Show only specific log levels
- Time Range — Last hour, day, week, or custom
- Search — Full-text search in log messages
# Example searches
"POST /api/v1/projects"
error
userId:user-123
statusCode:500Log Format
Each log entry includes:
{
"timestamp": "2024-01-15T10:30:00.000Z",
"level": "info",
"message": "Request completed",
"context": {
"method": "POST",
"path": "/api/v1/projects",
"statusCode": 201,
"duration": 45,
"userId": "user-123",
"organizationId": "org-456"
}
}Downloading Logs
- Set your desired filters
- Click Download
- Choose format (JSON or CSV)
- Logs are downloaded for the selected time range
Log Retention
| Plan | Retention |
|---|---|
| Free | 7 days |
| Pro | 30 days |
| Enterprise | 90 days |
Metrics
Service Metrics
Available metrics in the dashboard:
| Metric | Description |
|---|---|
| Request Rate | Requests per minute |
| Error Rate | Percentage of 4xx/5xx responses |
| Latency | Response time (p50, p95, p99) |
| Active Connections | Current open connections |
Database Metrics
| Metric | Description |
|---|---|
| Query Count | Queries per minute |
| Query Duration | Average query time |
| Connection Pool | Active/idle connections |
| Database Size | Storage used |
Viewing Metrics
- Navigate to your service
- Click the Metrics tab
- Select time range
- Choose metrics to display
Metric Time Ranges
- Last hour
- Last 24 hours
- Last 7 days
- Last 30 days
- Custom range
Alerts
Setting Up Alerts
- Navigate to Settings > Alerts
- Click Create Alert
- Configure:
- Metric — What to monitor
- Condition — Threshold
- Duration — How long before alerting
- Channel — Where to send alerts
Alert Types
| Alert | Trigger |
|---|---|
| High Error Rate | Error rate > 5% for 5 minutes |
| High Latency | p95 latency > 1s for 5 minutes |
| Service Down | No responses for 1 minute |
| Database Issues | Connection failures |
Notification Channels
- Email — Send to team members
- Slack — Post to a channel
- Webhook — Custom HTTP endpoint
- PagerDuty — Incident management
Example Alert Configuration
{
"name": "High Error Rate",
"metric": "error_rate",
"condition": {
"operator": ">",
"threshold": 0.05
},
"duration": "5m",
"channels": ["slack-ops", "email-team"]
}Health Checks
Endpoint
GET /healthResponse
{
"status": "healthy",
"version": "1.2.0",
"uptime": 86400,
"checks": {
"database": "connected",
"redis": "connected",
"memory": "ok"
}
}Status Values
| Status | Description |
|---|---|
healthy | All systems operational |
degraded | Some issues, partial functionality |
unhealthy | Critical issues |
Custom Health Checks
Add custom checks in your extensions:
// src/extensions/health/custom.health.ts
import { Injectable } from '@nestjs/common';
import { HealthIndicator, HealthCheckResult } from '@nestjs/terminus';
@Injectable()
export class CustomHealthIndicator extends HealthIndicator {
async check(key: string): Promise<HealthCheckResult> {
// Your custom health check logic
const isHealthy = true;
return this.getStatus(key, isHealthy);
}
}Performance Optimization
Identifying Slow Requests
- View Metrics > Latency chart
- Click on spike to see affected requests
- Check logs for those requests
- Identify slow database queries or external calls
Common Performance Issues
| Issue | Symptom | Solution |
|---|---|---|
| N+1 Queries | Slow list endpoints | Use include option |
| Missing Index | Slow filtered queries | Add database index |
| Large Payload | Slow responses | Implement pagination |
| Memory Leak | Increasing latency | Check for memory issues |
Query Analysis
Enable query logging to identify slow queries:
.apsorc
{
"database": {
"logging": ["query", "slow"]
}
}External Integrations
Log Forwarding
Forward logs to external services:
- Go to Settings > Integrations
- Add log destination:
- Datadog
- Papertrail
- Logtail
- Custom Webhook
APM Integration
Connect to Application Performance Monitoring:
- Datadog APM
- New Relic
- Sentry
Example: Datadog Integration
# Set environment variables
DD_API_KEY=your-datadog-api-key
DD_SITE=datadoghq.com
DD_SERVICE=my-apso-serviceDebugging
Enable Debug Mode
For detailed logs:
DEBUG=apso:* npm run devDatabase Query Logging
.apsorc
{
"database": {
"logging": true
}
}Request Tracing
Each request includes a trace ID:
X-Request-Id: abc123Use this to trace a request through logs:
# Search logs by request ID
requestId:abc123Related
Last updated on