# How to get filename from filebeat json object in logstash filter?

**URL:** <https://discuss.elastic.co/t/how-to-get-filename-from-filebeat-json-object-in-logstash-filter/239844>\
**Category:** Logstash\
**Tags:** elastic-stack-monitoring\
**Created:** [July 3, 2020, 6:21pm UTC](https://discuss.elastic.co/t/how-to-get-filename-from-filebeat-json-object-in-logstash-filter/239844 "2020-07-03T18:21:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rashid\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashid_ali/32/45796_2.png) [@Rashid\_Ali](https://discuss.elastic.co/u/Rashid_Ali)\
**Post date:** [July 3, 2020, 6:21pm UTC](https://discuss.elastic.co/t/how-to-get-filename-from-filebeat-json-object-in-logstash-filter/239844/1 "2020-07-03T18:21:26Z")

</div>

I want to parse the file from the JSON object sent by filebeat to logstash file. Can anyone please help me here?

---

<div class="post-metadata">

**Author:** ![rugenl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rugenl/32/12887_2.png) [@rugenl](https://discuss.elastic.co/u/rugenl)\
**Post date:** [July 4, 2020, 2:56am UTC](https://discuss.elastic.co/t/how-to-get-filename-from-filebeat-json-object-in-logstash-filter/239844/2 "2020-07-04T02:56:42Z")

</div>

There are probably many ways, but I have this sample:

if [log][file][path] =~ /idp-warn.log/ {....}

---

<div class="post-metadata">

**Author:** ![Rashid\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashid_ali/32/45796_2.png) [@Rashid\_Ali](https://discuss.elastic.co/u/Rashid_Ali)\
**Post date:** [July 4, 2020, 9:13am UTC](https://discuss.elastic.co/t/how-to-get-filename-from-filebeat-json-object-in-logstash-filter/239844/3 "2020-07-04T09:13:45Z")

</div>

Its not working, condition always falls in else part

---

<div class="post-metadata">

**Author:** ![rugenl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rugenl/32/12887_2.png) [@rugenl](https://discuss.elastic.co/u/rugenl)\
**Post date:** [July 4, 2020, 12:10pm UTC](https://discuss.elastic.co/t/how-to-get-filename-from-filebeat-json-object-in-logstash-filter/239844/4 "2020-07-04T12:10:40Z")

</div>

Add a "debug" logstash [stdout](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-stdout.html) section, that will show your event field structure. Add metadata =\> true also.

Are you harvesting these logs with logstash on each host or are you using filebeat sending to logstash? My example is filebeat -\> logstash.

---

<div class="post-metadata">

**Author:** ![Rashid\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashid_ali/32/45796_2.png) [@Rashid\_Ali](https://discuss.elastic.co/u/Rashid_Ali)\
**Post date:** [July 6, 2020, 6:41am UTC](https://discuss.elastic.co/t/how-to-get-filename-from-filebeat-json-object-in-logstash-filter/239844/5 "2020-07-06T06:41:48Z")

</div>

Actually we have multiple machines with filebeatand all these machines will be sending logs to logstash on a single machine. That machine will be parsing and sending data to elasticsearch.  
This is my proposed architecture and i would like to have your kind commenst and suggestions on it as you must got a vast experience in it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 3, 2020, 6:41am UTC](https://discuss.elastic.co/t/how-to-get-filename-from-filebeat-json-object-in-logstash-filter/239844/6 "2020-08-03T06:41:49Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
