I wish to parse proxy logs using logstash. I have multiple IP fields in each document (log). I wish to parse the IP field as an object/array, not quite sure which is best suited for the requirement. The final output that i wish to achieve for each document would be something similar to as follows
The purpose of grouping these 3 fields is to query the IP field for any matches and retrieve relevant results. I am not sure if this falls under the Parent-Child type of a situation. I believe if this does fall under the Parent-Child scenario then achieving this directly in logstash would be difficult. Any help would be appreciated.
I think what i want to achieve is a Nested datatype.
Alright, now that I have realized my mistake, let me rephrase it. How do i create nested documents in Elasticssearch using Logstash?
I realize that you might need to use the Ruby filter. Any pointers or sample filter that I can refer? Not very familiar with Ruby.
Thank you for the reply. I was hoping that you would eventually land here and reply!
This works well for the srcip field. But there is an issue, the device ip and destination ip are already part of a nested field msg. The structure is as follows:
msg {
deviceip: 10.0.0.1
destip: 10.0.0.2
}
How do i use the rename filter in this scenario? I tried using the rename option of mutate, but it threw an exception error.
So, to a temporarily have a work around this issue I sent all the fields to the root of the message. Then using the rename option on the msg.deviceip and msg,dstip i tried using the rename filter. However, that gave an array that was not quite supported by Elasticsearch. I then even tried using the add_field option, but the document structure remained the same. Here is the structure:
"ip": [
[
"device",
"10.131.73.14"
],
"ip"
],
Is there something that i am currently doing wrong? Please help.
Also, purely for an academic purpose, how would i achieve if i have to work with the nested fields directly? is it possible to rename nested fields in such a way?
Also, purely for an academic purpose, how would i achieve if i have to work with the nested fields directly? is it possible to rename nested fields in such a way?
I resolved the issue. It was a stupid mistake on my end.
I did a add_field option before the rename and totally forgot about it.
add_field {
"ip" => "ip"
}
This created an object array, and then i ran into all kinds of issues, on removing that line and using the config you suggested, this is the output i receive:
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.