<commit_before>filter {

    #
    # Default type to _logstash_input 
    #

    alter {
        coalesce => [
            "type", "%{_logstash_input}", "%{_type}"
        ]
    }

    #
    # rewrite our defined globals
    #

    if [type] == 'redis' or [type] == 'redis-input' {
        mutate {
            remove_field => [ 'type' ]
        }
    }

    if [type] != '' {
        mutate {
            rename => [ "type", "@type" ]
        }
    }

    if [message] != '' {
        mutate {
            rename => [ "message", "@message" ]
        }
    } else if [message] == '' and [@message] !~ /^.+$/ {
        drop { }
    }

    #
    # ignore particularly useless lines
    #

    if [@message] =~ /^\s*$/ or [@message] =~ /^#.*$/ {
        drop { }
    }

    #
    # trim excessively long messages
    #

    ruby {
        code => "(event['@message'] = event['@message'][0,<%= p("logstash_parser.message_max_size") %>] and (event['tags'] ||= []) << '_groktrimmed') if event['@message'] and event['@message'].length > <%= p("logstash_parser.message_max_size") %>"
    }

    #
    # trim excess whitespace
    #

    mutate {
        strip => [ "@message" ]
    }

    #
    # the various log types that we're interested in
    #

    if [@type] == "nginx_combined" {
        grok {
            match => [ "@message", "%{IPORHOST:remote_addr} - (?:%{USER:remote_user}|-) \[%{HTTPDATE:time_local}\] \"(?:%{WORD:request_method} %{URIPATHPARAM:request_uri}(?: HTTP/%{NUMBER:request_httpversion})?|-)\" %{INT:status} (?:%{NONNEGINT:body_bytes_sent}|-) \"(?:%{URI:http_referer}|-)\" %{QS:http_user_agent} (?:%{NONNEGINT:request_time}|-)" ]
            match => [ "@message", "%{IPORHOST:remote_addr} - (?:%{USER:remote_user}|-) \[%{HTTPDATE:time_local}\] \"(?:%{WORD:request_method} %{URIPATHPARAM:request_uri}(?: HTTP/%{NUMBER:request_httpversion})?|-)\" %{INT:status} (?:%{NONNEGINT:body_bytes_sent}|-) \"(?:%{URI:http_referer}|-)\" %{QS:http_user_agent}" ]
            add_tag => "nginx"
        }

        date {
            match => [ "time_local", "dd/MMM/YYYY:HH:mm:ss Z" ]
        }
    }

    #
    # Additional filter types from /var/vcap/packages/logstash-filters-*/*.conf
    #
<commit_msg>Remove nginx from filters_pre (its already present in filters-common)<commit_after>filter {

    #
    # Default type to _logstash_input 
    #

    alter {
        coalesce => [
            "type", "%{_logstash_input}", "%{_type}"
        ]
    }

    #
    # rewrite our defined globals
    #

    if [type] == 'redis' or [type] == 'redis-input' {
        mutate {
            remove_field => [ 'type' ]
        }
    }

    if [type] != '' {
        mutate {
            rename => [ "type", "@type" ]
        }
    }

    if [message] != '' {
        mutate {
            rename => [ "message", "@message" ]
        }
    } else if [message] == '' and [@message] !~ /^.+$/ {
        drop { }
    }

    #
    # ignore particularly useless lines
    #

    if [@message] =~ /^\s*$/ or [@message] =~ /^#.*$/ {
        drop { }
    }

    #
    # trim excessively long messages
    #

    ruby {
        code => "(event['@message'] = event['@message'][0,<%= p("logstash_parser.message_max_size") %>] and (event['tags'] ||= []) << '_groktrimmed') if event['@message'] and event['@message'].length > <%= p("logstash_parser.message_max_size") %>"
    }

    #
    # trim excess whitespace
    #

    mutate {
        strip => [ "@message" ]
    }

    #
    # Additional filter types from /var/vcap/packages/logstash-filters-*/*.conf
    #
{'fraction_non_alphanumeric': 0.20197461212976023, 'fraction_numerical': 0.0005641748942172073, 'mean_word_length': 2.0861618798955615, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3310037', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1216, 'n_words': 210}