使用prometheus+ grafana+nginx-module-vts 模块监控openresty
nginx-module-vts 是一个很不错的nginx 模块,我们可以用来,方便的分析系统的请求状态
同时支持基于prometheus 的监控, 我参考openresty 的docker镜像已经制作了一个集成模块
的镜像 dalongrong/openresty-nginx-module-vts
环境准备
- docker-compose 文件
version: "3"
services:
api:
build: ./
image: dalongrong/demo-ngx-vts
ports:
- "8080:80"
g:
image: grafana/grafana
ports:
- "3000:3000"
p:
image: prom/prometheus
volumes:
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "9090:9090"
- 集成nginx-module-vts的openresty 配置
dockerfile
FROM dalongrong/openresty-nginx-module-vts
COPY nginx.conf usr/local/openresty/nginx/conf/
EXPOSE 80
EXPOSE 443
EXPOSE 88
nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
vhost_traffic_status_zone;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
upstream backend-app {
server 10.15.0.66:80 weight=20 max_fails=2 fail_timeout=30s;
}
server {
listen 80;
charset utf-8;
location / {
index index.html index.htm;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
client_body_buffer_size 10M;
client_max_body_size 10G;
proxy_buffers 1024 4k;
proxy_read_timeout 300;
proxy_next_upstream error timeout http_404;
proxy_pass http://backend-app;
}
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
location /alert {
default_type text/html;
content_by_lua_block{
ngx.say([[<script>alert("error")</script>]])
}
}
location /ip {
default_type text/html;
content_by_lua_block{
ngx.say(ngx.var.remote_addr)
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 88;
server_name localhost;
charset utf-8;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
- prometheus监控配置
prometheus.yml
scrape_configs:
- job_name: nginx
metrics_path: /status/format/prometheus
static_configs:
- targets: ['api:80']
启动&&集成测试
- 启动
docker-compose up -d
- 界面效果
- 集成grafana
添加prometheus datasource 配置
添加dashboard
说明
nginx-module-vts 是一个很方便的模块,集成进openresty 中,我们可以快速的实现系统的信息监控,同时模块的文档也很全,类似的也
有一个基于opentracing 的模块nginx-opentracing
参考资料
https://github.com/rongfengliang/openresty_nginx-module-vts_prometheus_grafana
https://github.com/vozlt/nginx-module-vts
https://github.com/rongfengliang/openresty-nginx-module-vts
https://www.cnblogs.com/rongfengliang/p/9752800.html
使用prometheus+ grafana+nginx-module-vts 模块监控openresty的更多相关文章
- 使用 Prometheus + Grafana 对 Kubernetes 进行性能监控的实践
1 什么是 Kubernetes? Kubernetes 是 Google 开源的容器集群管理系统,其管理操作包括部署,调度和节点集群间扩展等. 如下图所示为目前 Kubernetes 的架构图,由 ...
- Kubernetes使用prometheus+grafana做一个简单的监控方案
前言 本文介绍在k8s集群中使用node-exporter.prometheus.grafana对集群进行监控.其实现原理有点类似ELK.EFK组合.node-exporter组件负责收集节点上的me ...
- Prometheus+Grafana+Alertmanager搭建全方位的监控告警系统
prometheus安装和配置 prometheus组件介绍 1.Prometheus Server: 用于收集和存储时间序列数据. 2.Client Library: 客户端库,检测应用程序代码,当 ...
- 微服务监控之三:Prometheus + Grafana Spring Boot 应用可视化监控
一.Springboot增加Prometheus 1.Spring Boot 应用暴露监控指标,添加如下依赖 <dependency> <groupId>org.springf ...
- prometheus+grafana监控mysql最佳实践
导航 前言 环境准备 安装Docker 安装prometheus 安装mysqld_exporter prometheus采集数据 安装grafana grafana配置数据源 感谢您的阅读,预计阅读 ...
- 实战开发一个Nginx扩展 (Nginx Module)
repo地址 https://github.com/wujunze/nginx-http-echo-module nginx_module_echo 使用echo指令输出一个字符串 Nginx 版本 ...
- Prometheus(一):Prometheus+Grafana 安装配置
一.基础环境 系统 IP 监控主机 CentOS 7 192.168.56.200 被监控主机 CentOS 7 192.168.56.201 二.Prometheus服务端安装 以下操作皆在监控主机 ...
- Docker搭建Prometheus+grafana监控系统
一.Prometheus简介 1.简介 Prometheus是由SoundCloud开发的开源监控报警系统和时序列数据库(TSDB). Prometheus使用Go语言开发,是Google BorgM ...
- 050.集群管理-Prometheus+Grafana监控方案
一 Prometheus概述 1.1 Prometheus简介 Prometheus是由SoundCloud公司开发的开源监控系统,是继Kubernetes之后CNCF第2个毕业的项目,在容器和微服务 ...
随机推荐
- urllib 获取页面或发送信息
#! /usr/bin/env python3 # -*- coding:utf-8 -*- #urllib提供了一系列用于操作URL的功能. #urllib的request模块可以非常方便地抓取UR ...
- Linux命令----su(切换用户)以及passwd(修改用户密码)
一.su命令登录root 用户在使用telnet命令可以远程登录,但不可以登录root,这样就需要使用su命令来登录root用户. telnet登录(不能登录root)--- 1.启动终端 输入 te ...
- Find the Missing Number II
Giving a string with number from 1-n in random order, but miss 1 number.Find that number. Notice n & ...
- 深入理解java虚拟机---虚拟机工具jps与jstat(十四)
jps-java process status jps类似于linux的ps命令,用于查看进程. JPS 名称: jps - Java Virtual Machine Process Status T ...
- ios 第4天
dealloc method 会在对象释放前调用这个方法(函数) 可以让对象在释放前把一些自己申请的对象 先释放了 满足 谁申请 谁释放 的原则 例如 dealloc 会自动调用 ...
- string使用方法
转载自:https://blog.csdn.net/tengfei461807914/article/details/52203202 使用场合: string是C++标准库的一个重要的部分,主要用于 ...
- shelly - HYMN TO INTELLECTUAL BEAUTY
HYMN TO INTELLECTUAL BEAUTY III No voice from some sublimer world hath ever To sage or poet these r ...
- TensorFlow函数:tf.lin_space
函数:tf.lin_space 别名: tf.lin_space tf.linspace lin_space( start, stop, num, name=None ) 参见指南:生成常量,序列和随 ...
- MySQL:MySQL Workbench的使用
MySQL Workbench 一.布局介绍 附:图片转自https://blog.csdn.net/qq_19891827/article/details/53995079 二.创建数据库 第一步: ...
- 解决VS2010使用mscomm控件无法接收数据的问题
如果你正在使用2010,并且想用mscomm控件,遇到如下问题,那你可以看看这篇文章: 1. 添加了mscomm控件以及对应的控件变量以后发现以前mscomm的成员函数,类似setsettings() ...