After a routine production environment build Nginx cluster, we need to continue in-depth study is the daily monitoring of Nginx.
How Nginx monitor? I believe Baidu can be found: nginx-status
By Nginx-status, real-time access to the monitoring data Nginx, and how existing monitoring systems integration? A good solution:
INX + Telegraf + Influxdb + Grafana
I.e., monitoring the timing Telegraf collected by monitoring status of Nginx widget, stored in the database Influxdb sequence, and then to show by Grafana.
A, Nginx nginx-status function is enabled
Nginx source compiler installed, you need to add corresponding module at compile time
./configure --with-http_stub_status_module
Use ./configure --help to see more support module. Then you can compile and install.
If you are directly installed apt-get install nginx, then use the command to see if support stub_status this module.
The following command: nginx -V to see if there --with-http_stub_status_module this module.
Modify Nginx configuration file: Increase in Server section:
location /nginx-status { allow 127.0.0.1; // allowed IP deny all; stub_status on; access_log off;}
Reload restart Nginx, see Nginx-Status
Output Description information:
active connections - the number of active connections server accepts handled requests - handled a total of 11,989 connections, successfully created 11989 handshake, handled a total of 11,991 requests reading — 读取客户端的连接数 writing — 响应数据到客户端的数量 waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.
二、Telegraf安装配置Nginx监控
关于Telegraf的安装,请参考官方介绍
https://www.influxdata.com/time-series-platform/telegraf/
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.4.3-1.x86_64.rpmsudo yum localinstall telegraf-1.4.3-1.x86_64.rpm
然后,在配置文件teldgraf.conf中配置Influxdb连接
增加对Nginx的监控
配置完成,重启telegraf服务即可。
三、Grafana集成Nginx监控
Grafana中支持Influxdb数据源,配置上上个步骤的Influxdb数据源之后,我们定制Nginx监控图表:
数据源:Influxdb
FROM:nginx
SELECT:field(accepts)
展现效果:
以上我们通过Nginx+Telegraf+Influxb+Grafana,实现了Nginx的监控,非常方便。
你们在日常实际生产环境对Nginx的状态监控使用的是何种技术?
最新整理的Java技术干货文档资料:【Java核心知识点整理】涵盖29个Java核心技术详解,JVM,Redis,Nginx,Spring Boot,Spring Cloud,Kafka,并发编程,Tomcat,MyBatis,BAT面试题,Java技术精讲视频等。转发+关注,加我VX【tkzl6666】即可获得免费领取方式。
With this knowledge point, the interview of the candidates but also a lot of eye-catching, crit 9999 points. Opportunities are reserved for those who are prepared, only adequate preparation before they can make themselves stand out among the candidates.