软件组件:
prometheus
alertmanager
prometheus-webhook-dingtalk

nginx-vts-exporter
nginx

(###--add-module=../nginx-module-vts/)

1、安装prometheus
2、安装alertmanager
3、nginx-vts-exporter

#cat docker-compose.yml
version: '2'
services:
alertmanager:
image: docker.io/prom/alertmanager
container_name: alertmanager
ports:
- 9093
volumes:
- /etc/prometheus/alertmanager.yml:/etc/prometheus/alertmanager.yml
network_mode: host
prometheus:
image: prom/prometheus
container_name: prometheus
ports:
- 9090
volumes:
- /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- /data/prometheus-data:/prometheus-data
- /etc/prometheus/rules.yml:/etc/prometheus/rules.yml

network_mode: host

nginx-vts-exporter:
image: sophos/nginx-vts-exporter
container_name: nginx-vts-exporter
ports:
- 9913
environment:
- NGINX_STATUS=http://127.0.0.1:11111/vt-status/format/json
network_mode: host

##cat /etc/prometheus/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: [ "127.0.0.1:9093"]

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "/etc/prometheus/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: 'prometheus_nginx'
static_configs:
- targets: ['127.0.0.1:9913']
- job_name: 'docker'
static_configs:
- targets: ['192.168.0.200:9999']

#cat /etc/prometheus/rules.yml
groups:

- name: test-rule
rules:
- alert: NodeFilesystemUsage
expr: (node_filesystem_size{device="rootfs"} - node_filesystem_free{device="rootfs"}) / node_filesystem_size{device="rootfs"} * 100 > 80
for: 2m
labels:
team: node
annotations:
summary: "{{$labels.instance}}: High Filesystem usage detected"
description: "{{$labels.instance}}: Filesystem usage is above 80% (current value is: {{ $value }}"

- alert: NodeMemoryUsage
expr: nginx_server_bytes > 100
for: 2m
labels:
team: node
annotations:
summary: "nginx_server_bytes too 100"
description: "{{$labels.instance}}: nginx_server_bytes (current value is: {{ $value }}"

#cat /etc/prometheus/alertmanager.yml
global:
resolve_timeout: 5m

route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 5m
receiver: 'send_to_dingding_webhook1'

receivers:
- name: 'send_to_dingding_webhook1'
webhook_configs:
- send_resolved: true
url: 'http://127.0.0.1:8060/dingtalk/webhook1/send'

inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']

#
nohup ./prometheus-webhook-dingtalk --web.listen-address=":8060" --ding.profile="webhook1=https://oapi.dingtalk.com/robot/send?access_token=682fdfb7c9b83670f32a0a1549187ff16fe36ebc2dcfab9747cd3122dbefa6dd" &

##启动
docker-compose up -d

4、安装nginx (略)
--user=nginx --group=nginx --prefix=/opt/app/nginx --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --add-module=../nginx-module-vts/ --with-http_image_filter_module=dynamic

配置nginx.conf
http {
vhost_traffic_status_zone;

vhost_traffic_status_filter_by_host on;
...
}

server{

listen 11111;
server_name 127.0.0.1;
location /vt-status {
stub_status on;
access_log off;

}
location /vt-status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}

}

prometheus(docker)安装和报警 -- nginx域名监控的更多相关文章

  1. docker安装并修改Nginx镜像

    1.安装nginx镜像,命令:docker pull nginx 2.创建nginx容器,并启动,命令:docker run --name webserver -d -p 192.168.51.227 ...

  2. Docker 安装并定制 Nginx 服务器

    安装并定制 Nginx 1.查阅对应的官方文档,首先下载镜像文件: [spider@izwz9d74k4cznxtxjeeur9z local]$ sudo docker pull nginx [su ...

  3. docker安装与配置nginx详细过程

    注:大鸟飞过,此方式只用于快速搭建使用 第一步 pull nginx 命令:docker pull nginx 第二步 启动nginx 命令:docker run --name nginx -p 80 ...

  4. Docker安装mysql、nginx、redis、tomcat

    拉取mysql 5.7官方镜像 docker pull mysql:5.7 启动容器 docker run --name mysql5.7 -p 3306:3306 -e MYSQL_ROOT_PAS ...

  5. Docker安装Mysql和Nginx

    1. 序言 将应用容器化更方便于管理,昨天辛辛苦苦安装在宿主机上的,今天狠心重置服务器,学下docker练练手. 2. Get start 2.1 安装Docker 公司的云用的是ubuntu,我自己 ...

  6. docker安装和配置nginx

    配置nginx docker配置nginx 本机ip是192.168.0.200 docker pull nginx 配置nginx主机 vi /root/docker/nginx/nginx01.c ...

  7. docker安装部署PHP nginx

    sudo tee /etc/yum.repos.d/docker.repo <<-'EOF' [dockerrepo] name=Docker Repository baseurl=htt ...

  8. mac环境下使用docker安装nginx

    前言 距离上一篇文章已经很长时间,近期实在事情太多了,也没来得及继续更新一些新的内容.现在开发使用的工作实在太多了,小编实在忍受不了windows那样卡机的状态,于是最近换了一个mac电脑,虽然做开发 ...

  9. 使用docker安装nginx并配置端口转发

    使用docker安装并运行nginx命令: docker run --name=nginx -p 80:80 -d docker.io/nginx 使用命令: docker exec -it ngin ...

随机推荐

  1. Java 字符串(一)字符串初始化

    一.String类概述 1.概述 java.lang.String 类代表字符串.Java程序中所有的字符串文字(例如 "abc" )都可以被看作是实现此类的实例.String 是 ...

  2. 机器学习10种经典算法的Python实现

    广义来说,有三种机器学习算法 1. 监督式学习 工作机制:这个算法由一个目标变量或结果变量(或因变量)组成.这些变量由已知的一系列预示变量(自变量)预测而来.利用这一系列变量,我们生成一个将输入值映射 ...

  3. FFmpeg Windows下安装与测试

    FFmpeg 简介 FFmpeg的名称来自MPEG视频编码标准,前面的"FF"代表"Fast Forward",FFmpeg是一套可以用来记录.转换数字音频.视 ...

  4. vue2.0 在页面中使用process获取全局路径的时候 报错 process is not defined

    如果是刚配置好的全局变量需要 重新启动一下vue才能通过proccess.env.xxx 获取到 如果想在html中使用 需要在data中声明一个变量 然后在vue生命周期中 将process.env ...

  5. mysql IFNULL

    IFNULL(v1,v2); 其中:如果 v1 不为 NULL,则 IFNULL 函数返回 v1; 否则返回 v2 的结果.

  6. C语言 dlopen dlsym

    C语言加载动态库 头文件:#include<dlfcn.h> void * dlopen(const char* pathName, int mode); 返回值 handle void ...

  7. nginx+Gunicorn部署你的Flask项目

    https://www.cnblogs.com/minsons/articles/8191219.html 大家在学习python的时候常常都是输入 python 文件名.py 这样启动小脚本 但实际 ...

  8. Dump文件的生成和使用

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/lk142500/article/detai ...

  9. js 递归 汉诺塔的例子

    程序调用自身的编程技巧称为递归. //汉诺塔的游戏,n为圆盘编号数量,编号,a,b,c代表的是三个柱子 var hanio=function(n,a,b,c){     if(n>0){    ...

  10. 浏览器渲染详细过程:重绘、重排和 composite 只是冰山一角

    https://juejin.im/entry/590801780ce46300617c89b8 渲染 这张很经典的图许多人都看过,其中的概念大家应该都很熟悉,也就是这么几个步骤:js修改dom结构或 ...