Nginx优化——VTS监控模块

最近闲来无事,租了一个服务器,很便宜,用来学习Linux 一,监控nginx主要用到以下三个模块 1,nginx-module-vts: Nginx virtual host traffic status module, Nginx 的监控模块,能够提供JSON格式的数据产出。

2,nginx-vts-exporter: Simple server that scrapes Nginx vts stats and exports them via HTTP for Prome theus consumption. 主要用于收集nginx的监控数据,并给prometheus提供监控接口,默认端口号为9913

3,prometheus:监控nginx-vts-exporter提供的nginx数据,并且存储在时序数据库中,可以使用rromQL对时序数据进行查询和聚合。

二,安装流程 1,上传并且解压 上传nginx-module-vts-master.zip软件包并解压。

unzip nginx-module-vts-master.zip

mv nginx-module-vts-master /usr/local/

 2,安装nginx依赖环境

yum -y install gcc gCC-C++ pcre pcre-devel zlib zl ib-devel openssl openssl-devel

3,编译安装nginx

cd /usr/local/ nginx-1.22.0

./configure --prefix=/usr/local/nginx --add-module=/usr/local/nginx-module-vts-master/ make && make install

4,优化管理

ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin

5,检查开启的模块

nginx -V log_format main '{ "@timestamp": "$time_local", ' '"@fields": { ' '"uri":"$request_uri",' '"url":"$uri",' '"upstream_addr":"$upstream_addr",' '"remote_addr": "$remote_addr", ' '"remote_user": "$remote_user", ' '"body_bytes_sent": "$body_bytes_sent", ' '"host":"$host",' '"server_addr":"$server_addr",' '"request_time": "$request_time", ' '"request_time":"$request_time",' '"status":"$status",' '"request": "$request", ' '"request_method": "$request_method", ' '"size":$body_bytes_sent,' '"upstream_time":"$upstream_response_time"' '"http_referrer": "$http_referer", ' '"body_bytes_sent":"$body_bytes_sent", ' '"http_x_forwarded_for": "$http_x_forwarded_for", ' '"http_user_agent": "$http_user_agent" } }';

在server模块中,添加一直llocation 指向以/status结尾的,跳转。  检查并且关闭防火墙 七, 访问该模块 八,使用ab压测,观察vts监控流量状态 image image image

点赞
收藏

评论区

加载中...

相关推荐

Nginx配置https

一、开启nginx的ssl模块1.未安装过nginx,编译安装配置参数如下:./configure\prefix/usr/local/nginx\withpcre\withhttp\_ssl\_modulessl模块\withhttp\_stub\_status\_module\wit

041. 通过 Lua 扩展 Nginx

1\.ngx\_lua模块Nginx模块需要用C开发,而且必须符合一系列复杂的规则,最重要的用C开发模块必须要熟悉Nginx的源代码,使得开发者对其望而生畏。ngx\_lua模块通过将lua解释器集成进Nginx,可以采用lua脚本实现业务逻辑。该模块具有

Nginx系列之使用ssl模块配置支持代理HTTPS链接

Nginx系列之使用ssl模块配置支持HTTPS访问1、博客前言介绍最近在用nginx代理https的第三方链接,因为不是做运维,所以对nginx并不是特殊熟悉,所以到处询问摸索了挺久2、查看ssl\_module要使用nginx代理https的链接,先用检查nginx是否已经有安装了ssl

Nginx与uWSGI交互

1\.更改uwsgi的配置文件uwsgi.iniuwsgi...使用nginx连接时,监控地址socket127.0.0.1:8080直接做web服务器时,所监控地址http127.0.0.1:80802\.在nginx配置文件中的路由模块添加uwsgi支持.

4. Nginx模块

Nginx官方模块1.ngx\_http\_stub\_status\_modulehttp://nginx.org/en/docs/http/ngx\_http\_stub\_status\_module.html。(https://www.oschina.net/action/GoToLink?urlhttp%3A%2

Nginx 模块分类

L:34!(https://oscimg.oschina.net/oscnet/3f218ca9379733d571a853b919759402668.png) 我们进入Nginx安装目录来查看上述模块的位置在src目录下每个模块对应的文件夹如下 /usr/local/nginx/nginx1.14.2/srcro