溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

發(fā)布時間:2021-12-13 14:02:56 來源:億速云 閱讀:237 作者:iii 欄目:大數(shù)據(jù)

本篇內(nèi)容介紹了“docker-compose數(shù)據(jù)庫監(jiān)控舉例分析”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!

運維監(jiān)控

監(jiān)控對象:

數(shù)據(jù)采集:

  • prometheus

  • cadvisor

  • node-exporter:

  • redis-exporter

  • mysql-exporter:

報表:

  • grafana

nginx 監(jiān)控需要編譯vfs模塊,筆記麻煩!推薦ELK 使用filebeat 直接收集日志,kibana出報表

docker-compose.yml

version: '2'

services:
  # db server
  redis:
    build: redis/
    container_name: redis
    restart: unless-stopped
    volumes:
      - ~/docker/redis/data:/data
      - ~/docker/redis/conf/master/redis.conf:/etc/redis/redis.conf
    ports:
      - "6379:6379"
  
  # mysql:
  #   build: mysql/
  #   container_name: mysql
  #   restart: unless-stopped
  #   volumes:
  #   #  - ~/docker/mysql/data:/var/lib/mysql
  #     - ~/docker/mysql/data:/var/lib/mysql
  #     - ~/github/docker_db/mysql/conf.d:/etc/mysql/conf.d
  #   ports:
  #     - "3306:3306"
  #   environment:
  #     MYSQL_ROOT_PASSWORD: "mysecretpassword"

  # exporter
  cadvisor:
    image: google/cadvisor:latest
    container_name: cadvisor
    restart: unless-stopped
    ports:
      - '8080:8080'
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
  node-exporter:
    image: prom/node-exporter:latest
    container_name: node-exporter
    restart: unless-stopped
    ports:
      - '9100:9100'
    command:
      - '--path.procfs=/host/proc'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
      - '--collector.textfile.directory=/node_exporter/prom'
    volumes:
      - /:/rootfs:ro
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - ~/docker/prometheus_exporter/prom:/node_exporter/prom

  # mysql exporter
  # mysql-exporter:
  #   image: prom/mysqld-exporter
  #   container_name: mysql-exporter
  #   hostname: mysql-exporter
  #   user: '0'
  #   restart: always
  #   ports:
  #       - "9104:9104"
  #   environment:
  #     # DATA_SOURCE_NAME: "root:yunjingtest@(localhost:3306)"
  #     DATA_SOURCE_NAME: "root:mysecretpassword@(mysql:23306)"
  #   depends_on:
  #     - mysql

  # redis exporter
  redis-exporter:
    image: oliver006/redis_exporter
    container_name: redis-exporter
    hostname: redis-exporter
    restart: always
    ports:
      - "9121:9121"
    command:
      - "--redis.addr=redis://redis:6379"
    depends_on:
      - redis

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    restart: unless-stopped
    ports:
      - '9090:9090'
    # user: '0'
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus/data'
      - '--storage.tsdb.retention=90d'
      - '--web.enable-lifecycle'
    volumes:
      - ./prometheus/conf/prometheus.yml:/etc/prometheus/prometheus.yml
      - ~/docker/prometheus/data:/prometheus/data
    depends_on:
      - cadvisor
      - node-exporter

  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    restart: unless-stopped
    ports:
      - '3000:3000'
    depends_on:
      - prometheus
    volumes:
      - ~/docker/grafana:/var/lib/grafana
    environment:
      - HTTP_USER=admin
      - HTTP_PASS=yunjingtest
      # - GF_SECURITY_ADMIN_PASSWORD=yunjingtest
      # - GF_USERS_ALLOW_SIGN_UP=false
networks:
    db:
        driver: bridge

run:

?  docker_db git:(master) docker-compose up -d
Creating redis         ... done
Creating cadvisor      ... done
Creating node-exporter  ... done
Creating redis-exporter ... done
Creating prometheus     ... done
Creating grafana        ... done
?  docker_db git:(master) docker-compose ps
     Name                   Command               State           Ports
--------------------------------------------------------------------------------
cadvisor         /usr/bin/cadvisor -logtostderr   Up      0.0.0.0:8080->8080/tcp
grafana          /run.sh                          Up      0.0.0.0:3000->3000/tcp
node-exporter    /bin/node_exporter --path. ...   Up      0.0.0.0:9100->9100/tcp
prometheus       /bin/prometheus --config.f ...   Up      0.0.0.0:9090->9090/tcp
redis            docker-entrypoint.sh /usr/ ...   Up      0.0.0.0:6379->6379/tcp
redis-exporter   /redis_exporter --redis.ad ...   Up      0.0.0.0:9121->9121/tcp
?  docker_db git:(master)

web 界面查看

1.prometheus 界面查看job_name

http://localhost:9090/targets docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

2.grafana 查看具體報表

  • redis 狀態(tài)報表

  • prometheus 狀態(tài)報表 dashborad 在granfa官網(wǎng)查找,找到模版id docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

prometheus reids

docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

官方報表模版

監(jiān)控指標 模版id:8919

  • cpu

  • 內(nèi)存

  • 磁盤

  • 系統(tǒng)調(diào)用

  • 網(wǎng)絡io ...

docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

cpu/內(nèi)存:

docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

系統(tǒng)負載/磁盤/網(wǎng)絡io

docker-compose數(shù)據(jù)庫監(jiān)控舉例分析

prometheus.yml

# my global config
global:
    scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
    evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
    # scrape_timeout is set to the global default (10s).
  
# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

  - job_name: 'node-exporter'
    scrape_interval: 5s
    static_configs:
    - targets: ['node-exporter:9100']

  - job_name: 'cadvisor'
    scrape_interval: 5s
    static_configs:
    - targets: ['cadvisor:8080']

  # - job_name: 'mysql-exporter'
  #   scrape_interval: 5s
  #   static_configs:
  #   - targets: ['mysql-exporter:9104']

  # - job_name: 'mysql-exporter-100'
  #   scrape_interval: 5s
  #   static_configs:
  #   - targets: ['mysql-exporter-100:9105']

  - job_name: 'redis-exporter'
    scrape_interval: 5s
    static_configs:
    - targets: ['redis-exporter:9121']

“docker-compose數(shù)據(jù)庫監(jiān)控舉例分析”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI