nginx-json.yaml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. # For all nginx variables, check this:
  2. # https://nginx.org/en/docs/http/ngx_http_core_module.html#var_connection_requests
  3. pattern: json
  4. prefix: NGINX_
  5. # When log2journal can detect the filename of each log entry (tail gives it
  6. # only when it tails multiple files), this key will be used to send the
  7. # filename to the journals.
  8. filename:
  9. key: NGINX_LOG_FILENAME
  10. filter:
  11. exclude: '^(NGINX_BINARY_REMOTE_ADDR)$'
  12. rename:
  13. - new_key: MESSAGE
  14. old_key: NGINX_REQUEST
  15. # args is an alias for query_string
  16. - new_key: NGINX_QUERY_STRING
  17. old_key: NGINX_ARGS
  18. # document_uri is an alias for uri
  19. - new_key: NGINX_URI
  20. old_key: NGINX_DOCUMENT_URI
  21. # is_args states if the request had a query string or not
  22. - new_key: NGINX_HAS_QUERY_STRING
  23. old_key: NGINX_IS_ARGS
  24. # msec is the timestamp in seconds, with fractional digits for milliseconds
  25. - new_key: NGINX_TIMESTAMP_SEC
  26. old_key: NGINX_MSEC
  27. # nginx_version is already prefixed with nginx, let's remove one of them
  28. - new_key: NGINX_VERSION
  29. old_key: NGINX_NGINX_VERSION
  30. # pipe states if the request was pipelined or not
  31. - new_key: NGINX_PIPELINED
  32. old_key: NGINX_PIPE
  33. # rename numeric TLVs to their names
  34. - new_key: NGINX_PROXY_PROTOCOL_TLV_ALPN
  35. old_key: NGINX_PROXY_PROTOCOL_TLV_0X01
  36. - new_key: NGINX_PROXY_PROTOCOL_TLV_AUTHORITY
  37. old_key: NGINX_PROXY_PROTOCOL_TLV_0X02
  38. - new_key: NGINX_PROXY_PROTOCOL_TLV_UNIQUE_ID
  39. old_key: NGINX_PROXY_PROTOCOL_TLV_0X05
  40. - new_key: NGINX_PROXY_PROTOCOL_TLV_SSL
  41. old_key: NGINX_PROXY_PROTOCOL_TLV_0X20
  42. - new_key: NGINX_PROXY_PROTOCOL_TLV_NETNS
  43. old_key: NGINX_PROXY_PROTOCOL_TLV_0X30
  44. # rename numeric SSL TLVs to their names
  45. - new_key: NGINX_PROXY_PROTOCOL_TLV_SSL_VERSION
  46. old_key: NGINX_PROXY_PROTOCOL_TLV_SSL_0X21
  47. - new_key: NGINX_PROXY_PROTOCOL_TLV_SSL_CN
  48. old_key: NGINX_PROXY_PROTOCOL_TLV_SSL_0X22
  49. - new_key: NGINX_PROXY_PROTOCOL_TLV_SSL_CIPHER
  50. old_key: NGINX_PROXY_PROTOCOL_TLV_SSL_0X23
  51. - new_key: NGINX_PROXY_PROTOCOL_TLV_SSL_SIG_ALG
  52. old_key: NGINX_PROXY_PROTOCOL_TLV_SSL_0X24
  53. - new_key: NGINX_PROXY_PROTOCOL_TLV_SSL_KEY_ALG
  54. old_key: NGINX_PROXY_PROTOCOL_TLV_SSL_0X25
  55. # Inject constant fields into the journal logs.
  56. inject:
  57. - key: SYSLOG_IDENTIFIER
  58. value: nginx-log
  59. # inject PRIORITY is a duplicate of NGINX_STATUS
  60. - key: PRIORITY
  61. value: '${NGINX_STATUS}'
  62. # Inject NGINX_STATUS_FAMILY is a duplicate of NGINX_STATUS
  63. - key: NGINX_STATUS_FAMILY
  64. value: '${NGINX_STATUS}'
  65. # Rewrite the value of fields (including the duplicated ones).
  66. # The search pattern can have named groups, and the replace pattern can use
  67. # them as ${name}.
  68. rewrite:
  69. # a ? means it has query string, everything else means it does not
  70. - key: NGINX_HAS_QUERY_STRING
  71. match: '^\?$'
  72. value: yes
  73. - key: NGINX_HAS_QUERY_STRING
  74. match: '.*'
  75. value: no
  76. # 'on' means it was HTTPS, everything else means it was not
  77. - key: NGINX_HTTPS
  78. match: '^on$'
  79. value: yes
  80. - key: NGINX_HTTPS
  81. match: '.*'
  82. value: no
  83. # 'p' means it was pipelined, everything else means it was not
  84. - key: NGINX_PIPELINED
  85. match: '^p$'
  86. value: yes
  87. - key: NGINX_PIPELINED
  88. match: '.*'
  89. value: no
  90. # zero means client sent a certificate and it was verified, non-zero means otherwise
  91. - key: NGINX_PROXY_PROTOCOL_TLV_SSL_VERIFY
  92. match: '^0$'
  93. value: yes
  94. - key: NGINX_PROXY_PROTOCOL_TLV_SSL_VERIFY
  95. match: '.*'
  96. value: no
  97. # 'OK' means request completed, everything else means it didn't
  98. - key: NGINX_REQUEST_COMPLETION
  99. match: '^OK$'
  100. value: 'completed'
  101. - key: NGINX_REQUEST_COMPLETION
  102. match: '.*'
  103. value: 'not completed'
  104. # PRIORTY is a duplicate of NGINX_STATUS
  105. # Valid PRIORITIES: 0=emerg, 1=alert, 2=crit, 3=error, 4=warn, 5=notice, 6=info, 7=debug
  106. - key: PRIORITY
  107. match: '^[123]'
  108. value: 6
  109. - key: PRIORITY
  110. match: '^4'
  111. value: 5
  112. - key: PRIORITY
  113. match: '^5'
  114. value: 3
  115. - key: PRIORITY
  116. match: '.*'
  117. value: 4
  118. # NGINX_STATUS_FAMILY is a duplicate of NGINX_STATUS
  119. - key: NGINX_STATUS_FAMILY
  120. match: '^(?<first_digit>[1-5])'
  121. value: '${first_digit}xx'
  122. - key: NGINX_STATUS_FAMILY
  123. match: '.*'
  124. value: 'UNKNOWN'
  125. # Control what to do when input logs do not match the main PCRE2 pattern.
  126. unmatched:
  127. # The journal key to log the PCRE2 error message to.
  128. # Set this to MESSAGE, so you to see the error in the log.
  129. key: MESSAGE
  130. # Inject static fields to the unmatched entries.
  131. # Set PRIORITY=1 (alert) to help you spot unmatched entries in the logs.
  132. inject:
  133. - key: PRIORITY
  134. value: 1