Hello everyone,
Am using Logstash and am a new user. I have a log file which I need to parse and get some meaningful fields like Timestamp, User, Domain, message, response code, error code etc.,
I use Grok pattern to parse the log file and my filter plugin of the ‘test’ configuration file looks like the below.
filter {
grok {
match => { “message" => "%{USERNAME}@%{HOSTNAME}" }
}
}
Here in this filter, I just tried to parse only the user@domain field from the log line. The sample log file which I have created is given below. This file has some rough logs just for testing purpose to see whether my logstash is working.
2016-10-23 18:57:00 firstuser@elk.com
2016-10-23 18:58:17 seconduser@elk.co.in
2016-10-23 18:58:17 thirduser@elasticsearch.com
Here the user@domain (i.e firstuser@elk.com) should be parsed like below.
{
"USERNAME": [
[
"firstuser"
]
],
"HOSTNAME": [
[
"elk.com"
]
]
}
But the actual result I got after stashing is like this:
{
“MESSAGE”: “2016-10-23 18:57:00 firstuser@elk.com”
}
I also used this filter to parse all possible fields, but this does not seem to work even.
filter {
grok {
match => { “message" => "%{COMBINEDAPACHELOG}" }
}
}
Note: All the configuration file sample code segments which I have given above does not have errors, as the "--configtest" passes fine. If you find any errors in that, that must be of the typo error.