grok-patterns 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. USERNAME [a-zA-Z0-9._-]+
  2. USER %{USERNAME}
  3. INT (?:[+-]?(?:[0-9]+))
  4. BASE10NUM ([+-]?(?:[0-9]+(?:\.[0-9]+)?)|\.[0-9]+)
  5. NUMBER (?:%{BASE10NUM})
  6. BASE16NUM (0[xX]?[0-9a-fA-F]+)
  7. #BASE16FLOAT \b(?<![0-9A-Fa-f.])(?:[+-]?(?:0x)?(?:(?:[0-9A-Fa-f]+(?:\.[0-9A-Fa-f]*)?)|(?:\.[0-9A-Fa-f]+)))\b
  8. POSINT \b(?:[1-9][0-9]*)\b
  9. NONNEGINT \b(?:[0-9]+)\b
  10. WORD \b\w+\b
  11. NOTSPACE \S+
  12. SPACE \s*
  13. DATA .*?
  14. GREEDYDATA .*
  15. QUOTEDSTRING "([^"\\]*(\\.[^"\\]*)*)"|\'([^\'\\]*(\\.[^\'\\]*)*)\'
  16. UUID [A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}
  17. # Networking
  18. MAC (?:%{CISCOMAC}|%{WINDOWSMAC}|%{COMMONMAC})
  19. CISCOMAC (?:(?:[A-Fa-f0-9]{4}\.){2}[A-Fa-f0-9]{4})
  20. WINDOWSMAC (?:(?:[A-Fa-f0-9]{2}-){5}[A-Fa-f0-9]{2})
  21. COMMONMAC (?:(?:[A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2})
  22. IPV6 ((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]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STNAME}|%{IP})
  28. HOSTPORT %{IPORHOST}:%{POSINT}
  29. # paths
  30. PATH (?:%{UNIXPATH}|%{WINPATH})
  31. #UNIXPATH (?>/(?>[\w_%!$@:.,-]+|\\.)*)+
  32. UNIXPATH (/[\w_%!$@:.,-]?/?)(\S+)?
  33. TTY (?:/dev/(pts|tty([pq])?)(\w+)?/?(?:[0-9]+))
  34. #WINPATH (?>[A-Za-z]+:|\\)(?:\\[^\\?*]*)+
  35. WINPATH ([A-Za-z]:|\\)(?:\\[^\\?*]*)+
  36. URIPROTO [A-Za-z]+(\+[A-Za-z+]+)?
  37. URIHOST %{IPORHOST}(?::%{POSINT:port})?
  38. # uripath comes loosely from RFC1738, but mostly from what Firefox
  39. # doesn't turn into %XX
  40. URIPATH (?:/[A-Za-z0-9$.+!*'(){},~:;=@#%_\-]*)+
  41. #URIPARAM \?(?:[A-Za-z0-9]+(?:=(?:[^&]*))?(?:&(?:[A-Za-z0-9]+(?:=(?:[^&]*))?)?)*)?
  42. URIPARAM \?[A-Za-z0-9$.+!*'|(){},~@#%&/=:;_?\-\[\]]*
  43. URIPATHPARAM %{URIPATH}(?:%{URIPARAM})?
  44. URI %{URIPROTO}://(?:%{USER}(?::[^@]*)?@)?(?:%{URIHOST})?(?:%{URIPATHPARAM})?
  45. # Months: January, Feb, 3, 03, 12, December
  46. MONTH \b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\b
  47. MONTHNUM (?:0?[1-9]|1[0-2])
  48. MONTHDAY (?:(?:0[1-9])|(?:[12][0-9])|(?:3[01])|[1-9])
  49. # Days: Monday, Tue, Thu, etc...
  50. DAY (?:Mon(?:day)?|Tue(?:sday)?|Wed(?:nesday)?|Thu(?:rsday)?|Fri(?:day)?|Sat(?:urday)?|Sun(?:day)?)
  51. # Years?
  52. #YEAR (?>\d\d){1,2}
  53. #c
  54. YEAR (\d\d){1,2}
  55. HOUR (?:2[0123]|[01]?[0-9])
  56. MINUTE (?:[0-5][0-9])
  57. # '60' is a leap second in most time standards and thus is valid.
  58. SECOND (?:(?:[0-5][0-9]|60)(?:[:.,][0-9]+)?)
  59. #TIME (?!<[0-9])%{HOUR}:%{MINUTE}(?::%{SECOND})(?![0-9])
  60. #c
  61. TIME ([^0-9]?)%{HOUR}:%{MINUTE}(?::%{SECOND})([^0-9]?)
  62. # datestamp is YYYY/MM/DD-HH:MM:SS.UUUU (or something like it)
  63. DATE_US %{MONTHNUM}[/-]%{MONTHDAY}[/-]%{YEAR}
  64. DATE_EU %{MONTHDAY}[./-]%{MONTHNUM}[./-]%{YEAR}
  65. ISO8601_TIMEZONE (?:Z|[+-]%{HOUR}(?::?%{MINUTE}))
  66. ISO8601_SECOND (?:%{SECOND}|60)
  67. TIMESTAMP_ISO8601 %{YEAR}-%{MONTHNUM}-%{MONTHDAY}[T ]%{HOUR}:?%{MINUTE}(?::?%{SECOND})?%{ISO8601_TIMEZONE}?
  68. DATE %{DATE_US}|%{DATE_EU}
  69. DATESTAMP %{DATE}[- ]%{TIME}
  70. TZ (?:[PMCE][SD]T|UTC|GMT)
  71. DATESTAMP_RFC822 %{DAY} %{MONTH} %{MONTHDAY} %{YEAR} %{TIME} %{TZ}
  72. DATESTAMP_OTHER %{DAY} %{MONTH} %{MONTHDAY} %{TIME} %{TZ} %{YEAR}
  73. # Syslog Dates: Month Day HH:MM:SS
  74. SYSLOGTIMESTAMP %{MONTH} +%{MONTHDAY} %{TIME}
  75. PROG (?:[\w._/%-]+)
  76. SYSLOGPROG %{PROG:program}(?:\[%{POSINT:pid}\])?
  77. SYSLOGHOST %{IPORHOST}
  78. SYSLOGFACILITY <%{NONNEGINT:facility}.%{NONNEGINT:priority}>
  79. HTTPDATE %{MONTHDAY}/%{MONTH}/%{YEAR}:%{TIME} %{INT}
  80. # Shortcuts
  81. QS %{QUOTEDSTRING}
  82. # Log formats
  83. SYSLOGBASE %{SYSLOGTIMESTAMP:timestamp} (?:%{SYSLOGFACILITY} )?%{SYSLOGHOST:logsource} %{SYSLOGPROG}:
  84. COMMONAPACHELOG %{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" %{NUMBER:response} (?:%{NUMBER:bytes}|-)
  85. COMBINEDAPACHELOG %{COMMONAPACHELOG} %{QS:referrer} %{QS:agent}
  86. # Log Levels
  87. LOGLEVEL ([A-a]lert|ALERT|[T|t]race|TRACE|[D|d]ebug|DEBUG|[N|n]otice|NOTICE|[I|i]nfo|INFO|[W|w]arn?(?:ing)?|WARN?(?:ING)?|[E|e]rr?(?:or)?|ERR?(?:OR)?|[C|c]rit?(?:ical)?|CRIT?(?:ICAL)?|[F|f]atal|FATAL|[S|s]evere|SEVERE|EMERG(?:ENCY)?|[Ee]merg(?:ency)?)