使用docker部署grafana+prometheus配置

docker-compose-monitor.yml

version: '2'

networks:
  monitor:
    driver: bridge

services:
  influxdb:
    image: influxdb:latest
    container_name: tig-influxdb
    ports:
      - "18083:8083"
      - "18086:8086"
      - "18090:8090"
    env_file:
      - 'env.influxdb'
    volumes:
      # Data persistency
      # sudo mkdir -p ./influxdb/data
      - ./influxdb/data:/var/lib/influxdb
      # 配置docker里的时间为东八区时间
      - ./timezone:/etc/timezone:ro
      - ./localtime:/etc/localtime:ro
    restart: unless-stopped #停止后自动

  telegraf:
    image: telegraf:latest
    container_name: tig-telegraf
    links:
      - influxdb
    volumes:
      - ./telegraf.conf:/etc/telegraf/telegraf.conf:ro
      - ./timezone:/etc/timezone:ro
      - ./localtime:/etc/localtime:ro
    restart: unless-stopped
  prometheus:
    image: prom/prometheus
    container_name: prometheus
    hostname: prometheus
    restart: always
    volumes:
      - /home/qa/docker/grafana/prometheus.yml:/etc/prometheus/prometheus.yml
      - /home/qa/docker/grafana/node_down.yml:/etc/prometheus/node_down.yml
    ports:
      - '9090:9090'
    networks:
      - monitor

  alertmanager:
    image: prom/alertmanager
    container_name: alertmanager
    hostname: alertmanager
    restart: always
    volumes:
      - /home/qa/docker/grafana/alertmanager.yml:/etc/alertmanager/alertmanager.yml
    ports:
      - '9093:9093'
    networks:
      - monitor

  grafana:
    image: grafana/grafana:6.7.4
    container_name: grafana
    hostname: grafana
    restart: always
    ports:
      - '13000:3000'
    networks:
      - monitor

  node-exporter:
    image: quay.io/prometheus/node-exporter
    container_name: node-exporter
    hostname: node-exporter
    restart: always
    ports:
      - '9100:9100'
    networks:
      - monitor

  cadvisor:
    image: google/cadvisor:latest
    container_name: cadvisor
    hostname: cadvisor
    restart: always
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
    ports:
      - '18080:8080'
    networks:
      - monitor

alertmanager.yml

global:
  resolve_timeout: 5m
  smtp_from: '邮箱'
  smtp_smarthost: 'smtp.exmail.qq.com:25'
  smtp_auth_username: '邮箱'
  smtp_auth_password: '密码'
  smtp_require_tls: false
  smtp_hello: 'qq.com'
route:
  group_by: ['alertname']
  group_wait: 5s
  group_interval: 5s
  repeat_interval: 5m
  receiver: 'email'
receivers:
- name: 'email'
  email_configs:
  - to: '收件邮箱'
    send_resolved: true
inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['alertname', 'dev', 'instance']

prometheus.yml

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: ['192.168.32.117:9093']
      # - alertmanager:9093

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

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # IO存储节点组
  - job_name: 'io'
    scrape_interval: 8s
    static_configs:     #端口为node-exporter启动的端口 
      - targets: ['192.168.32.117:9100']
      - targets: ['192.168.32.196:9100']
      - targets: ['192.168.32.136:9100']
      - targets: ['192.168.32.193:9100']
      - targets: ['192.168.32.153:9100']
      - targets: ['192.168.32.185:9100']
      - targets: ['192.168.32.190:19100']
      - targets: ['192.168.32.192:9100']

  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'cadvisor'
    static_configs:     #端口为cadvisor启动的端口
      - targets: ['192.168.32.117:18080']
      - targets: ['192.168.32.193:8080']
      - targets: ['192.168.32.153:8080']
      - targets: ['192.168.32.185:8080']
      - targets: ['192.168.32.190:18080']
      - targets: ['192.168.32.192:18080']

node_down.yml

groups:
  - name: node_down
    rules:
      - alert: InstanceDown
        expr: up == 0
        for: 1m
        labels:
          user: test
        annotations:
          summary: 'Instance {{ $labels.instance }} down'
          description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minutes.'

        #剩余内存小于10%
      - alert: 剩余内存小于10%
        expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10
        for: 2m
        labels:
          severity: warning
        annotations:
          summary: Host out of memory (instance {{ $labels.instance }})
          description: "Node memory is filling up (< 10% left)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"

        #剩余磁盘小于10%
      - alert: 剩余磁盘小于10%
        expr: (node_filesystem_avail_bytes * 100) / node_filesystem_size_bytes < 10 and ON (instance, device, mountpoint) node_filesystem_readonly == 0
        for: 2m
        labels:
          severity: warning
        annotations:
          summary: Host out of disk space (instance {{ $labels.instance }})
          description: "Disk is almost full (< 10% left)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"

        #cpu负载 > 80%
      - alert: CPU负载 > 80%
        expr: 100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[2m])) * 100) > 80
        for: 0m
        labels:
          severity: warning
        annotations:
          summary: Host high CPU load (instance {{ $labels.instance }})
          description: "CPU load is > 80%\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"

告警:https://awesome-prometheus-alerts.grep.to/rules#prometheus-self-monitoring

官网仪表盘:https://grafana.com/grafana/dashboards/

到此这篇关于docker部署grafana+prometheus配置的文章就介绍到这了,更多相关docker部署grafana+prometheus内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • 基于docker 搭建Prometheus+Grafana的过程详解

    一.介绍Prometheus Prometheus(普罗米修斯)是一套开源的监控&报警&时间序列数据库的组合,起始是由SoundCloud公司开发的.随着发展,越来越多公司和组织接受采用Prometheus,社会也十分活跃,他们便将它独立成开源项目,并且有公司来运作.Google SRE的书内也曾提到跟他们BorgMon监控系统相似的实现是Prometheus.现在最常见的Kubernetes容器管理系统中,通常会搭配Prometheus进行监控. Prometheus基本原理是通过HTT

  • Docker 部署 Prometheus的安装详细教程

    目录 1.安装Node Exporter 2.安装cAdvisor 3.安装 Prometheus Server 4.创建运行Grafana 5.添加监控模板 6.键值查询 7.使用Prometheus监控 8.各个监控项的含义 9.Prometheus UI中Target表达式查询 10.安装blackbox_exporter 11.Docker部署nginx-module-vts模块 Docker 搭建 Consul集群(未完) Docker 部署 Prometheus 说明: 监控端安装:

  • 使用docker部署grafana+prometheus配置

    docker-compose-monitor.yml version: '2' networks: monitor: driver: bridge services: influxdb: image: influxdb:latest container_name: tig-influxdb ports: - "18083:8083" - "18086:8086" - "18090:8090" env_file: - 'env.influxdb'

  • Docker部署Nginx并配置反向代理

    准备工作 在docker内部署任何应用,都需要先下载对应的镜像:下载镜像之前,需要先搜索镜像来确认该镜像是否存在: docker search nginx 从列表可以看到,docker已经有了nginx的镜像,名称是“nginx”,接下来下载镜像: docker pull nginx 下载完成后,查看一下本地镜像: 如果在列表中看到nginx,镜像下载就已经成功了. 容器设置 在docker中,真正运行的是容器,镜像在我理解中是一种环境.我们在指定的镜像中运行某个容器,然后编辑和配置这个容器,从

  • CentOS7使用docker部署Apollo配置中心的实现

    Apollo开源地址: https://github.com/ctripcorp/apollo 第一步 将项目clone到本地,然后在github的releases页面中下载三个zip文件 本文中重点讲解截止2019年1月最新的1.2.0版本的部署方法 第二步 打开clone到本地的项目,目录结构如下 第三步 在此目录下创建docker-compose.yml文件,写入内容: version: "3" services: apollo-configservice: ##容器服务名 co

  • 使用Docker Compose搭建部署ElasticSearch的配置过程

    目录 什么是 Elasticsearch? Elasticsearch 的用途是什么? Elasticsearch 的工作原理是什么? Elasticsearch 索引是什么? 说明 一.目录准备 二.es配置准备 三.准备docker-compose.yml 四.启动容器 五.查看 什么是 Elasticsearch? Elasticsearch 是一个分布式的开源搜索和分析引擎,适用于所有类型的数据,包括文本.数字.地理空间.结构化和非结构化数据.Elasticsearch 在Apache

  • docker部署钉钉机器人报警通知的实现

    本文主要介绍了docker部署钉钉机器人报警通知的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧 目录结构 [root@node1 ~]# tree prom prom ├── docker-compose.yml #docker-compose文件 ├── grafana #grafana数据挂载 ├── prometheus_data #Prometheus数据挂载 ├── rules #报警规则文件 │ ├── c

  • docker 搭建基于prometheus的监控体系步骤实现

    目录 1.启动prometheus容器服务 2.启动成功后,公网访问该9090端口进入普罗米修斯主页 3.部署mysqld-exporer监控mysql数据库(想监控什么就部署对应的exporter即可) 4.重启prometheus服务 5.访问prometheus主页查看mysql的监控 6.将监控数据通过grafana面板展示 Prometheus是一个时间序列数据库.但是,它不仅仅是一个时间序列数据库. 它涵盖了可以绑定的整个生态系统工具集及其功能. Prometheus主要用于对基础设

  • 使用Grafana+Prometheus监控mysql服务性能

    Prometheus(也叫普罗米修斯)官网:https://prometheus.io/docs/introduction/overview/ Grafana官网:https://grafana.com/enterprise 特征 普罗米修斯的主要特点是: 具有由度量名称和键/值对标识的时间序列数据的多维数据模型 一个灵活的查询语言 来利用这一维度 不依赖分布式存储; 单个服务器节点是自治的 时间序列集合通过HTTP上的拉模型发生 推送时间序列通过中间网关支持 通过服务发现或静态配置发现目标 多

  • 用docker部署RabbitMQ环境的详细介绍

    前置条件: 已经安装好docker 1.查找镜像(有2种方式) ①登录rabbitmq官网找到docker镜像,选择想要的镜像的tag https://www.rabbitmq.com/download.html https://hub.docker.com/_/rabbitmq 如果需要访问web管理页面,就选择tag为management的 ps:带有alpine的是用最小linux镜像构建的,体积最小可以达5M初学者不建议这么折腾,而且 Alpine Linux使用了muslmusl实现的

  • Spring Boot与Docker部署详解

    本文介绍了Spring Boot与Docker部署,分享给大家,希望对大家有帮助 开启Docker远程访问 首先需要开启docker远程访问功能,以便可以进行远程操作. CentOS 6 修改/etc/default/docker文件,重启后生效(service docker restart). DOCKER_OPTS="-H=unix:///var/run/docker.sock -H=0.0.0.0:2375"  CentOS 7 打开/usr/lib/systemd/system

随机推荐