Docker_监控平台_组件监控

Grafana+Prometheus+组件

架构图示例:
在这里插入图片描述

组件安装

node-exporter

#下载镜像
docker pull prom/node-exporter
#运行
docker run -d \
 -p 9100:9100 \
  quay.io/prometheus/node-exporter
#运行
docker run -d \
  -p 9100:9100 \
  --name node-exporter \
  -v "/proc:/host/proc" \
  -v "/sys:/host/sys" \
  -v "/:/rootfs" \
  --net="host" \
  quay.io/prometheus/node-exporter \
    -collector.procfs /host/proc \
    -collector.sysfs /host/sys \
    -collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"

mysqld_exporter

#配置授权
mysql> CREATE USER 'mysql_monitor'@'localhost' IDENTIFIED BY 'mysql_monitor' WITH MAX_USER_CONNECTIONS 3;
mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysql_monitor'@'localhost';
mysql> FLUSH PRIVILEGES;
#运行
docker run -d \
 -p 9104:9104 \
 -e DATA_SOURCE_NAME="mysql_monitor:mysql_monitor@(10.10.0.186:3306)/" prom/mysqld-exporter

redis_exporter

#下载镜像
docker pull oliver006/redis_exporter
#运行
docker run -d \
--name redis_exporter \
-p 9121:9121 \
oliver006/redis_exporter --redis.addr redis://192.168.10.208:6379

Prometheus

创建配置文件

#创建目录并授权
sudo mkdir /usr/local/src/file/prometheus
sudo chown 767 /usr/local/src/file/prometheus
#编写配置文件
prometheus.yml,并存放到/usr/local/src/file/prometheus目录下

# my global config
global:   # 全局设置,可以被覆盖
  scrape_interval:     15s # 默认值为 15s,用于设置每次数据收集的间隔
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# 告警管理配置
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'  # 采集 Prometheus 自身的 metrics

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

    static_configs:
    - targets: ['localhost:9090']  # Prometheus的endpoint

  - job_name: 'redis'
    static_configs:
     - targets: ['192.168.142.130:9121']  # Prometheus会定期请求这个网址,来获取你想记录的数据
       labels:
         instance: redis

  - job_name: 'linux'
    static_configs:
     - targets: ['192.168.142.130:9100']  # node_exporter 的 endpoint
       labels:
         instance: node
  - job_name: mysql
	  static_configs:
	    - targets: ['10.10.0.186:9104']
	      labels:
	        instance: mysql

安装Prometheus

#下载镜像
docker pull prom/prometheus
#运行
sudo docker run -d \
  -p 9090:9090 \
  -v /usr/local/src/file/prometheus.yml:/usr/local/src/file/prometheus/prometheus.yml \
  quay.io/prometheus/prometheus \
  --config.file=/usr/local/src/file/prometheus/prometheus.yml

浏览器查看

192.168.142.130:9090
在这里插入图片描述

Grafana

安装Grafana

#下载镜像
docker pull grafana/grafana
#运行
docker run -d --name=grafana -p 3000:3000 grafana/grafana

组件配置

http://192.168.142.130:3000登录 默认(admin/admin)
(1)配置数据源
在这里插入图片描述
(2)下载模板
redis监控模板 https://grafana.com/api/dashboards/763/revisions/1/download 下载 鼠标放在grafana+点击import导入
在这里插入图片描述

Guess you like

Origin blog.csdn.net/qq_15764943/article/details/88343332