• 使用docker部署prometheus和grafana 并监控mysql 配置告警


     上图是发送告警的截图

     grafana 监控mysql的图片

    需要部署5个容器

    docker run -d -p 9104:9104 --network mysql-network --name mysql-exporter -e DATA_SOURCE_NAME="root:123456@(192.168.244.13:3306)/" prom/mysqld-exporter
    
    docker run  -d -p 9090:9090 --name prometheus -v E:docker-configsprometheus.yml:/etc/prometheus/prometheus.yml -v E:docker-configs
    ules1.rules:/usr/local/prometheus/rules/1.rules prom/prometheus
     
    docker run -d -p 3000:3000 --name=grafana -v E:docker-configsgrafana-storage:/var/lib/grafana grafana/grafana
    
    docker run --name alertmanager -d -p 9093:9093 prom/alertmanager:latest
    

      

    prometheus.yml
    global:
      scrape_interval:     60s
      evaluation_interval: 60s
    alerting: 
      alertmanagers:
        - static_configs:
          - targets: [192.168.244.13:9093]
    rule_files:
      - "/usr/local/prometheus/rules/*.rules"
    scrape_configs:
      - job_name: prometheus
        static_configs:
          - targets: ['localhost:9090']
            labels:
              instance: prometheus
     
      - job_name: mysql
        static_configs:
          - targets: ['192.168.244.13:9104']
            labels:
              instance: mysql-master
    

    1.rules

    groups:
    - name: node-up
      rules:
      - alert: node-up
        expr: mysql_global_status_mysqlx_sessions{job="mysql"} == 0
        for: 15s
        labels:
          severity: 1
          team: node
        annotations:
          summary: "{{ $labels.instance }} 已停止运行!"
          description: "{{ $labels.instance }} 检测到异常停止!请重点关注!!!"
    

      

  • 相关阅读:
    IDE-常用插件
    Go-竞态条件-锁
    Go-发送邮件
    复刻网络Yum源配置为本地Yum源使用
    测试
    九.查找算法
    九.多线程-PDF笔记
    八.设计模式
    八.排序算法:复杂度
    七.注解
  • 原文地址:https://www.cnblogs.com/zhongshuiping/p/15099323.html
Copyright © 2020-2023  润新知