How to Visualize Your Data with Grafana

Learn a powerful data monitoring tool

Lynn Kwong
9 min readJan 9, 2022

--

Grafana is a very powerful tool to visualize data. You can use it to build powerful analytical or monitoring dashboards for all kinds of data sources. You can version and share your dashboards with your team very conveniently. Besides, you can use custom variables in Grafana to make your dashboards more flexible and interactive. In this article, we will introduce how to set up Grafana locally and how to build powerful dashboards with it.

Image by kreatikar on Pixabay.

We will use Docker to create a Grafana server locally. It is recommended to use a Docker container locally because you can always use the latest version of Grafana and won’t have issues with system libraries. Therefore, be sure to have Docker and docker-compose installed properly on your computer. It’s recommended to follow the instructions on the official pages of Docker and docker-compose, rather than using third-party installation scripts. Docker and docker-compose are very extensively used in modern software development practice. It’s worth spending some time learning the basics and getting them installed properly.

The docker-compose.yaml file used in this article is:

Keypoints for this file:

  • Besides Grafana, we also create a MySQL service that will serve as the data source for Grafana. You can use all kinds of data sources. We use MySQL because it is pretty simple to set up and most of us know something about SQL.
  • We use high ports (13000 and 13306) for the Docker containers to avoid potential port conflicts with your local services.
  • A volume is created and mounted for Grafana and MySQL, respectively. In this way, the data won’t be lost if the services are restarted.
  • We specify the root password for MySQL as an environment variable. In practice, you will normally use a .env file and specify it by the env_file keyword. Also, you will create a user with just viewing privileges for Grafana in practice, rather than using…

--

--

Lynn Kwong

I’m a Software Developer (https://superdataminer.com) keen on sharing thoughts, tutorials, and solutions for the best practice of software development.