상세 컨텐츠

본문 제목

모니터링 시스템 Prometheus 설치 #2 (docker & grafana )

Ops/Monitoring

by 크리두 2020. 2. 18. 11:53

본문

반응형

도커 사용해서 모니터링 페이지 만들기

 

dockprom 이용

 

git clone https://github.com/stefanprodan/dockprom.git

https://github.com/stefanprodan/dockprom

 

stefanprodan/dockprom

Docker hosts and containers monitoring with Prometheus, Grafana, cAdvisor, NodeExporter and AlertManager - stefanprodan/dockprom

github.com

Prerequisites:

Docker Engine >= 1.13
Docker Compose >= 1.11

 

  • Containers 구성
    • Prometheus (metrics database) http://:9090
    • Prometheus-Pushgateway (push acceptor for ephemeral and batch jobs) http://:9091
    • AlertManager (alerts management) http://:9093
    • Grafana (visualize metrics) http://:3000
    • NodeExporter (host metrics collector)
    • cAdvisor (containers metrics collector)
    • Caddy (reverse proxy and basic auth provider for prometheus and alertmanage

 

실행 방법

cd dockprom; ADMIN_USER=admin ADMIN_PASSWORD='admin' docker-compose up -d

ADMIN_USER=admin ADMIN_PASSWORD='admin' --→ container들의 ID / PW 설정
예를 들어 grafana 접속하려면 이 내용대로 접속

 

설정

더보기
version: '2.1'

networks:
  monitor-net:
    driver: bridge

volumes:
    prometheus_data: {}
    grafana_data: {}

services:

  prometheus:
    image: prom/prometheus:v2.15.2
    container_name: prometheus
    volumes:
      - ./prometheus:/etc/prometheus
      - ./prometheus_data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/etc/prometheus/console_libraries'
      - '--web.console.templates=/etc/prometheus/consoles'
      - '--storage.tsdb.retention.time=200h'
      - '--web.enable-lifecycle'
    restart: unless-stopped
    expose:
      - 9090
    networks:
      - monitor-net
    labels:
      org.label-schema.group: "monitoring"

  alertmanager:
    image: prom/alertmanager:v0.20.0
    container_name: alertmanager
    volumes:
      - ./alertmanager:/etc/alertmanager
    command:
      - '--config.file=/etc/alertmanager/config.yml'
      - '--storage.path=/alertmanager'
    restart: unless-stopped
    expose:
      - 9093
    networks:
      - monitor-net
    labels:
      org.label-schema.group: "monitoring"

  nodeexporter:
    image: prom/node-exporter:v0.18.1
    container_name: nodeexporter
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.rootfs=/rootfs'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
    restart: unless-stopped
    expose:
      - 9100
    networks:
-- VISUAL --
    container_name: cadvisor
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker:/var/lib/docker:ro
      #- /cgroup:/cgroup:ro #doesn't work on MacOS only for Linux
    restart: unless-stopped
    expose:
      - 8080
    networks:
      - monitor-net
    labels:
      org.label-schema.group: "monitoring"

  grafana:
    image: grafana/grafana:6.6.1
    container_name: grafana
    volumes:
      - ./grafana_data:/var/lib/grafana
      - ./grafana/provisioning:/etc/grafana/provisioning
    environment:
      - GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
      - GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
      - GF_USERS_ALLOW_SIGN_UP=falsei
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_NAME=Main Org.
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
    restart: unless-stopped
    expose:
      - 3000
    networks:
      - monitor-net
    labels:
      org.label-schema.group: "monitoring"

  pushgateway:
    image: prom/pushgateway:v1.1.0
    container_name: pushgateway
    restart: unless-stopped
    expose:
      - 9091
    networks:
      - monitor-net
    labels:
      org.label-schema.group: "monitoring"

  caddy:
    image: stefanprodan/caddy
    container_name: caddy
    ports:
      - "3000:3000"
      - "9090:9090"
      - "9093:9093"
      - "9091:9091"
    volumes:
      - ./caddy:/etc/caddy
    environment:
      - ADMIN_USER=${ADMIN_USER:-admin}
      - ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
    restart: unless-stopped
    networks:
      - monitor-net
    labels:
      org.label-schema.group: "monitoring"

 

 

기본 세팅으로 진행하고 실행하고, 저는 여기서 grafana 설정을 추가했습니다.

로그인 없이 grafana로 접속되고, 관리자는 로그인하면 수정 가능하도록 설정

 

- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_NAME=Main Org.
- GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer

ORG_ROLE 파라미터는 Admin / Editor / Viewer 선택해서 설정

자세한 내용은 아래 링크 클릭

 

https://grafana.com/docs/grafana/latest/permissions/organization_roles/

 

Organization Roles

Organization Roles Users can be belong to one or more organizations. A user’s organization membership is tied to a role that defines what the user is allowed to do in that organization. Admin Role Can do everything scoped to the organization. For example:

grafana.com

 

완성된 모습

 

반응형

'Ops > Monitoring' 카테고리의 다른 글

리눅스 로그 관리 - Logrotate  (0) 2020.11.03
fluentd 설치 및 설정  (0) 2020.04.07
fluentd 설치 (CentOS 7)  (0) 2020.01.10
fluentd 설정 및 도커화 (CentOS 7)  (0) 2020.01.10
Fleunt Bit 설치 및 세팅  (0) 2020.01.07

관련글 더보기

댓글 영역