2. grafana provisioning

grafana๋Š” provisioning์ด๋ผ๋Š” ๊ธฐ๋Šฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.

๊ธฐ์กด์—๋Š” datasource์™€ dashboard๋ฅผ ์ˆ˜๋™์œผ๋กœ ๋“ฑ๋กํ•ด์คฌ๋‹ค.

์ด๊ฒƒ๋“ค์„ docker์‹œ์ž‘์‹œ์— ์ž๋™์œผ๋กœ ๋„ฃ์–ด์ฃผ๋Š”๊ฒƒ์ด๋‹ค.

datasource

source-code : https://github.com/teamsmiley/devops-public/tree/main/monitoring/2.grafana-provisioning

Alt text

grafanaํด๋”๋ฅผ ๋งŒ๋“ ํ›„ ์ถ”๊ฐ€๋กœ ๋ช‡๊ฐœ์˜ ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์ค€๋‹ค.

datasources/prometheus.yaml ํŒŒ์ผ์„ ํ™•์ธํ•ด๋ณด์ž.

apiVersion: 1
datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://prometheus:9090
    isDefault: true
    version: 1
    editable: true

์ด์ œ ์ด ํด๋”๋ฅผ ๋งˆ์šดํŠธํ•ด์ฃผ์ž.

grafana:
  image: grafana/grafana
  container_name: grafana
  # network_mode: host
  restart: always
  ports:
    - 3000:3000
  environment:
    - GF_SECURITY_ADMIN_USER=admin
    - GF_SECURITY_ADMIN_PASSWORD=grafana
  volumes:
    - ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards
    - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
    - ./grafana/dashboards:/etc/grafana/dashboards

ํ”„๋กœ๋น„์ €๋‹ ํŒŒ์ผ์€ grafana/provisioning ํด๋”์— / dashboard jsonํŒŒ์ผ์€ dashboards์— ๋„ฃ์–ด์ค€๋‹ค.

์‹คํ–‰ํ•˜์ž.

docker-compose up -d

ํ™•์ธํ•ด๋ณด์ž. http://localhost:3000/dashboards

Alt text

dashboard๊ฐ€ 2๊ฐœ๊ฐ€ ์ž๋™์œผ๋กœ ๋“ฑ๋ก๋œ๊ฒƒ์„ ์•Œ์ˆ˜ ์žˆ๋‹ค.

datasource๋„ ํ™•์ธํ•ด๋ณด์ž.

์ž˜ ๋“ค์–ด์™€ ์žˆ๋‹ค.

Last updated

Was this helpful?