Monitoring & Logging
Logging System
The Hereby Platform uses Pino logger with structured JSON output.
Log Levels
| Level | Purpose |
|---|---|
debug | Detailed debugging information |
info | General operational info (default) |
warn | Warnings (no immediate action needed) |
error | Errors (action required) |
Change Log Level
Set via environment variable:
bash
# .env
LOG_LEVEL=info # debug, info, warn, errorDocker Container Logs
bash
# All logs
docker-compose logs
# Specific service (real-time)
docker-compose logs -f postgres
docker-compose logs -f redis
# Last 100 lines only
docker-compose logs --tail=100 postgresHealth Checks
PostgreSQL
bash
docker exec hereby_postgres pg_isready -U hereby_admin
docker exec hereby_postgres psql -U hereby_admin -d hereby_platform -c "SELECT 1;"Redis
bash
docker exec hereby_redis redis-cli ping
# Response: PONG
docker exec hereby_redis redis-cli info memoryContainer Status
bash
docker-compose ps
docker stats --no-streamPerformance Monitoring
PostgreSQL Performance
sql
-- Cache hit ratio
SELECT
sum(heap_blks_read) as heap_read,
sum(heap_blks_hit) as heap_hit,
round(sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read))::numeric, 4) as ratio
FROM pg_statio_user_tables;
-- Index usage
SELECT relname, idx_scan as index_scans, seq_scan as sequential_scans
FROM pg_stat_user_tables
ORDER BY seq_scan DESC LIMIT 10;Disk Usage
bash
# Database size
docker exec hereby_postgres psql -U hereby_admin -d hereby_platform \
-c "SELECT pg_size_pretty(pg_database_size('hereby_platform'));"
# Docker volume sizes
docker system df -vMonitoring Scripts
Disk Space Monitor
bash
#!/bin/bash
# scripts/check-disk.sh
THRESHOLD=80
USAGE=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')
if [ "$USAGE" -gt "$THRESHOLD" ]; then
echo "WARNING: Disk usage ${USAGE}% exceeds threshold ${THRESHOLD}%"
fiConnection Count Monitor
bash
#!/bin/bash
# scripts/check-connections.sh
MAX_CONNECTIONS=100
CURRENT=$(docker exec hereby_postgres psql -U hereby_admin -d hereby_platform \
-t -c "SELECT count(*) FROM pg_stat_activity;")
if [ "$CURRENT" -gt "$MAX_CONNECTIONS" ]; then
echo "WARNING: DB connections ${CURRENT} exceeds threshold"
fi