Hello all,
I am trying to use the filebeat.yml file for the first time. Since, the logs are being logged in a different country and sometimes I see an abrupt jump in the logs visibility. It might be (not sure) because previously those services were not online for the logs to ES clusters. Anyways, I want to get only the date and time and display that as a field in kibana logs.
For the solution, I am trying the script processors as follows:
- script:
lang: javascript
id: my_filter
tag: enable
source: >
function process(event) {
var str = event.Get("event.message");
var time = str.split(" ").slice(1,3).join("@");
event.Put("event.start_time",time);
}
- timestamp:
#format the start_time layouts then assign to @timestamp
field: start_time
layouts:
-'2006-01-02@15:04:05.999'
But in Kibana, I am not seeing any field which is "start_time"
Further, It took me a lot of time to write this script and combat with for correct syntax. Since, I am going to write lot of if else and slicing them based on condition, Any easier way to do this?
So, message in kibana shows [jgsdlkfgasgfy2346-asdsdhfbjsd] [2021-01-05 10:48:36.974] [INFO]..... I am trying to parse this message and get [2021-01-05 10:48:36.974] as a separate field (i.e. start_time) if possible.
Based on my limited understanding, I am using script processors which is posted above but I am not successful. I hope this helps.
Also, one more thing that I noticed was that,
in message : [hsjdfjsdgf-23hjsbdf-2346dsad] [2020-11-25 22:31:16.795] [INFO] but @timestamp is Dec 16, 2020. Hence, the counts of the service hits is very different. This is the main issue I am trying to solve which I do not think can be solved by just parsing.
event.timezone is ECS field. So I think when I put the above code in the filebeat.yml, I should be able to see the correct time in event.timezone field. However, I do not see that in kibana logs.
- if:
equals.log.file.path: "<filepath>"
then:
- dissect:
tokenizer: '[%{}] [%{start_time}] [%{}] [%{}] %{}'
field: "message"
else:
- timestamp:
#format the start_time layouts then assign to @timestamp
field: start_time
timezone: Europe
layouts:
-'2006-01-02 15:04:05.999'
I used the dissect processor and timestamp processor. I checked the date where the data/logs was ingested i.e. Dec 16. It still has the same issue though!
message: [sometext] [2020-11-30 02:10:17.736] [loglevel] [something] text1 - text2
But the @timestamp Dec 16, 2020 @ 18:59:59.715 Since it was recently ingested. Hence, my idea is to parse the message, get the start_time. Using the timezone and parsed value, pass it toas timestamp. Does it make sense now?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.