This project sets up a complete monitoring environment using Docker Compose to orchestrate InfluxDB and Grafana. It allows for collecting, storing, and visualizing real-time metric data. The configuration includes automatic initialization of InfluxDB and automatic configuration of Grafana with pre-configured data sources and dashboards.
- Docker installed on your machine.
- Docker Compose installed (version 3.7 or higher recommended).
- Clone the Repository
git clone https://github.com/CaptainIgl00/grafana-influxdb-docker-compose.git
cd grafana-influxdb-docker-compose
- Modify the .env file with your own information
INFLUXDB_DATABASE=db
INFLUXDB_USERNAME=user
INFLUXDB_ORG=org
INFLUXDB_PASSWORD=userpassword
INFLUXDB_TOKEN='token'
GRAFANA_USERNAME=admin
GRAFANA_PASSWORD=adminpassword
Note: Make sure to replace the values with your own information. Avoid using special characters such as quotes in the passwords to prevent interpretation issues.
- Run the Docker Compose file
docker-compose up -d
- Access Grafana at http://localhost:3000 and InfluxDB at http://localhost:8086
In order to add custom dashboards, you can use the Grafana interface.
-
Create or Export a Dashboard
- Create a new dashboard in Grafana.
- Export it as JSON via Share > Export > Save to file.
-
Add the Dashboard to the Project
- Place the exported JSON file into the grafana-dashboards/ folder.
-
Next time you start the project, the dashboard will be automatically added to Grafana.
grafana-influxdb-docker-compose/
├── docker-compose.yml # Docker Compose file
├── .env # InfluxDB and Grafana credentials
├── grafana-dashboards/ # Folder for custom dashboards
│ └── Example Dashboard.json # Example dashboard
│
└── grafana-provisioning/ # Folder for Grafana provisioning
├── datasources/
│ └── datasource.yml # Configures InfluxDB as the default data source
│
└── dashboards/
└── dashboard.yml # Automatically loads dashboards from grafana-dashboards/
-
Verify that the environment variables are correctly defined in the .env file.
-
Ensure that the init-influxdb service ran successfully by checking the logs:
docker-compose up
-
Check that the provisioning files are correctly placed in grafana-provisioning/datasources/ and grafana-provisioning/dashboards/.
-
Review Grafana logs for any errors:
docker-compose logs -f grafana-influxdb-docker-compose-grafana-1
- Make sure that the InfluxDB token doesn't contain special characters that could be badly interpreted.
-
Ensure that variables are referenced using the
${VARIABLE}
syntax in the provisioning YAML files. -
The environment variables must be exported within the Grafana container. You can verify them with:
docker exec -it grafana-influxdb-docker-compose-grafana-1 env | grep GF_
Contributions are welcome! If you find bugs or have suggestions for improvement, feel free to open an issue or a pull request.
This project is licensed under the GPL-3.0 License. See the LICENSE file for details.