|[Nginx and Certbot in Docker](https://github.com/xuan103/Docker-Grafana_Nginx/blob/main/document/Nginx%20and%20Certbot%20in%20Docker.md)|[Table of Contents](https://github.com/xuan103/Docker-Grafana_Nginx/blob/main/README.md)|[Setup Grafana](https://github.com/xuan103/Docker-Grafana_Nginx/blob/main/document/Setup%20Grafana.md)| ---| ---| ---| --- <h1 id="start">Grafana and InfluxDB in Docker</h1> ![downloads](https://img.shields.io/github/downloads/atom/atom/total.svg) ![build](https://img.shields.io/appveyor/ci/:user/:repo.svg) ![chat](https://img.shields.io/discord/:serverId.svg) --- <h2 id="Contents">Table of Contents</h2> - [Grafana and InfluxDB in Docker](#start) - [Table of Contents](#Contents) - [Guide](#Guide) - [Architecture](#Architecture) - [Docker Compose for Grafana](#Grafana) - [Docker Compose for InfluxDB](#InfluxDB) - [On Grafana use InfluxDB](#useInfluxDB) - [Dashboards](#Dashboards) - [Related Posts](#Related) - [Appendix and FAQ](#Appendix) --- <h2 id="Guide">Guide</h2> 1. Create a Docker Compose for Grafana. 2. Create a Docker Compose for InfluxDB. 3. Connect to InfluxDB on Grafana. 4. Upload JSON file (Dashboard) to Grafana. --- <h2 id="Architecture">Architecture</h2> ``` . ├── docker-compose.yml └── volume ├── grafana │ ├── conf │ └── data └── influxdb ├── conf └── data ``` --- <h2 id="Grafana">Docker Compose for Grafana</h2> --- ```yaml= version: '3' services: grafana: image: grafana/grafana hostname: grafana restart: always ports: - 3000:3000 ``` > Run `sudo docker compose up` to start the Grafana, try the server is ok. ```yaml= version: '3' services: grafana: image: grafana/grafana hostname: grafana restart: always ports: - 3000:3000 volumes: - ./volume/grafana/data:/var/lib/grafana:rw - ./volume/grafana/conf/grafana.ini:/etc/grafana/grafana.ini:ro ``` > Use the `volumes` feature of Docker. Map the folder located at `/var/lib/grafana` from the docker container to a folder located at `./volume/grafana/data` on local machine. Every file add, remove or update into this folder locally will be updated into the container. > If you wish to adapt the default configuration, use something like the following to copy it from a running grafana container: ``` $ sudo docker run --name tmp-grafana-container -d grafana $ sudo docker cp tmp-grafana-container:/etc/grafana/grafana.ini volume/grafana/conf/grafana.ini $ sudo docker cp tmp-grafana-container:/var/lib/grafana volume/grafana/data $ sudo docker rm -f tmp-grafana-container ``` ```yaml= version: '3' services: grafana: image: grafana/grafana hostname: grafana restart: always ports: - 3000:3000 volumes: - ./volume/grafana/data:/var/lib/grafana:rw - ./volume/grafana/conf/grafana.ini:/etc/grafana/grafana.ini:ro environment: - GF_INSTALL_PLUGINS=grafana-clock-panel,ryantxu-ajax-panel,volkovlabs-image-panel ``` --- <h2 id="InfluxDB">Docker Compose for InfluxDB</h2> Use the docker image for certbot and add it as a service to Docker Compose project. ```yaml= version: '3' services: grafana: image: grafana/grafana hostname: grafana restart: always ports: - 3000:3000 volumes: - ./volume/grafana/data:/var/lib/grafana:rw - ./volume/grafana/conf/grafana.ini:/etc/grafana/grafana.ini:ro environment: - GF_INSTALL_PLUGINS=grafana-clock-panel,ryantxu-ajax-panel,volkovlabs-image-panel influxdb: image: influxdb hostname: influxdb restart: always volumes: - ./volume/influxdb/data:/var/lib/influxdb2:rw - ./volume/influxdb/conf/config.yml:/etc/influxdb2/config.yml:ro - ./volume/influxdb/initdb/initdb.sh:/docker-entrypoint-initdb.d/initdb.sh:ro environment: - DOCKER_INFLUXDB_INIT_USERNAME=admin - DOCKER_INFLUXDB_INIT_PASSWORD=Vatten123 - DOCKER_INFLUXDB_INIT_ORG=vatten - DOCKER_INFLUXDB_INIT_BUCKET=grafana - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=Aa12345678901234567890 ``` > Restart container using `sudo docker compose restart`. InfluxDB should now have access to Grafana. --- <h2 id="useInfluxDB">On Grafana use InfluxDB</h2> --- <h2 id="Related">Related Posts</h2> - Reference - https://www.blackvoid.club/grafana-8-influxdb-2-telegraf-2021-monitoring-stack/ <h2 id="Appendix">Appendix and FAQ</h2> :::info **Find this document incomplete?** Leave a comment! ::: ###### tags: `Grafana` `Docker` `InfluxDB` --- |[Nginx and Certbot in Docker](https://github.com/xuan103/Docker-Grafana_Nginx/blob/main/document/Nginx%20and%20Certbot%20in%20Docker.md)|[Table of Contents](https://github.com/xuan103/Docker-Grafana_Nginx/blob/main/README.md)|[Setup Grafana](https://github.com/xuan103/Docker-Grafana_Nginx/blob/main/document/Setup%20Grafana.md)| ---| ---| ---|