Skip to content

Monitoring

The application includes a fully provisioned and preconfigured monitoring stack that allows you to monitor container performance, resource usage, and logs. This stack is ready to use immediately after installation and is accessible via the monitoring URL.

Monitoring Stack Overview

The monitoring stack consists of the following tools:

  1. cAdvisor: Collects container-level metrics such as CPU, memory, and network usage.
  2. Promtail: Collects logs from Docker containers and forwards them to Loki.
  3. Loki: A log aggregation system for storing and querying logs.
  4. Prometheus: A time-series database for collecting metrics from cAdvisor and other sources.
  5. Grafana: A visualization and dashboard tool to view metrics and logs.

Key Features

  • Container Status: View the status of all containers in the application.
  • Resource Usage: Monitor CPU, memory, and network usage for each container.
  • Log Aggregation: Access centralized logs for all containers.
  • Log Search and Error Detection: Search logs for specific terms (e.g., ERROR) to quickly identify issues.

Accessing the Monitoring Dashboard

  1. URL: The monitoring stack is available at: "http://$hostname/monitor/" Replace $hostname with the hostname or IP of your server

  2. Default Grafana Credentials:

    • Username: admin
    • Password: admin

Security Note

For security purposes, it is recommended to change the default credentials after the first login.

Preconfigured Dashboards

The monitoring stack comes with preconfigured dashboards in Grafana, ready to use out of the box:

1. Docker Monitoring Dashboard

Docker Monitoring Dashboard

  • Container Selection: Filter by specific container (e.g., apifort-backend)
  • Container Status: View uptime and operational status of containers
  • Log Event Metrics: Track total log events, categorized by Info, Warning, and Error counts
  • Time Range Selection: Adjust the time window (e.g., last 30 minutes)
  • Resource Visualizations:
    • CPU Usage: Real-time graph showing CPU utilization percentage over time
    • Memory Usage: Detailed memory consumption tracking in GB
    • Disk I/O: Separate panels for read and write operations showing I/O rates
  • Log Tail: Live stream of recent logs with timestamp, log level, thread ID, and message content
  • Refresh Controls: Manual refresh and auto-refresh timing options

2. Container Metrics Dashboard

  • Displays CPU, memory, and network usage for all containers.
  • Helps identify resource bottlenecks or underutilized containers.

3. Log Dashboard

  • Aggregates logs from all containers.
  • Allows searching for specific terms (e.g., ERROR, WARNING) to troubleshoot issues.

4. Overview Dashboard

  • Provides a high-level summary of container health and application performance.

How to Use the Monitoring Tools

1. View Container Metrics

  • Navigate to the Docker Monitoring Dashboard in Grafana.
  • Select the specific container you want to monitor from the dropdown menu.
  • View the container's status (UP/DOWN) and uptime duration.
  • Analyze CPU, memory, and disk I/O usage through the time-series graphs.
  • Use the time range selector to focus on specific time periods (e.g., last 30 minutes, last hour).

2. Search Logs

  • Use the Log Tail panel to view the most recent log entries.
  • Filter logs by log level (INFO, WARN, ERROR) to focus on specific types of events.
  • Use the search bar to filter logs by keywords or specific service names.
  • Check log counts (Info, Warn, Error) to quickly identify potential issues.

3. Detect Errors

  • Monitor the Error Count metric for unexpected increases.
  • Review WARN and ERROR log entries in the Log Tail section.
  • Identify patterns in error messages, such as repeated warnings about vulnerability alerts.
  • Set up alerts in Grafana (optional) to notify you when specific log patterns are detected.

Deployment Details

Network Configuration

  • The monitoring stack uses a Docker network and does not expose any services directly to the host.
  • All components communicate internally within the Docker network.

Preconfigured Setup

  • The stack is fully provisioned and preconfigured during installation.
  • No additional setup is required after deployment.

Security Recommendations

  1. Change Default Credentials:

    • After the first login, update the default Grafana credentials (admin:admin) to a secure username and password.
  2. Restrict Access:

    • Ensure that access to the monitoring stack is restricted to authorized users only.
  3. Monitor Logs for Security Issues:

    • Regularly search logs for unusual activity or errors that could indicate security issues.