This tutorial will guide you through setting up and using the Grafana Docker image. The Grafana Docker image is a popular choice for running Grafana in a variety of environments. It's flexible, easy to use, and makes it simple to start monitoring your data.
Before we proceed, I strongly recommend you take a look at Prometheus and Grafana blog post for a deeper understanding of how Prometheus and Grafana can be used together to monitor your system's performance.
Prerequisites
Ensure that you have the following installed:
Docker: Install the latest version of Docker-based on your OS from the official Docker website.
Docker Compose (Optional): If you plan to use Docker Compose, install it from the official Docker Compose website.
Step 1: Pull the Grafana Docker Image
Open your terminal and pull the latest Grafana Docker image using the following command:
docker pull grafana/grafana:latest
Step 2: Run Grafana Docker Container
After pulling the image, run the Grafana container with the following command:
docker run -d -p 3000:3000 grafana/grafana
Here, -d
runs the container in detached mode (in the background) and -p 3000:3000
maps port 3000 of your machine to port 3000 of the Grafana container.
Step 3: Access Grafana
Once the Grafana container is up and running, you can access the Grafana user interface via your web browser by navigating to http://localhost:3000
.
The default username and password are both 'admin'. Upon the first login, you will be prompted to change the default password.
Step 4: Configure Datasource
The next step is to configure a datasource for Grafana to pull data from. Grafana supports many types of data sources, including Prometheus, InfluxDB, Elasticsearch, etc.
If you have Prometheus set up and you'd like to use it as your datasource, you can refer to this detailed guide on Prometheus and Grafana to understand how to add it as a datasource.
Step 5: Create a Dashboard
Once you have the datasource configured, you can start creating dashboards. Go to the 'Dashboard' section and click on 'New Dashboard'. Add panels and select the type of visualization you want for each panel. The query for each panel will be specific to your configured datasource.
And that's it! You've now successfully set up and are using the Grafana Docker image. This can serve as the starting point for more complex Grafana configurations, including setting up alerting and more advanced visualizations.
Happy data monitoring!