Last active
August 29, 2015 14:11
-
-
Save jasperla/f9178efbae083ce903ed to your computer and use it in GitHub Desktop.
logstash multiline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input { | |
| file { | |
| path => [ '/home/jasper/bacula.log' ] | |
| type => "bacula" | |
| start_position => "beginning" | |
| codec => multiline { | |
| # Unless a line matches the regular bacula logformat, tag it onto the previous | |
| patterns_dir => '/usr/local/logstash/patterns' | |
| pattern => "(%{BACULA_INFO})|(%{BACULA_ERR})" | |
| negate => true | |
| what => "previous" | |
| } | |
| } | |
| } | |
| filter { | |
| if [type] == "bacula" { | |
| if "grokked" not in [tags] { | |
| grok { | |
| patterns_dir => '/usr/local/logstash/patterns' | |
| match => [ "message", "%{BACULA_MULTI}" ] | |
| add_tag => [ "grokked", "multi" ] | |
| } | |
| } | |
| if "grokked" not in [tags] { | |
| grok { | |
| patterns_dir => '/usr/local/logstash/patterns' | |
| match => [ "message", "%{BACULA_INFO}" ] | |
| add_tag => [ "grokked", "info" ] | |
| } | |
| } | |
| if "grokked" not in [tags] { | |
| grok { | |
| patterns_dir => '/usr/local/logstash/patterns' | |
| match => [ "message", "%{BACULA_STATUS}" ] | |
| add_tag => [ "grokked", "status" ] | |
| } | |
| } | |
| if "grokked" not in [tags] { | |
| grok { | |
| patterns_dir => '/usr/local/logstash/patterns' | |
| match => [ "message", "%{BACULA_ERR}" ] | |
| add_tag => [ "bacula_error", "grokked" ] | |
| remove_tag => [ "_grokparsefailure" ] | |
| } | |
| } | |
| date { | |
| match => [ "timestamp", "dd-MMM HH:mm"] | |
| add_tag => [ "dated" ] | |
| } | |
| } | |
| } | |
| output { | |
| stdout { codec => rubydebug } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 14-Nov 12:52 bacula-dir JobId 0: Fatal error: mysql.c:198 Unable to connect to MySQL server. | |
| Database=bacula User=bacula | |
| MySQL connect failed either server not running or your authorization is incorrect. | |
| 15-Dec 22:31 bacula-dir JobId 0: Using Catalog "MyCatalog" | |
| 05-Dec 11:53 bacula-dir: ERROR TERMINATION at bsys.c:556 | |
| bacula-dir is already running. pid=827 | |
| Check file /var/run/bacula-dir.9101.pid | |
| 05-Dec 11:53 bacula-dir: ERROR TERMINATION at bsys.c:556 | |
| bacula-dir is already running. pid=827 | |
| Check file /var/run/bacula-dir.9101.pid | |
| 15-Dec 22:31 bacula-dir JobId 0: Using Catalog "MyCatalog" | |
| 15-Dec 22:31 bacula-dir JobId 0: Using Catalog "bla" | |
| 15-Dec 22:31 bacula-dir JobId 0: Finished run: | |
| Storage: "bacula-storage" (/dev/backup) | |
| Job: "wubwubwub" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BJOB (?:\s+Job:\s+(?<jobname>%{GREEDYDATA})) | |
| BSTORAGE (?:\s+Storage:\s+%{QS:device} \((%{PATH:mountpoint})\)) | |
| BPOOL (?:\s+Pool:\s+(%{GREEDYDATA:pool})) | |
| BCLIENT (?:\s+Client:\s+%{QS:client}\s*(%{GREEDYDATA:version})) | |
| BLEVEL (?:\s+Backup\ Level:\s+(%{GREEDYDATA:level})) | |
| BFILESET (?:\s+FileSet:\s+%{QS:fileset}) | |
| BCATALOG (?:\s+Catalog:\s+%{QS:catalog}) | |
| BJOBSTATUS (?:\s+Termination:\s+%{GREEDYDATA:jobstatus}) | |
| BSDERRORS (?:\s+SD Errors:\s+%{NUMBER:sd_errors}) | |
| BTERMSTATUS (?:\s+(?<termination_daemon>(DIR|SD|FD))\ termination\ status:\s+%{GREEDYDATA:termination_status}) | |
| BKEY (?:\s+%{WORD:key}:\s+%{GREEDYDATA:value})* | |
| BJOBID JobId %{NUMBER:jobid} | |
| BTIMESTAMP ^(?<timestamp>%{MONTHDAY}-%{MONTH}\s+%{HOUR}:%{MINUTE}) | |
| BHOST %{HOSTNAME:hostname}-(?<daemon>(dir|sd|fd)) | |
| BACULA_INFO %{BTIMESTAMP} %{BHOST} %{BJOBID}: %{GREEDYDATA:bacula_message}[^\n]+ | |
| BACULA_MULTI %{BACULA_INFO}\n?%{GREEDYDATA:bacula_message} | |
| BACULA_STATUS %{BACULA_INFO}\n?%{BSTORAGE}?\n?%{BJOB}?\n?%{BPOOL}?\n?%{BCLIENT}?\n?%{BLEVEL}?\n?%{BFILESET}?\n?%{BCATALOG}?\n?%{BJOBSTATUS}?\n?%{BSDERRORS}?\n?%{BTERMSTATUS}?\n?%{BKEY}? | |
| BACULA_ERR %{BTIMESTAMP} %{BHOST}: %{GREEDYDATA:bacula_message} | |
| BACULA (%{BACULA_STATUS}|%{BACULA_MULTI}|%{BACULA_INFO}|%{BACULA_ERR}) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This incorrectly tags a message such as:
as "status", whereas it should just be "multi".
It also fails to expand the "mountpoint" and other fields in a real status message: