HAproxy Json日志格式配置
生活随笔
收集整理的這篇文章主要介紹了
HAproxy Json日志格式配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
通過日志工作分析日志時,非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#---------------------------------------------------------------------globallog 127.0.0.1 local2log-send-hostnamechroot /var/lib/haproxypidfile /var/run/haproxy.pidmaxconn 30000user haproxygroup haproxydaemon# turn on stats unix socketstats socket /var/lib/haproxy/stats#---------------------------------------------------------------------# common defaults that all the 'listen' and 'backend' sections will# use if not designated in their block#---------------------------------------------------------------------defaultsmode httplog globaloption httplogoption dontlognulloption http-server-closeoption forwardfor except 127.0.0.0/8option redispatchretries 3timeout http-request 10stimeout queue 1mtimeout connect 10stimeout client 1mtimeout server 1mtimeout http-keep-alive 10stimeout check 10smaxconn 50000#---------------------------------------------------------------------#---------------------------------------------------------------------listen myapp1 :22222mode tcpoption tcploglog-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 logasapbalance leastconnserver server1 xx.xx.xx.xx:22222server server2 xx.xx.xx.xx:22222server server3 xx.xx.xx.xx:22222listen myapp2 :22201mode tcpoption tcploglog-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 logasapbalance leastconnserver server1 xx.xx.xx.xx:22201server server2 xx.xx.xx.xx:22201server server3 xx.xx.xx.xx:22201# Interface Weblisten stats *:80stats enablestats uri /stats refresh 5sstats hide-version轉載于:https://www.cnblogs.com/breezey/p/8810170.html
總結
以上是生活随笔為你收集整理的HAproxy Json日志格式配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 快速查看Gradle项目的类库依赖情况
- 下一篇: Clash Royale开发日志