Hi,
This is the message source is sending to the logstash
<132>Mar 13 23:50:32 k8s-93f066ee-9b76 {\"projectid\":\"JHAR_BV\",\"_kmd\":{\"lmt\":\"2022-03-13T23:50:26:388Z\",\"ecf\":\"2022-03-13T23:50:26:388Z\"},\type\":\"warn\",\"createdOn\",\"2022-03-13T23:50:26:388Z\",\"deviceid\":\"web\",\"userid\":\:\"65678g54445s666544\,\"appVersion\":\"0.0\",\"platform\":\"web\",\"message\":\[\\\"\\\n It looks like you're using disabled attributes with reactive from directive.\\\\n\\\"]\",\_id\":\"65677vg65566\",\"app_key\":\"kid\"}"
I want to filter on the basis of projectid, the project id which has value "JHAR_BV" should go to output, all other should drop.
I created two grok filter for this which look like
filter {
grok {
match => { "message" => "%{SYSLOG5424PRI}%{MONTH:month} +%{NONNEGONT:day:int} +%{TIME:time} +%{DATA:kis} %{GREEDYDATA:json_payload}"}
match => { "message" => "%{SYSLOG5424PRI:number}%{CISCOTIMESTAMP:timestmp} %{DATA:id} %{GREEDYDATA:json_payload}"}
}
json {
source => "json_payload"
}
if [projectid] != "JHAR_BV" {
drop { }
}
}
Now the problem is I am not getting any error while starting the logstash, also data is not flowing to the output. I am not sure if the issue is with my grok or my applied logic is not correct?
You need to share your full pipeline and also the output you are getting, there is not enough information to know what is happening.
First you need to check if your grok and json filters are working and you have the field projectid, if you do not have this field, logstash will drop everything because your conditional will always be true.
Also, there is a type in one of your grok patterns, NONNEGONT, it is NONNEGINT.
This is my pipeline config and I want to drop all messages which don't have projectid=JHAR_BV. Updated the config but still getting nothing in the output.
You need to remove the drop part of your pipeline to be able to troubleshoot it, if there is something wrong in your grok, logstash will drop everything.
Remove this part to see what logstash is receiving and outputing.
As I said, without seeing what is your real output there is not much to help.
Your conditional would drop any message where the value for field projectid is not JHAR_BV, does your message have this field with this exact name and with this exact value?
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.