Install Grafana using Docker
Overview
After completing installation of Docker on Windows in the previous tutorial, will see how to download a specific image or set of images using docker pull command.
Docker Tutorial :
- Install Docker On Windows
- Docker Hello World Example
- Install Prometheus using Docker
- Install Grafana using Docker
- Install RabbitMQ using Docker
Q: What is Grafana?
Ans:
Grafana is an open source tool for performing data analytics, retrieving metrics that make sense of large amounts of data, and monitoring our apps using nice configurable dashboards.
Grafana integrates with a wide range of data sources, including Graphite, Prometheus, Influx DB, ElasticSearch, MySQL, PostgreSQL, and others. When connected to supported data sources, it provides web-based charts, graphs, and alerts.
What is Docker?
Docker is a set of platform as a service tools that deliver software in containers using OS-level virtualization. Containers are self-contained, containing their own software, libraries, and configuration files, and communicating with one another via well-defined channels. Docker makes it simple for developers to package, ship, and execute any application as a lightweight, portable, self-contained container that can operate almost anywhere.
Pull an image from Docker Hub
Use docker pull to download a specific image or set of images (i.e., a repository). If no tag is specified, Docker Engine defaults to the :latest tag. This command retrieves the latest image:
Using the docker pull command, you can get the Grafana docker image -
$ docker run -d --name=grafana -p 3000:3000 grafana/grafana
The image ID is a SHA256 digest covering the image's configuration and layers, and Docker uses a content-addressable image store.
Multiple layers can be included in a Docker image. The image in the example above has below layers as shown.
Once the image has been downloaded, use the docker image ls
command to see a list of
all the images available locally.
C:\Users>docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
grafana/grafana latest 38209d2ec29a 2 weeks ago 206MB
docker/getting-started latest 083d7564d904 3 weeks ago 28MB
hello-world latest d1165f221234 4 months ago 13.3kB
The above command would start Grafana in a Docker container and allow access on port 3000 on the
Host system.
To see a list of Docker containers, execute docker container ls.
C:\Users>docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ef7128b30d63 grafana/grafana "/run.sh" 1 hour ago Up 1 hour 0.0.0.0:3000->3000/tcp grafana
c6534ab34055 prom/prometheus "/bin/prometheus --câ¦" 22 hours ago Up 22 hours 0.0.0.0:9090->9090/tcp, :::9090->9090/tcp prometheus
Finally, You may now access Grafana by going to http://localhost:3000
and logging in with the default login admin
and password admin
.
Importing metrics data from Prometheus into Grafana
Refer Spring Boot + Prometheus + Grafana Example to fetch the data from the application to visualize in the Grafana dashboard using Prometheus.
Add the Prometheus data source in Grafana
Click on Data Sources -> Prometheus.- Provide the required details as given below:
- After you've input all of your data correctly, click Save & Test.
- After that, go to the Dashboard tab and select Import to load the prometheus data.
- Once you've clicked on "Prometheus Stats," you'll see a grafana graph consuming Prometheus data.