nginx-combined.yaml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # Netdata log2journal Configuration
  2. # The following parses nginx log files using the combined format.
  3. # The PCRE2 pattern to match log entries and give names to the fields.
  4. # The journal will have these names, so follow their rules. You can
  5. # initiate an extended PCRE2 pattern by starting the pattern with (?x)
  6. pattern: |
  7. (?x) # Enable PCRE2 extended mode
  8. ^
  9. (?<NGINX_REMOTE_ADDR>[^ ]+) \s - \s # NGINX_REMOTE_ADDR
  10. (?<NGINX_REMOTE_USER>[^ ]+) \s # NGINX_REMOTE_USER
  11. \[
  12. (?<NGINX_TIME_LOCAL>[^\]]+) # NGINX_TIME_LOCAL
  13. \]
  14. \s+ "
  15. (?<NGINX_REQUEST>
  16. (?<NGINX_REQUEST_METHOD>[A-Z]+) \s+ # NGINX_METHOD
  17. (?<NGINX_REQUEST_URI>[^ ]+) \s+
  18. (?<NGINX_SERVER_PROTOCOL>[^"]+)
  19. )
  20. " \s+
  21. (?<NGINX_STATUS>\d+) \s+ # NGINX_STATUS
  22. (?<NGINX_BODY_BYTES_SENT>\d+) \s+ # NGINX_BODY_BYTES_SENT
  23. "(?<NGINX_HTTP_REFERER>[^"]*)" \s+ # NGINX_HTTP_REFERER
  24. "(?<NGINX_HTTP_USER_AGENT>[^"]*)" # NGINX_HTTP_USER_AGENT
  25. # When log2journal can detect the filename of each log entry (tail gives it
  26. # only when it tails multiple files), this key will be used to send the
  27. # filename to the journals.
  28. filename:
  29. key: NGINX_LOG_FILENAME
  30. rename:
  31. - new_key: MESSAGE
  32. old_key: NGINX_REQUEST
  33. # Inject constant fields into the journal logs.
  34. inject:
  35. - key: SYSLOG_IDENTIFIER
  36. value: nginx-log
  37. # inject PRIORITY is a duplicate of NGINX_STATUS
  38. - key: PRIORITY
  39. value: '${NGINX_STATUS}'
  40. # Inject NGINX_STATUS_FAMILY is a duplicate of NGINX_STATUS
  41. - key: NGINX_STATUS_FAMILY
  42. value: '${NGINX_STATUS}'
  43. # Rewrite the value of fields (including the duplicated ones).
  44. # The search pattern can have named groups, and the replace pattern can use
  45. # them as ${name}.
  46. rewrite:
  47. # PRIORITY is a duplicate of NGINX_STATUS
  48. # Valid PRIORITIES: 0=emerg, 1=alert, 2=crit, 3=error, 4=warn, 5=notice, 6=info, 7=debug
  49. - key: PRIORITY
  50. match: '^[123]'
  51. value: 6
  52. - key: PRIORITY
  53. match: '^4'
  54. value: 5
  55. - key: PRIORITY
  56. match: '^5'
  57. value: 3
  58. - key: PRIORITY
  59. match: '.*'
  60. value: 4
  61. # NGINX_STATUS_FAMILY is a duplicate of NGINX_STATUS
  62. - key: NGINX_STATUS_FAMILY
  63. match: '^(?<first_digit>[1-5])'
  64. value: '${first_digit}xx'
  65. - key: NGINX_STATUS_FAMILY
  66. match: '.*'
  67. value: 'UNKNOWN'
  68. # Control what to do when input logs do not match the main PCRE2 pattern.
  69. unmatched:
  70. # The journal key to log the PCRE2 error message to.
  71. # Set this to MESSAGE, so you to see the error in the log.
  72. key: MESSAGE
  73. # Inject static fields to the unmatched entries.
  74. # Set PRIORITY=1 (alert) to help you spot unmatched entries in the logs.
  75. inject:
  76. - key: PRIORITY
  77. value: 1