Haproxy Json日志格式配置
来源:互联网 发布:linux升级rpm版本号 编辑:程序博客网 时间:2024/05/22 07:54
通过日志工作分析日志时,非json日志分析起来比较麻烦。通过以下的配置,可以让生成的日志为json。
log-format {"haproxy_clientIP":"%ci","haproxy_clientPort":"%cp","haproxy_dateTime":"%t","haproxy_frontendNameTransport":"%ft","haproxy_backend":"%b","haproxy_serverName":"%s","haproxy_Tw":"%Tw","haproxy_Tc":"%Tc","haproxy_Tt":"%Tt","haproxy_bytesRead":"%B","haproxy_terminationState":"%ts","haproxy_actconn":%ac,"haproxy_FrontendCurrentConn":%fc,"haproxy_backendCurrentConn":%bc,"haproxy_serverConcurrentConn":%sc,"haproxy_retries":%rc,"haproxy_srvQueue":%sq,"haproxy_backendQueue":%bq,"haproxy_backendSourceIP":"%bi","haproxy_backendSourcePort":"%bp","http_request":%r,"request_headers":"%hrl","response_headers":"%hsl","status_code":"%ST"}
配置实例:
# Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 local2
log-send-hostname
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 30000
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 50000
#---------------------------------------------------------------------
#---------------------------------------------------------------------
listen myapp1 :22222
mode tcp
option tcplog
log-format {"haproxy_clientIP":"%ci","haproxy_clientPort":"%cp","haproxy_dateTime":"%t","haproxy_frontendNameTransport":"%ft","haproxy_backend":"%b","haproxy_serverName":"%s","haproxy_Tw":"%Tw","haproxy_Tc":"%Tc","haproxy_Tt":"%Tt","haproxy_bytesRead":"%B","haproxy_terminationState":"%ts","haproxy_actconn":%ac,"haproxy_FrontendCurrentConn":%fc,"haproxy_backendCurrentConn":%bc,"haproxy_serverConcurrentConn":%sc,"haproxy_retries":%rc,"haproxy_srvQueue":%sq,"haproxy_backendQueue":%bq,"haproxy_backendSourceIP":"%bi","haproxy_backendSourcePort":"%bp"}
option logasap
balance leastconn
server server1 xx.xx.xx.xx:22222
server server2 xx.xx.xx.xx:22222
server server3 xx.xx.xx.xx:22222
listen myapp2 :22201
mode tcp
option tcplog
log-format {"haproxy_clientIP":"%ci","haproxy_clientPort":"%cp","haproxy_dateTime":"%t","haproxy_frontendNameTransport":"%ft","haproxy_backend":"%b","haproxy_serverName":"%s","haproxy_Tw":"%Tw","haproxy_Tc":"%Tc","haproxy_Tt":"%Tt","haproxy_bytesRead":"%B","haproxy_terminationState":"%ts","haproxy_actconn":%ac,"haproxy_FrontendCurrentConn":%fc,"haproxy_backendCurrentConn":%bc,"haproxy_serverConcurrentConn":%sc,"haproxy_retries":%rc,"haproxy_srvQueue":%sq,"haproxy_backendQueue":%bq,"haproxy_backendSourceIP":"%bi","haproxy_backendSourcePort":"%bp"}
option logasap
balance leastconn
server server1 xx.xx.xx.xx:22201
server server2 xx.xx.xx.xx:22201
server server3 xx.xx.xx.xx:22201
# Interface Web
listen stats *:80
stats enable
stats uri /
stats refresh 5s
stats hide-version
来自 <https://github.com/jothoma1/graylog-contentpack-haproxy/blob/master/sample-haproxy.cfg>
- Haproxy Json日志格式配置
- haproxy日志格式
- 配置Haproxy日志功能
- HAProxy日志配置详解
- haproxy打印日志配置
- haproxy 配置日志
- haproxy的日志配置
- HAProxy日志配置详解
- ubuntu12.04 配置haproxy日志
- Json 日志格式转换
- Redhat 6.3与Haproxy日志配置
- 配置Haproxy增加日志记录功能
- Apache 自定义 JSON 格式日志
- 日志转换成json格式
- Nginx 日志改成 JSON 格式
- 配置apache日志格式
- nginx日志格式配置
- 使用Haproxy时apache日志的配置方法
- java 基础类
- java包装类
- cocos2dx 里的坐标系统
- java-equals
- 为什么快速排序是不稳定的
- Haproxy Json日志格式配置
- 【内含福利】黑科技神助攻_白娘子玩转云栖大会
- 序列化与反序列化
- Java订单号生成工具(实现二)基于队列
- SLAMTEC—思岚科技把国内服务机器人带出国门
- python GUI编程
- Android 开发 软键盘覆盖而不上推布局 控件总显示在软件盘上边
- gnu链接脚本解析
- 【ORACLE】ORACLE存储过程SHOW_SPACE.SQL完整脚本