Errors came out if I added multiline under "filter", but it works if I have added under "input". Anyone can give me hints?
input {
file {
path => "/tmp/input.log"
#codec => multiline {
# pattern => "^%{TIMESTAMP_ISO8601}"
# negate=> true
# what => "previous"
#}
}
}
filter {
codec => multiline {
pattern => "^%{TIMESTAMP_ISO8601}"
negate=> true
what => "previous"
}
grok {
match => {"message" => "%{TIMESTAMP_ISO8601:timestamp} \[%{DATA:app_name},%{DATA:trace_id},%{DATA:seq_no},%{DATA:reference},%{DATA:run_date},%{DATA:message_type},%{DATA:message_code},%{DATA:service_code}\] %{WORD:level}%{SPACE}+\[%{DATA:thread_id}\] %{DATA:class}\[%{DATA:line}\] - %{GREEDYDATA:message}"}
overwrite => [ "message" ]
}
}
output {
file {
path => "/tmp/output.log"
}
elasticsearch {
hosts => ["http://localhost:9200"]
user => elastic
password => XXXXXXXXXXXX
}
}
Logstash logs:
[2023-05-24T20:08:12,433][INFO ][logstash.runner ] Log4j configuration path used is: /etc/logstash/log4j2.properties
[2023-05-24T20:08:12,541][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"8.2.1", "jruby.version"=>"jruby 9.2.20.1 (2.5.8) 2021-11-30 2a2962fbd1 OpenJDK 64-Bit Server VM 11.0.14.1+1 on 11.0.14.1+1 +indy +jit [linux-x86_64]"}
[2023-05-24T20:08:12,544][INFO ][logstash.runner ] JVM bootstrap flags: [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djruby.compile.invokedynamic=true, -Djruby.jit.threshold=0, -XX:+HeapDumpOnOutOfMemoryError, -Djava.security.egd=file:/dev/urandom, -Dlog4j2.isThreadContextMapInheritable=true, -Djruby.regexp.interruptible=true, -Djdk.io.File.enableADS=true, --add-opens=java.base/java.security=ALL-UNNAMED, --add-opens=java.base/java.io=ALL-UNNAMED, --add-opens=java.base/java.nio.channels=ALL-UNNAMED, --add-opens=java.base/sun.nio.ch=ALL-UNNAMED, --add-opens=java.management/sun.management=ALL-UNNAMED]
[2023-05-24T20:08:13,983][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600, :ssl_enabled=>false}
[2023-05-24T20:08:14,408][ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of [ \t\r\n], "#", "{" at line 8, column 9 (byte 73) after filter {\n codec ", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:32:in compile_imperative'", "org/logstash/execution/AbstractPipelineExt.java:189:in
initialize'", "org/logstash/execution/JavaBasePipelineExt.java:72:in initialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:48:in
initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:50:in execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:381:in
block in converge_state'"]}
[2023-05-24T20:08:14,564][INFO ][logstash.runner ] Logstash shut down.
[2023-05-24T20:08:14,574][FATAL][org.logstash.Logstash ] Logstash stopped processing because of an error: (SystemExit) exit
org.jruby.exceptions.SystemExit: (SystemExit) exit
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:747) ~[jruby.jar:?]
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:710) ~[jruby.jar:?]
at usr.share.logstash.lib.bootstrap.environment.(/usr/share/logstash/lib/bootstrap/environment.rb:91) ~[?:?]
^C