当前位置: 首页 > news >正文

东航集团客户网站是哪家公司建设4k高清视频素材网站

东航集团客户网站是哪家公司建设,4k高清视频素材网站,建设网站的经验,成都seo优化推广nginx 日志改为json格式 场景描述效果变更旧样式新样式 场景描述 正常使用nginx时,使用默认的日志输出格式,对于后续日志接入其他第三方日志收集、清洗环节,因分隔符问题可能不是很友好。 xxxx - - [19/Feb/2024:11:16:48 0800] "GET …

nginx 日志改为json格式

    • 场景描述
    • 效果
    • 变更
      • 旧样式
      • 新样式


场景描述

正常使用nginx时,使用默认的日志输出格式,对于后续日志接入其他第三方日志收集、清洗环节,因分隔符问题可能不是很友好。

xxxx - - [19/Feb/2024:11:16:48 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
xxxx - - [19/Feb/2024:11:16:49 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
xxxx - - [19/Feb/2024:11:16:50 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
xxxx - - [19/Feb/2024:11:16:51 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
xxxx - - [19/Feb/2024:11:16:52 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
xxxx - - [19/Feb/2024:11:16:53 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"

nginx同时支持将日志输出为json格式,修改较小,下面为效果。

效果

{"@timestamp":"2024-02-19T11:23:09+08:00","server_addr":"10.0.0.251","remote_addr":"xxxx","host":"sre-support.xxxx-inc.top","uri":"/time_feed","body_bytes_sent":42,"upstream_response_time":0.000,"request":"GET /time_feed HTTP/1.1","request_length":349,"request_time":0.001,"status":"200","http_referer":"http://sre-support.xxxx-inc.top/max_data","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}
{"@timestamp":"2024-02-19T11:23:10+08:00","server_addr":"10.0.0.251","remote_addr":"xxxx","host":"sre-support.xxxx-inc.top","uri":"/time_feed","body_bytes_sent":42,"upstream_response_time":0.001,"request":"GET /time_feed HTTP/1.1","request_length":349,"request_time":0.001,"status":"200","http_referer":"http://sre-support.xxxx-inc.top/max_data","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}
{"@timestamp":"2024-02-19T11:23:11+08:00","server_addr":"10.0.0.251","remote_addr":"xxxx","host":"sre-support.xxxx-inc.top","uri":"/time_feed","body_bytes_sent":42,"upstream_response_time":0.000,"request":"GET /time_feed HTTP/1.1","request_length":349,"request_time":0.001,"status":"200","http_referer":"http://sre-support.xxxx-inc.top/max_data","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}
{"@timestamp":"2024-02-19T11:23:12+08:00","server_addr":"10.0.0.251","remote_addr":"xxxx","host":"sre-support.xxxx-inc.top","uri":"/time_feed","body_bytes_sent":42,"upstream_response_time":0.000,"request":"GET /time_feed HTTP/1.1","request_length":349,"request_time":0.001,"status":"200","http_referer":"http://sre-support.xxxx-inc.top/max_data","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}
{"@timestamp":"2024-02-19T11:23:13+08:00","server_addr":"10.0.0.251","remote_addr":"xxxx","host":"sre-support.xxxx-inc.top","uri":"/time_feed","body_bytes_sent":42,"upstream_response_time":0.000,"request":"GET /time_feed HTTP/1.1","request_length":349,"request_time":0.001,"status":"200","http_referer":"http://sre-support.xxxx-inc.top/max_data","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}

变更

旧样式

nginx一般默认会打开日志格式化格式,我这里为默认的格式,可能有的同学使用的是自定义格式,但是都是用“ - ” 分割的。

样式为:
nginx log_format格式

新样式

因本身nginx支持json格式日志输出,下面为我使用的示例,我这里增加了获取源站响应时间upstream_response_timer,所以下面先增加了upstream_response_timer取值方式。
下面的log_format展示了当前获取的字段,各位可根据自己需求进行自定义。

http {map $upstream_response_time $upstream_response_timer {default $upstream_response_time;""        0;}log_format log_json escape=json '{"@timestamp":"$time_iso8601",''"server_addr":"$server_addr",''"remote_addr":"$remote_addr",''"host":"$host",''"uri":"$uri",''"body_bytes_sent":$body_bytes_sent,''"upstream_response_time":$upstream_response_timer,''"request":"$request",''"request_length":$request_length,''"request_time":$request_time,''"status":"$status",''"http_referer":"$http_referer",''"http_x_forwarded_for":"$http_x_forwarded_for",''"http_user_agent":"$http_user_agent"''}';access_log  /var/log/nginx/access.log  log_json;error_log /var/log/nginx/error.log error;........
}

样式为:
nginx log_json样式

http://www.dtcms.com/a/469162.html

相关文章:

  • Compose 在Row、Column上使用focusRestorer修饰符失效原因
  • Sora 2:当AI视频“以假乱真”,内容创作进入新纪元,体验AI创作能力
  • 推荐一个浏览器代理插件(Tajang Proxy),支持Chrome和Edge
  • conda|如何通过命令行在mac上下载conda
  • VS Code 二次开发:跨平台图标定制全攻略
  • 关于微信小程序开发几点总结
  • 杭州建站价格邢台wap网站建设费用
  • kafka4使用记录
  • 2100AI智能生活
  • 网站开发交流群做网站线上线下价格混乱
  • AI:让驾驶体验个性化!
  • 由Nacos允许配置访问代理启发的Node前端部署路径转发探究
  • vue - JS 判断客户端是苹果 iOS 还是安卓 Android(封装好的方法直接调用)二种解决方案
  • 路由器如何判断数据转发目标
  • BEM命名规范
  • 12V-24V转3.2V-10V600mA恒流驱动芯片WT7018
  • 远程MCP的调用和阿里云生态的知识库和工作流的使用
  • 前端与后端开发之间的不同
  • 做企业免费网站鄂尔多斯北京网站建设
  • 网站建设优化服务好么锦州做网站
  • 在线Excel新突破:SpreadJS如何完美驾驭中国式复杂报表
  • Excel如何排序?【图文详解】Excel表格排序?Excel自动排序?
  • 【Python办公】csv转Excel(可指定行数)
  • 个人网站用备案吗深圳办公室装修公司哪家好
  • Scala面试题及详细答案100道(71-80)-- 与Java的交互
  • 基于 PyQt5 实现刀具类型选择界面的设计与交互逻辑
  • 常用库函数
  • QUIC协议相比其他传输层协议(TCP,STCP,UDP)的优势
  • 【PC+安卓】塞尔达传说:王国之泪|v1.4.2整合版|官方中文|解压可玩 内附switch模拟器
  • 【自然语言处理】实现跨层跨句的上下文语义理解的解决办法