Filebeat 6.1.1 multiline is not working

As mentioned, I'm not being capable of making multiline work on filebeat. The message is getting received on logstash without considering the multiline. I've made it work on debbugers, but not on the real deal. What am i doing wrong here?

Here is the message that i'm trying to parse:

2017-12-28 00:05:00,634 INFO [CBILL_ESB_PROFILER_LOGGER] (pool-192-thread-1) ProfilerStat [serviceName=jms:instance.node.com.br:15199#queue/soa/saveCustomerService, error=false, timeToExecute=2017-12-28 00:05:00 - 222ms,
messageRequest=
<cus:customerSaveRequest xmlns:cus="http://com.test/services/crud/CustomerSaveRequest" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<gen:userIdentification xmlns:gen="http://com.test/services/crud/GenericSaveRequest">WS_SOL</gen:userIdentification>
<gen:saveDate xmlns:gen="http://com.test/services/crud/GenericSaveRequest">2017-12-28T00:05:00</gen:saveDate>
cus:customer
<cus1:personType xmlns:cus1="http://com.test/types/Customer">1</cus1:personType>
<cus1:companyAssociations xmlns:cus1="http://com.test/types/Customer">
cus1:companyAssociation
<cus2:nrc xmlns:cus2="http://com.test/types/CustomerCompanyAssociation">6983877</cus2:nrc>
</cus1:companyAssociation>
</cus1:companyAssociations>
<cus1:birthday xmlns:cus1="http://com.test/Customer">1987-07-04</cus1:birthday>
</cus:customer>
</cus:customerSaveRequest>

messageResponse=
<ns130:customerSaveResponse xmlns="adresses">
ns130:resultItem
ns130:customerIdentification
ns130:nrcxxxxxxx</ns130:nrc>
ns130:companyIdentificationxxxxxx</ns130:companyIdentification>
</ns130:customerIdentification>
</ns130:resultItem>
</ns130:customerSaveResponse>
]

and here is my filebeat.yml, with configurations of multiline:

filebeat.prospectors:

type: log

enabled: true

paths:
    /var/log/*.log

multiline.pattern: '^.*\[CBILL_ESB_PROFILER_LOGGER\]'
multiline.negate: true
multiline.match: after
multiline.flush_pattern: '\]'

This config looks pretty weird. Is this a formatting problem. Please post your complete config. Format logs and configuration files using the </> button or 3 backticks.

The config file format is based on YAML, that is, it's sensitive to indentation. The multiline settings are per prospector.

Here is the complete config file:

###################### Filebeat Configuration Example #########################

# This file is an example configuration file highlighting only the most common
# options. The filebeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/filebeat/index.html

# For more available modules and options, please see the filebeat.reference.yml sample
# configuration file.

#=========================== Filebeat prospectors =============================

filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

- type: log

  # Change to true to enable this prospector configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /var/log/*.log
    #- c:\programdata\elasticsearch\logs\*

  # Exclude lines. A list of regular expressions to match. It drops the lines that are
  # matching any regular expression from the list.
  #exclude_lines: ['^DBG']

  # Include lines. A list of regular expressions to match. It exports the lines that are
  # matching any regular expression from the list.
  #include_lines: ['^ERR', '^WARN']

  # Exclude files. A list of regular expressions to match. Filebeat drops the files that
  # are matching any regular expression from the list. By default, no files are dropped.
  #exclude_files: ['.gz$']

  # Optional additional fields. These fields can be freely picked
  # to add additional information to the crawled log files for filtering
  #fields:
  #  level: debug
  #  review: 1

  ### Multiline options

  # Mutiline can be used for log messages spanning multiple lines. This is common
  # for Java Stack Traces or C-Line Continuation

  # The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
  multiline.pattern: '^.*\[CBILL_ESB_PROFILER_LOGGER\]'
  multiline.negate: true
  multiline.match: after
  multiline.flush_pattern: '\]'
  
  fields.pipeline: apache-server-log

#============================= Filebeat modules ===============================

filebeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: false

  # Period on which files under path should be checked for changes
  #reload.period: 10s

#==================== Elasticsearch template setting ==========================

setup.template.settings:
  index.number_of_shards: 3
  setup.template.fields: ${path.config}/fields.yml
  setup.template.enabled: false
  #index.codec: best_compression
  #_source.enabled: false

#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
#  env: staging

#============================== Dashboards =====================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here, or by using the `-setup` CLI flag or the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  host: "localhost:5601"

#============================= Elastic Cloud ==================================

# These settings simplify using filebeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
#cloud.id:

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
#cloud.auth:

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
#output.elasticsearch:
  # Array of hosts to connect to.
  #hosts: ["localhost:9200"]

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  #username: "elastic"
  #password: "changeme"

#----------------------------- Logstash output --------------------------------
output.logstash:
  # The Logstash hosts
  hosts: ["localhost:5044"]

  # Optional SSL. By default is off.
  # List of root certificates for HTTPS server verifications
  #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

  # Certificate for SSL client authentication
  #ssl.certificate: "/etc/pki/client/cert.pem"

  # Client Certificate Key
  #ssl.key: "/etc/pki/client/cert.key"

#================================ Logging =====================================

# Sets log level. The default log level is info.
# Available log levels are: critical, error, warning, info, debug
#logging.level: debug

# At debug level, you can selectively enable logging only for some components.
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publish", "service".
#logging.selectors: ["*"]

You also have a more complete and properly formatted log sample (with lines before/after the multiline). Question: Why don't you just filter on the presence of a timestamp at the beginning of a log message? You really need the flush pattern? The multiline pattern is applied line by line, it 's not a 'start' pattern.

Ok, I've tried to change a little. But is not working still:

filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

  type: log

  # Change to true to enable this prospector configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /var/log/*.log
    #- c:\programdata\elasticsearch\logs\*

  # Exclude lines. A list of regular expressions to match. It drops the lines that are
  # matching any regular expression from the list.
  #exclude_lines: ['^DBG']

  # Include lines. A list of regular expressions to match. It exports the lines that are
  # matching any regular expression from the list.
  #include_lines: ['^ERR', '^WARN']

  # Exclude files. A list of regular expressions to match. Filebeat drops the files that
  # are matching any regular expression from the list. By default, no files are dropped.
  #exclude_files: ['.gz$']

  # Optional additional fields. These fields can be freely picked
  # to add additional information to the crawled log files for filtering
  #fields:
  #  level: debug
  #  review: 1

  ### Multiline options

  # Mutiline can be used for log messages spanning multiple lines. This is common
  # for Java Stack Traces or C-Line Continuation

  # The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
  multiline:
    pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}
    negate: true
    match: after

Regular expressions should be used with single quotes, so the YAML parser won't mess with the expression. Try pattern: '^\d{4}-\d{2}-\d{2}'. I'm not sure about thenegateandmatch` settings right now.

Still not working. Even with your suggestion.

I've tried a couple of other configurations by now. All of them are hitting water. Here's the last one:

#=========================== Filebeat prospectors =============================

filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

- type: log

  # Change to true to enable this prospector configuration.
  enabled: true

  json:
    keys_under_root: true
    add_error_key: true
    message_key: log
  
  paths:
    - /var/log/*.log

  ### Multiline options
  multiline:
    pattern: '^\d{4}-\d{2}-\d{2}'
    negate: true
    match: after
  
#============================= Filebeat modules ===============================

filebeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: false

  # Period on which files under path should be checked for changes
  #reload.period: 10s

#==================== Elasticsearch template setting ==========================

setup.template.settings:
  index.number_of_shards: 3
  #index.codec: best_compression
  #_source.enabled: false

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  host: "localhost:5601"

#================================ Outputs =====================================
#-------------------------- Elasticsearch output ------------------------------
#output.elasticsearch:
  # Array of hosts to connect to.
  #hosts: ["localhost:9200"]

#----------------------------- Logstash output --------------------------------
output.logstash:
  # The Logstash hosts
  hosts: ["localhost:5044"]

logging.level: debug

Let's start from zero. Which services are involved? Why do you have json and multiline enabled (you try get logs from docker)?

Can you share some actual logs (with events before/after the multiline)?

What exactly do you get with your current config?

How/when are logs written? You see any difference by setting multiline.timeout: 0 ?

Have you checked out the multiline testing script mentioned in the docs? The regex + your sample event work just fine for me: https://play.golang.org/p/gtuu4QeGnlk

You're right, on debuggers works like a charm. But for some reason, the message is comming splitted line by line on logstash. I have no idea why, but i should get a single big message. The last changes, I've made out of desperation lol. Not proud but, at this point, I will try everything.

2017-12-28 00:05:00,634 INFO  [CBILL_ESB_PROFILER_LOGGER] (pool-192-thread-1) ProfilerStat [serviceName=jms:bilu-teteia.kkkk-osa.com.br:15199#queue/soa/saveCustomerService, error=false, timeToExecute=2017-12-28 00:05:00 - 222ms, 
messageRequest=
<cus:customerSaveRequest xmlns:cus="http://com.empty.soa/services/crud/CustomerSaveRequest" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <gen:userIdentification xmlns:gen="http://com.empty.soa/services/crud/GenericSaveRequest">WS_SOL</gen:userIdentification>
   <gen:saveDate xmlns:gen="http://com.empty.soa/services/crud/GenericSaveRequest">2017-12-28T00:05:00</gen:saveDate>
   <cus:customer>
      <cus1:personType xmlns:cus1="http://com.empty.soa/types/Customer">1</cus1:personType>
      <cus1:companyAssociations xmlns:cus1="http://com.empty.soa/types/Customer">
         <cus1:companyAssociation>
            <cus2:nrc xmlns:cus2="http://com.empty.soa/types/CustomerCompanyAssociation">6983877</cus2:nrc>
         </cus1:companyAssociation>
      </cus1:companyAssociations>
      <cus1:birthday xmlns:cus1="http://com.empty.soa/types/Customer">1987-07-04</cus1:birthday>
   </cus:customer>
</cus:customerSaveRequest>

messageResponse=
<ns130:customerSaveResponse xmlns="http://com.empty.soa/services/crud/CustomerFindRequest" >
   <ns130:resultItem>
      <ns130:customerIdentification>
         <ns130:nrc>6983877</ns130:nrc>
         <ns130:companyIdentification>kkkk</ns130:companyIdentification>
      </ns130:customerIdentification>
   </ns130:resultItem>
</ns130:customerSaveResponse>
]
2017-12-28 00:05:00,641 INFO  [CBILL_ESB_PROFILER_LOGGER] (ajp-0.0.0.0-15109-38) ProfilerStat [serviceName=jms:bilu-teteia.kkkk-osa.com.br:15199#queue/soa/saveCustomerService-HornetQ, error=false, timeToExecute=2017-12-28 00:05:00 - 248ms, 
messageRequest=
<cus:customerSaveRequest xmlns:cus="http://com.empty.soa/services/crud/CustomerSaveRequest" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <gen:userIdentification xmlns:gen="http://com.empty.soa/services/crud/GenericSaveRequest">WS_SOL</gen:userIdentification>
   <gen:saveDate xmlns:gen="http://com.empty.soa/services/crud/GenericSaveRequest">2017-12-28T00:05:00</gen:saveDate>
   <cus:customer>
      <cus1:personType xmlns:cus1="http://com.empty.soa/types/Customer">1</cus1:personType>
      <cus1:companyAssociations xmlns:cus1="http://com.empty.soa/types/Customer">
         <cus1:companyAssociation>
            <cus2:nrc xmlns:cus2="http://com.empty.soa/types/CustomerCompanyAssociation">6983877</cus2:nrc>
         </cus1:companyAssociation>
      </cus1:companyAssociations>
      <cus1:birthday xmlns:cus1="http://com.empty.soa/types/Customer">1987-07-04</cus1:birthday>
   </cus:customer>
</cus:customerSaveRequest>

messageResponse=
<cus:customerSaveRequest xmlns:cus="http://com.empty.soa/services/crud/CustomerSaveRequest" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <gen:userIdentification xmlns:gen="http://com.empty.soa/services/crud/GenericSaveRequest">WS_SOL</gen:userIdentification>
   <gen:saveDate xmlns:gen="http://com.empty.soa/services/crud/GenericSaveRequest">2017-12-28T00:05:00</gen:saveDate>
   <cus:customer>
      <cus1:personType xmlns:cus1="http://com.empty.soa/types/Customer">1</cus1:personType>
      <cus1:companyAssociations xmlns:cus1="http://com.empty.soa/types/Customer">
         <cus1:companyAssociation>
            <cus2:nrc xmlns:cus2="http://com.empty.soa/types/CustomerCompanyAssociation">6983877</cus2:nrc>
         </cus1:companyAssociation>
      </cus1:companyAssociations>
      <cus1:birthday xmlns:cus1="http://com.empty.soa/types/Customer">1987-07-04</cus1:birthday>
   </cus:customer>
</cus:customerSaveRequest>
]

I was just making a test. I've processed the message with logstash without filebeat. And worked just fine. But I've realized something interesting. On Logstash, was generated a tag "multiline" but on the message processed on filebeat don't. I'm guessing that something is missing. Does that help a little?

I've just found the issue. One of the modules was enabled (apache2 on this case) and filebeat was using this configuration, ignoring mine. Thanks for the help!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.