Multi-Line with Beats Input

Hello,
I would appreciate some help with configuring my beats input. In my beats input, I have enabled the multiline button. The start pattern is: ^#|;$
However, when starting graylog collector, I get an error from filebeat, "Multiline match can either be ‘after’ or ‘before’, but not ’ '.
Additionally, the log messages are all separate messages coming in.
Thanks!

Hej Matt,

did you configure beats via sidecar or did you write the beats configuration yourself?

Hi Jan,
I configured beats via sidecar with this documentation: (http://docs.graylog.org/en/2.2/pages/collector_sidecar.html)

can you please paste your generated filebeat configuration.

I guess you have missed the “before” or “after” setting in the configuration for filebeat on Graylog.

This is the filebeat.yml. I haven’t changed a lot of things in here, hence almost all of it being the default configs.

#=========================== 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.

- input_type: log

  # 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 field 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: ^\[
   #multiline.pattern: ^#|;$

  # Defines if the pattern set under pattern should be negated or not. Default is false.
  #multiline.negate: false

  # Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
  # that was (not) matched before or after or as long as a pattern is not matched based on negate.
  # Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
  # multiline.match: after


#================================ 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

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

# Configure what outputs to use when sending the data collected by the beat.
# Multiple outputs may be used.

#-------------------------- 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: ["*"]

Hej @matthkang

I do not know where you get this configuration from - but if you had used sidecar to get this configuration from Graylog this would be found in /etc/graylog/collector-sidecar/generated/ and might look like:

filebeat:
  prospectors:
  - document_type: log
    encoding: plain
    fields:
      gl2_source_collector: 345f10fd-21cc-4d92-a9f1-c7960d2bb4b1
    ignore_older: 0
    input_type: log
    paths:
    - /var/log/*.log
    scan_frequency: 10s
    tail_files: true
output:
  logstash:
    hosts:
    - 192.168.100.50:5044
    - 192.168.100.51:5044
    - 192.168.100.52:5044
    loadbalance: true

But your error message just say what is missing, multiline.match: after or multiline.match: before need to be set in your configuration to have it work.

Ah, it looks like I gave you the wrong yml.

filebeat:
  prospectors:
  - document_type: log
    encoding: utf-8
    fields:
      collector_node_id: graylog-collector-sidecar
      gl2_source_collector: 9d5194d8-3b3d-49df-b66a-7a6077e2a676
    ignore_older: 0
    input_type: log
    paths:
    - /var/log/apache2/access.log
    scan_frequency: 10s
    tail_files: true
output:
  logstash:
    hosts:
    - IP_ADDRESS:5044
path:
  data: /var/cache/graylog/collector-sidecar/filebeat/data
  logs: /var/log/graylog/collector-sidecar
tags:
- linux
- apache

what is your error again?

the configuration you copy here and the first post does not fit into a picture.

What did you try to solve? What did you configure and what error did you get?

Please post the configuration and the log files that can help with that.

thank you

My first filebeat.yml that I posted was in /etc/filebeat. I am trying to read from a log through collector-sidecar from the path: /var/log/apache2/access.log. It contains two lines that start with #. (i.e. #first line, #second line)
When specifying the regex pattern: ^#|;$, I see from the graylog UI, that there are two separate events for these lines. I would like for there to be one event for a multiline log.
Hopefully this clarifies things a little bit.

I ended up solving the problem. In the Graylog UI, where I enable Multiline and I specify the pattern of a multiline message, I needed to specify the pattern in brackets. So The correct regex was: [^#|;$]

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