Skip to content

Instantly share code, notes, and snippets.

@bmaupin
Created November 2, 2018 15:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmaupin/4cc30778615a5ec4dcccc34208c2fce1 to your computer and use it in GitHub Desktop.
Save bmaupin/4cc30778615a5ec4dcccc34208c2fce1 to your computer and use it in GitHub Desktop.
Extract Java exceptions in Graylog

Get exceptions in search results

Regular expressions used in searches seem to search the extracted search "terms," which you can see by clicking on any particular message, then click the down arrow > Show terms of .... For this reason, "exception" needs to be lower-case:

message:/([a-z0-9\.]+exception)/

Extract exceptions as a field

  1. Create a new rule

    rule "Extract Java exceptions"
    when
        regex("([A-Za-z0-9\\.]+Exception(?!\\w))", to_string($message.message)).matches == true
    then
        let exception_regex = regex("([A-Za-z0-9\\.]+Exception(?!\\w))", to_string($message.message));
        set_field("exception", exception_regex["0"]);
    end
    
  2. Create a new pipeline and add this rule

To extract exceptions as a decorator (so the exception field won't be indexed), don't connect the pipeline to any particular stream. Instead, do a search and then go to Decorators > Select decorator > Pipeline Processor Decorator > Apply > select the pipeline you created

To extract exceptions at index time, connect the pipeline to a stream, e.g. All messages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment