2022-01-24 06:41 AM
Hello.
First of all, I've read this article and tried to do such thing, but no luck.
Logs are from MongoDB Community event source.
Log example:
"Jan 24 16:30:10 mongodb-linux-test-1 MONGODB-AUDIT: {"t":{"$date":"2022-01-24T16:30:01.081+06:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"192.168.1.100:58595","connectionId":37,"connectionCount":1}}"
I've tried to parse only these ("s":"I", "c":"NETWORK", "id":22943)
My log parser file is:
<?xml version="1.0" encoding="UTF-8"?>
After (re-)deployment I've get such result(message id is OK, but no metas of severity, reference, subject):
Please, explain what is wrong with my parser file.
2022-01-25 03:32 AM
I've managed to find the error by myself:
...
...
<VARTYPE name="logstash_json_payload" dataType=FileBeatsEvent"/>
<DataType name="InternetTime" dateTime="%W-%M-%DT%H:%T:%S.%V%E" />
<DataType name="CollectionTime" type="InternetTime" meta="lc.ctime"/>
<DataType name="ElasticCommonSchemaSubset" format="JSON">
<Capture key="/@timestamp"> type="CollectionTime" />
<Capture key="/host/hostname"> meta="alias.host" />
<Capture key="/host/id"> meta="hardware.id" />
<Capture key="/host/os/name"> meta="OS" />
</DataType>
2022-01-25 03:32 AM
I've managed to find the error by myself:
...
...
<VARTYPE name="logstash_json_payload" dataType=FileBeatsEvent"/>
<DataType name="InternetTime" dateTime="%W-%M-%DT%H:%T:%S.%V%E" />
<DataType name="CollectionTime" type="InternetTime" meta="lc.ctime"/>
<DataType name="ElasticCommonSchemaSubset" format="JSON">
<Capture key="/@timestamp"> type="CollectionTime" />
<Capture key="/host/hostname"> meta="alias.host" />
<Capture key="/host/id"> meta="hardware.id" />
<Capture key="/host/os/name"> meta="OS" />
</DataType>
2022-02-07 02:56 AM
If the message is logstash/JSON, there is an easier way.
From v11.6, you can utilize Logstash/Beats plugin on Log Collector and use JSON Mappings on Log Parser Rules configuration.
Please, refer the attached ppt deck as an example.
Instead of writing a new parser, you can do same thing on web UI.
2022-05-30 04:25 AM
Hi,
If we make use of json mapping feature for logstash logs, how will it identify the header? As we will be using the header while mapping?
2022-06-14 04:17 AM - edited 2022-06-14 04:17 AM
For the JSON mapping, there is no concept of headers and messages.
As JSON is structured data, you only need to define hierachical path for each values.