Implement centralized log aggregation with Grafana Loki stack #139
Reference in New Issue
Block a user
Delete Branch "copilot/implement-centralized-logging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements centralized log aggregation and analysis using Grafana Loki stack. Aggregates logs from all services (backend, security, postgres, redis, pgbouncer, nginx) with 30-day retention and efficient search via LogQL.
Architecture
Configuration
Loki (
loki/loki-config.yml):Promtail (
promtail/promtail-config.yml):job,level,service,action,resultGrafana (
grafana/provisioning/):Docker Integration
Updated
docker-compose.{dev,prod}.yml:logs-backend:/app/logs:3000(admin/admin)Log Sources
combined.log,error.log,exceptions.logsecurity.log(auth events, rate limits, threats)Query Examples
Documentation
LOGGING.md: Complete usage guide, troubleshooting, performance tuningdocs/CENTRALIZED_LOGGING_QUICKSTART.md: 5-minute setup guidescripts/validate-logging-setup.sh(22 checks)Notes
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Pull Request Overview
This PR implements centralized log aggregation for Discord SpyWatcher using the Grafana Loki stack. The implementation provides comprehensive log collection, storage, and visualization across all services with a 30-day retention policy.
Key changes:
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@@ -0,0 +1,523 @@# Centralized Log Aggregation & AnalysisThe path pattern documented here is '/logs/backend/security*.log' with a wildcard, but the actual configuration in promtail-config.yml line 47 uses '/logs/backend/security.log' without a wildcard. This should be corrected to match the implementation.
@@ -0,0 +1,347 @@# Centralized Log Aggregation Implementation SummaryThe path pattern documented here is '/logs/backend/security*.log' with a wildcard, but the actual configuration in promtail-config.yml line 47 uses '/logs/backend/security.log' without a wildcard. Ensure documentation matches the actual implementation.
@@ -0,0 +1,60 @@# Promtail ConfigurationThe path pattern shown here is '/logs/backend/security*.log' with a wildcard, but the actual configuration in promtail-config.yml line 47 uses '/logs/backend/security.log' without a wildcard. This documentation should match the implementation.
@@ -0,0 +44,4 @@labels:job: securityservice: spywatcher-security__path__: /logs/backend/security.logThe path pattern '/logs/backend/security.log' matches only a single file, while the README.md documentation states the pattern is '/logs/backend/security*.log' (with wildcard). This inconsistency could cause confusion. Consider updating the path to match the documentation if the intention is to support multiple security log files, or update the README to reflect the exact path.