Files
Copilot 7da8cc91a6 Implement centralized log aggregation with Grafana Loki stack (#139)
* Initial plan

* feat: implement centralized log aggregation with Grafana Loki stack

- Add Loki for log aggregation and storage with 30-day retention
- Configure Promtail for log collection from all services
- Set up Grafana with pre-configured logging dashboard
- Add structured logging with JSON format and label extraction
- Support Docker container log collection via Docker socket
- Implement log filtering by service, level, and custom fields
- Add comprehensive documentation for logging system
- Update Docker Compose for dev and prod environments

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add validation script and quickstart guide for centralized logging

- Add comprehensive validation script to check logging setup
- Create quick start guide for users
- Validate all configuration files (YAML, JSON, Docker Compose)
- All 22 validation checks passing successfully

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add comprehensive implementation summary

- Document all components deployed
- Detail configuration highlights and design decisions
- Compare with alternative solutions (ELK, CloudWatch)
- Provide troubleshooting guide
- List future enhancement opportunities
- Confirm all success criteria met

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: address code review feedback

- Support both docker-compose and docker compose commands
- Fix log path duplication in Promtail (separate backend and security logs)
- Remove invalid Tempo datasource reference from Grafana config
- Add authentication note for production Loki deployments
- Update security documentation with Loki auth best practices

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Update LOGGING.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update docs/LOGGING_IMPLEMENTATION_SUMMARY.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update promtail/README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
Co-authored-by: ⓪ηηωεε忧世 <onnweexd@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-31 23:15:38 -05:00
..

Promtail Configuration

This directory contains the configuration for Promtail, the log collection agent.

Files

  • promtail-config.yml - Main Promtail configuration file

Log Sources

Promtail collects logs from:

  1. Backend Application Logs (/logs/backend/*.log)

    • JSON formatted logs
    • Labels: job, service, level
  2. Security Logs (/logs/backend/security.log)

    • Security events
    • Labels: job, level, action, result
  3. PostgreSQL Logs (/var/log/postgresql/*.log)

    • Database logs
    • Labels: job, service
  4. Docker Container Logs (via Docker socket)

    • Redis, PgBouncer, Nginx, etc.
    • Labels: container, service, stream

Pipeline Stages

For structured logs (JSON):

  1. JSON parsing - Extract fields from JSON
  2. Label extraction - Create Loki labels
  3. Timestamp parsing - Parse timestamp field
  4. Output formatting - Format log message

Ports

  • 9080 - HTTP API (metrics)

Customization

To add a new log source:

scrape_configs:
  - job_name: my_service
    static_configs:
      - targets:
          - localhost
        labels:
          job: my_service
          service: my-service-name
          __path__: /path/to/logs/*.log

Resources