Monitoring¶
LogSys provides in-built health/observability and integrates with external monitoring.
Built-in Health¶
API Health¶
| Component | Checks | Output |
|---|---|---|
| PostgreSQL | SELECT 1 latency |
{status, latency_ms} |
| Redis | PING + dbsize |
{status, latency_ms, extra.total_keys} |
Collector Status¶
Per source: status, last_event_at, events_24h, connector.
Logs¶
Every service logs structured JSON via structlog:
Key pipeline fields: written_total, processing_time_ms, batch_size, dlq.
Metrics to Watch¶
| Signal | Source | Alert threshold |
|---|---|---|
| Consumer lag | Kafka offsets | > 5,000 |
| DLQ count | /api/kpis → dlq_count |
growing |
| Events/min | mv_dashboard_aggregates.events_last_min |
drops to 0 |
| Criticals 24h | criticals_24h |
spikes |
| Copy failures | pipeline logs | > 0 |
| Redis memory | dbsize / container stats |
near maxmemory |
Database Monitoring¶
-- Long-running queries
SELECT pid, now() - query_start AS duration, query
FROM pg_stat_activity WHERE state = 'active'
ORDER BY duration DESC LIMIT 10;
-- Index usage
SELECT indexname, idx_scan FROM pg_stat_user_indexes
WHERE tablename LIKE 'events%' ORDER BY idx_scan DESC;
-- Partition sizes
SELECT child.relname, pg_size_pretty(pg_total_relation_size(child.oid))
FROM pg_inherits JOIN pg_class child ON inhrelid = child.oid
WHERE inhparent = 'events'::regclass;
Kafka Monitoring¶
# Inside the broker container
docker compose exec kafka-broker /opt/kafka/bin/kafka-consumer-groups.sh \
--bootstrap-server localhost:19092 --describe --all-groups
# Topic list
docker compose exec kafka-broker /opt/kafka/bin/kafka-topics.sh \
--bootstrap-server localhost:19092 --list
External Integration¶
| Tool | What to scrape |
|---|---|
| Prometheus | Docker stats, custom /metrics on services |
| Grafana | Dashboards from logs + /api/kpis |
| PagerDuty/AlertOps | Route P1 alerts from the alerts module |
Dashboards¶
The frontend Monitoring page renders:
- PostgreSQL / Redis health cards
- Collector status table
- Recent events feed (real-time)