Setting Up Grafana with Prometheus Data Source in Docker

image_print

Introduction:
Grafana is a popular open-source data visualization and monitoring tool. In this guide, we’ll show you how to set up Grafana using Docker and configure it to use Prometheus as a data source.

Step 1: Install Grafana with Docker
To install Grafana and run it in Docker, use the following command:

docker run -d --name=grafana -p 3000:3000 -v grafana_data:/data grafana/grafana

Explanation of options used:

  • -d: Run the container in the background (detached mode).
  • --name=grafana: Assign the name “grafana” to the container for easy management.
  • -p 3000:3000: Map port 3000 from the container to the host system. This allows you to access Grafana’s web interface at http://localhost:3000.
  • -v grafana_data:/data: Create a Docker volume named “grafana_data” and mount it to the /data directory inside the container. This volume allows you to persist Grafana’s data and configurations.

Step 2: Access Grafana Web Interface
Once the Grafana container is running, you can access the web interface by opening a web browser and navigating to http://localhost:3000.

Step 3: Change Default Admin Credentials
Log in to Grafana using the default admin credentials (username: “admin,” password: “admin”). You’ll be prompted to change the password upon initial login.

Step 4: Add Prometheus Data Source
To add Prometheus as a data source in Grafana, follow these steps:

  1. Click on the gear icon (Configuration) in the left sidebar, then select “Data Sources.”
  2. Click on the “Add data source” button.
  3. Choose “Prometheus” from the list of data sources.
  4. In the “HTTP” section, set the URL to the address of your Prometheus server, in this case, http://192.168.0.223:9090.
  5. Click “Save & Test” to verify the connection to Prometheus. If successful, you’ll see a green notification.

Step 5: Start Creating Dashboards
With Prometheus as the data source, you can start creating dashboards and visualizations in Grafana to monitor and analyze your data.

Conclusion:
You’ve successfully set up Grafana using Docker and configured it to use Prometheus as a data source. Grafana provides a user-friendly interface for visualizing data from various sources, and with Prometheus as a backend, you can easily create powerful monitoring dashboards.

Happy data visualization and monitoring!

You may also like...