Nginx使用日志输出上游服务器和自身的处理时间
发表于:2024-09-21 作者:千家信息网编辑
千家信息网最后更新 2024年09月21日,场景: Nginx的后端跟着Tomcat,现在要统计实现Nginx的处理时间以及后端服务器的返回时间。目的: 对于一个客户端请求,使用日志输出Nginx自身的处理时间,上游服务器的处理时间。实现: 通
千家信息网最后更新 2024年09月21日Nginx使用日志输出上游服务器和自身的处理时间场景: Nginx的后端跟着Tomcat,现在要统计实现Nginx的处理时间以及后端服务器的返回时间。
目的: 对于一个客户端请求,使用日志输出Nginx自身的处理时间,上游服务器的处理时间。
实现: 通过upstream模块的upstream_response_time变量来获取相关信息。
配置:
1.定义logformat log_format timed_combined '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' '$request_time $upstream_response_time $pipe';
request_time 表明,Nginx处理该请求所需花费的时间。 upstream_response_time 表明上游服务器的处理时间。 pipe 表示是否使用了http pipe
使用该条日志格式:
access_log /var/log/nginx/yourdomain.com.access.log timed_combined;
66.249.71.173 - - [08/Nov/2010:14:16:18 -0600] "GET /blog/2010/apr/30/installing-geodjango-dependencies-homebrew/ HTTP/1.1" 200 6569 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 0.640 0.640 .
0.640 表示,Nginx使用了0.640s的时间去相应客户端,其中上游服务器占用了0.640s,Nginx本身没有花费任何时间,并且没有使用pipeline
目的: 对于一个客户端请求,使用日志输出Nginx自身的处理时间,上游服务器的处理时间。
实现: 通过upstream模块的upstream_response_time变量来获取相关信息。
配置:
1.定义logformat log_format timed_combined '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' '$request_time $upstream_response_time $pipe';
request_time 表明,Nginx处理该请求所需花费的时间。 upstream_response_time 表明上游服务器的处理时间。 pipe 表示是否使用了http pipe
使用该条日志格式:
access_log /var/log/nginx/yourdomain.com.access.log timed_combined;
66.249.71.173 - - [08/Nov/2010:14:16:18 -0600] "GET /blog/2010/apr/30/installing-geodjango-dependencies-homebrew/ HTTP/1.1" 200 6569 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 0.640 0.640 .
0.640 表示,Nginx使用了0.640s的时间去相应客户端,其中上游服务器占用了0.640s,Nginx本身没有花费任何时间,并且没有使用pipeline
时间
处理
服务器
服务
日志
客户
客户端
输出
中上游
信息
变量
场景
格式
模块
目的
跟着
统计
配置
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
坦克世界服务器崩了吗
女生做软件测试好还是软件开发好
按部门查询销售业绩 数据库
服务器h3c默认账号密码
网络安全防护标语
电脑自带时间服务器地址
计算机网络安全内容主要有
服务器集中管理开关机
网络安全等级红色
昌平区网络技术信息推荐
lol进去服务器延迟
计算机网络技术培训班证书
服务器安全狗客户端在
dbc数据库怎么扩张
北京pdu服务器电源厂
邵阳计算机网络技术
什么是网络安全法律
共同筑牢网络安全防线时评作文
数据库查核
学生网络安全知识讲座内容
附加数据库文
娄底智能软件开发中介
汽修厂软件开发
沈阳三一软件开发工程师
电视机安卓软件开发
互联网科技园区
零件数据库
网络安全信息安全教授
关于护苗网络安全的画
单招选择计算机网络技术的理由