To set up a monitoring solution for your local server using Prometheus and Grafana, here we have all within one Docker Compose:
Prerequisites Ensure Docker and Docker Compose are installed on your local machine.
Step-by-Step Guide
Create a Docker Compose file (.yml) that contains both Grafana and Prometheus images.
Link Prometheus to your session server Prometheus endpoint.
Configure your Grafana data source to communicate with Prometheus and import the pre-configured dashboards.
Configure the Grafana dashboards
Access Grafana.
Instructions:
-
Clone the repository:
git clone https://github.com/SumairaS/Docker-Compose-Prometheus-Grafana cd prometheus-grafana -
Run Docker Compose:
docker-compose up -d
-
Check if it's up and running:
Accessing the Services
Prometheus: http://localhost:9090
Grafana: http://localhost:3000
Default Grafana login:
Username: admin
Password: admin
Upon first login, you may be prompted to change the password.
- Configure Grafana to Use Prometheus Data Source Add Prometheus as a data source:
Go to Configuration (gear icon) > Data Sources > Add data source. Select Prometheus. Set the URL to http://prometheus:9090. Click Save & Test. Create a new dashboard:
Go to Create (plus icon) > Dashboard > Add new panel. Set your desired metrics and visualization.
- Explore Metrics in Grafana You can now create and customize dashboards in Grafana to visualize the metrics being scraped by Prometheus.
To Stop all the services:
docker-compose down