Skip to content

dostonshernazarov/docker_monitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Container Monitoring System

This project is a Docker Container Monitoring System that allows you to monitor the status of Docker containers by pinging their IP addresses and displaying the results in a web interface. The system consists of four main components:

  1. Backend Service: A RESTful API written in Go that handles database operations.
  2. Frontend Service: A React-based web application that displays the status of Docker containers.
  3. Pinger Service: A Go service that pings Docker containers and sends the results to the Backend API.
  4. PostgreSQL Database: Stores the status of Docker containers.
  5. Database migrations: For auto migrate tables

The system is containerized using Docker and orchestrated with Docker Compose. Nginx is used as a reverse proxy to route requests between the frontend and backend.


Table of Contents

  1. Features
  2. Technologies Used
  3. Prerequisites
  4. Setup and Installation
  5. Running the Project
  6. Project Structure
  7. API Endpoints
  8. Troubleshooting
  9. Contributing
  10. License

Features

  • Real-time Monitoring: The Pinger service continuously pings Docker containers and updates the database.
  • Web Interface: The Frontend service provides a user-friendly interface to view the status of Docker containers.
  • RESTful API: The Backend service exposes endpoints to fetch and insert container status data.
  • Containerized: All services are containerized using Docker for easy deployment and scalability.

Technologies Used

  • Backend: Go (Golang)
  • Frontend: React (JavaScript)
  • Database: PostgreSQL
  • Pinger Service: Go (Golang)
  • Containerization: Docker, Docker Compose
  • Reverse Proxy: Nginx
  • Migrations: SQL migrations

Prerequisites

Before running the project, ensure you have the following installed:

  1. Docker: Install Docker
  2. Docker Compose: Install Docker Compose
  3. Node.js (for local frontend development): Install Node.js
  4. Go (for local backend development): Install Go

Setup and Installation

  1. Clone the Repository:

    git clone https://github.com/dostonshernazarov/docker_monitoring.git
    cd docker_monitoring
  2. Set Up Environment Variables:

    • Create a .env file in the backend directory with the following content:
      POSTGRES_USER=postgres
      POSTGRES_PASSWORD=yourpassword
      POSTGRES_DB=docker_monitor
  3. Build and Run the Project:

    docker-compose up --build

    This will:

    • Build Docker images for all services.
    • Start the PostgreSQL database with migrations, Backend, Frontend, Pinger, and Nginx services.
  4. Access the Application:

    • Open your browser and navigate to http://localhost:80.
    • You should see the frontend interface displaying the status of Docker containers.

Running the Project

Using Docker Compose

To start all services, run:

docker-compose up --build

To stop all services, run:

docker-compose down

Running Services Locally (Optional)

  1. Backend:

    • Navigate to the backend directory:
      cd backend
    • Run the backend service:
      go run main.go
  2. Frontend:

    • Navigate to the frontend directory:
      cd frontend
    • Install dependencies and start the frontend:
      npm install
      npm start
  3. Pinger:

    • Navigate to the pinger directory:
      cd pinger
    • Run the pinger service:
      go run main.go

Project Structure

docker-monitor/
├── backend/               # Backend service (Go)
│   ├── main.go            # Backend entry point
│   ├── Dockerfile         # Dockerfile for backend
|   ├── .env               # Environment variables
│   └── go.mod             # Go dependencies
├── frontend/              # Frontend service (React)
│   ├── src/               # React source code
│   ├── Dockerfile         # Dockerfile for frontend
│   └── package.json       # Node.js dependencies
├── migrations/
|   ├── 00...table.down.sql
|   ├── 00...table.up.sql
├── pinger/                # Pinger service (Go)
│   ├── main.go            # Pinger entry point
│   ├── Dockerfile         # Dockerfile for pinger
│   └── go.mod             # Go dependencies
├── nginx.conf             # Nginx configuration
├── docker-compose.yml     # Docker Compose configuration
└── README.md              # Project documentation

API Endpoints

Backend API

  • GET /status:

    • Fetches the status of all Docker containers.
    • Example Response:
      [
        {
          "ip_address": "192.168.1.1",
          "ping_time": 100,
          "last_success": "2023-10-01T12:00:00Z"
        }
      ]
  • POST /status:

    • Inserts a new container status into the database.
    • Example Request Body:
      {
        "ip_address": "192.168.1.1",
        "ping_time": 100,
        "last_success": "2023-10-01T12:00:00Z"
      }

Troubleshooting

  1. CORS Issues:

    • Ensure the Backend service has CORS enabled (see backend/main.go).
    • Use the proxy configuration in the Frontend (frontend/package.json).
  2. Database Connection Issues:

    • Verify that the PostgreSQL service is running.
    • Check the .env file for correct database credentials.
  3. Pinger Service Not Sending Data:

    • Check the logs of the Pinger service for errors.
    • Ensure the Backend API is running and accessible.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a detailed description of your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.


About

This project is a Docker Container Monitoring System that allows you to monitor the status of Docker containers by pinging their IP addresses and displaying the results in a web interface.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors