top of page

Setting up Grafana with Docker Compose

Updated: Jun 22, 2023

What is Grafana?

Grafana is a tool to create rich dashboards from your metrics.

Grafana can ingest from many different data sources, including Prometheus.

Setting up Grafana with Docker Compose

Configuration

Grafana can work without any configuration files. However, we want to configure Prometheus as a data source, so we create grafana/provisioning/datasources/prometheus_ds.yml.


Configuration file: grafana/provisioning/datasources/prometheus_ds.yml

This configuration file will tell Grafana about Prometheus. You could omit this and add the configuration via the Grafana UI.

Add the following to grafana/provisioning/datasources/prometheus_ds.yml:

datasources:
- name: Prometheus
  access: proxy
  type: prometheus
  url: http://prometheus:9090
  isDefault: true

Docker compose file: docker-compose.yml

Next, add the following to docker-compose.yml to add Grafana:

grafana:
    image: grafana/grafana:7.5.7
    ports:
      - 3000:3000
    restart: unless-stopped
    volumes:
      - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
      - grafana-data:/var/lib/grafana
      
volumes:
  grafana-data:

The first volume points to our data source configuration. The second volume is used to save dashboards etc.

Start

Start Prometheus and Grafana:

docker-compose up -d

and open http://localhost:3000 in your browser. Use user admin with password admin for the first login.

You should see the Grafana Landing Page after login:

Setting up Grafana with Docker Compose

Add the first dashboard

Go to http://localhost:3000/dashboard/new to add a new dashboard (or use the plus sign in the navigation bar).

Click on Add an empty panel.

In the dropdown which says -- Grafana -- select Prometheus. You can select Prometheus here because we added the configuration earlier.

Now we need Grafana to tell what to graph. Add the following PromQL statement to the input field metric:

increase(prometheus_http_requests_total[1m])

This will show you how often Prometheus endpoints were called. To learn more about PromQL, see the official documentation.

Setting up Grafana with Docker Compose

Click on Apply to save and go back to the dashboard. Finally, click on the dashboard save button in the upper right corner.


Your final dashboard

Setting up Grafana with Docker Compose

2 Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Guest
3 days ago

Mình có thói quen xem soi cầu XSMB hằng ngày để nắm nhanh tình hình trước giờ quay, nhất là lúc muốn nhìn lại nhịp ra số mấy hôm gần đây. Khi cần so sánh thêm thì mình ghé qua soi cau mb ở giữa buổi, rồi đối chiếu với mấy bảng dự đoán XSMB kèm thống kê lô gan và lô xiên cho dễ hình dung xu hướng. Trong nhóm mình cũng hay bàn chuyện dữ liệu lịch sử với mấy công cụ quay thử như Rồng Bạch Kim, vì nhìn tần suất thực tế rõ ràng hơn nên đỡ đoán mò. Cá nhân mình thấy dự đoán xổ số miền Bắc không chỉ dựa vào may rủi, mà…

Like

Guest
Aug 11

Mình chơi xổ số kiểu cho vui là chính, coi kết quả như một thói quen giải trí nên cũng không đặt nặng chuyện đổi đời. Trước đây nghe người ta bàn về “cầu” với đủ kiểu mẹo, mình cũng nửa tin nửa ngờ. Nhưng theo dõi một thời gian thì thỉnh thoảng thấy có vài chi tiết lặp lại, làm mình tò mò hơn chút. Mỗi lần đọc mấy bài nhận định, mình hay ghi lại vài ý ngắn rồi để đó, sau đối chiếu xem có phải mình tự gán ý nghĩa không. Có hôm trúng nhẹ thì vui, nhưng cũng nhiều bữa trật hoàn toàn nên mình luôn nhắc bản thân đừng tin quá. Thi thoảng mình…

Like
Stationary photo

Be the first to know

Subscribe to our newsletter to receive news and updates.

Thanks for submitting!

Follow us

©2023 by AirTips

- - - Sharing & Tutorial - - - 

bottom of page