0

I have Filebeat-7.1 installed in a Debian server, this Filebeat send data from files in this Debian server to server with Logstash 7.6 , here are the files config

Filebeat.yml:

#=========================== Filebeat inputs =============================

filebeat.inputs:

type: log

Change to true to enable this input configuration.
enabled: true
paths:

/root/code/cigol/logs/server.log
json.keys_under_root: true
json.overwrite_keys: true
json.add_error_key: true
force_close_files: true
fields:
env: dev
type: voiceserver.log

type: log
enabled: true
paths:
- /usr/local/freeswitch/log/freeswitch.log
force_close_files: true
fields:
env: dev
type: freeswitch.log

processors:

drop_fields:
fields: ["agent.ephemeral_id", "time", "agent.hostname", "agent.id", "agent.type", "agent.version", "ecs.version", "input.type", "log.offset", "@version", "fields.env", "tags"]
#----------------------------- Logstash output --------------------------------
output.logstash:

hosts: ["35.171.202.75:5044"]

--------------------------------logstash.conf----------------------------------------------------------------------------- input.conf

input {
beats {
port => 5044
}
}

filter.conf

filter{
if [fields][env] == "dev" {
if [source] == "/root/code/cigol/logs/server.log" {
json {
source => "message"
}
}
} else
if [source] == "/usr/local/freeswitch/log/freeswitch.log" {
grok {
match => { "message" => "%{NOTSPACE:uuid} %{TIMESTAMP_ISO8601:date} [%{LOGLEVEL:loglevel}] %{GREEDYDATA:message}" }
remove_field => ["message"]
}
}
}

Output.conf

output {

elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "%{[fields][type]}-%{+YYYY.MM.dd}"
}
stdout { codec => rubydebug }
}

application logs format

79110982-6d35-4b80-9be7-6ec9772313f9 2020-04-21 14:25:55.001130 [DEBUG] switch_core_state_machine.c:749 (sofia/3clogic_external/3001@freeswitch-registrar-10x.i3clogic.com:5505) State DESTROY

Kibana Output

message 79110982-6d35-4b80-9be7-6ec9772313f9 2020-04-21 14:25:55.001130 [DEBUG] mod_sofia.c:364 sofia/3clogic_external/3001@freeswitch-registrar-10x.i3clogic.com:5505 SOFIA DESTROY

I want to segregate message as below

"UUID" = 79110982-6d35-4b80-9be7-6ec9772313f9
"date" = 2020-04-21 14:25:55.001130
"loglevel" = DEBUG
"message" = switch_core_state_machine.c:749 (sofia/3clogic_external/3001@freeswitch-registrar-10x.i3clogic.com:5505) State DESTROY
Swisstone
  • 6,357
  • 7
  • 21
  • 32
Ankit
  • 1

1 Answers1

1

You just need to escape the special chars:

[%{LOGLEVEL:loglevel}]

should be

\[%{LOGLEVEL:loglevel}\]

here is the working pattern:

%{NOTSPACE:uuid} %{TIMESTAMP_ISO8601:date} \[%{LOGLEVEL:loglevel}\] %{GREEDYDATA:message}
Swisstone
  • 6,357
  • 7
  • 21
  • 32
  • 1
    For extra correctness, and to make that GREEDYDATA fail faster (a good thing), add a `$` to the end of the string. It'll let the regex engine know that GREEDYDATA can run to the end of the string. Putting a `^` at the start of the string will help even more. – sysadmin1138 Apr 21 '20 at 20:49