# Communication between ruby and translate plugin in logstash filter

**URL:** <https://discuss.elastic.co/t/communication-between-ruby-and-translate-plugin-in-logstash-filter/257828>\
**Category:** Logstash\
**Created:** [December 7, 2020, 10:11am UTC](https://discuss.elastic.co/t/communication-between-ruby-and-translate-plugin-in-logstash-filter/257828 "2020-12-07T10:11:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hzarrabi](https://avatars.discourse-cdn.com/v4/letter/h/f9ae1b/32.png) [@hzarrabi](https://discuss.elastic.co/u/hzarrabi)\
**Post date:** [December 7, 2020, 10:11am UTC](https://discuss.elastic.co/t/communication-between-ruby-and-translate-plugin-in-logstash-filter/257828/1 "2020-12-07T10:11:25Z")

</div>

Hi all,  
Do you have any idea or example how in ruby plugin (in logstash filter) invoke translate plugin and then collect and use the translated data again in ruby plugin?  
Thank.  
Best regards

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [December 7, 2020, 10:27am UTC](https://discuss.elastic.co/t/communication-between-ruby-and-translate-plugin-in-logstash-filter/257828/2 "2020-12-07T10:27:00Z")

</div>

Not sure if that is possible  
What is your specific use case ?

---

<div class="post-metadata">

**Author:** ![hzarrabi](https://avatars.discourse-cdn.com/v4/letter/h/f9ae1b/32.png) [@hzarrabi](https://discuss.elastic.co/u/hzarrabi)\
**Post date:** [December 7, 2020, 1:18pm UTC](https://discuss.elastic.co/t/communication-between-ruby-and-translate-plugin-in-logstash-filter/257828/3 "2020-12-07T13:18:05Z")

</div>

Hi ylasri,

I have xml Data input which is treated by a ruby code in Logstash filter.

I have to translate xml Fields which is done directly in ruby. This made ruby code huge.

That's way I've thought to divide the translation code by using translate plugin with translated entries in a file which is more easy to maintain and evolve as a dictionary file.

Thank,  
Best Regards

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [December 7, 2020, 2:13pm UTC](https://discuss.elastic.co/t/communication-between-ruby-and-translate-plugin-in-logstash-filter/257828/4 "2020-12-07T14:13:07Z")

</div>

I suggest your parse your XML data using logstash [XML filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-xml.html)  
Then apply [translate filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html) to the field you want to enrich  
Then you can use ruby filter if you want to add any custom logic that is not supported by logstash filters

---

<div class="post-metadata">

**Author:** ![hzarrabi](https://avatars.discourse-cdn.com/v4/letter/h/f9ae1b/32.png) [@hzarrabi](https://discuss.elastic.co/u/hzarrabi)\
**Post date:** [December 8, 2020, 1:01pm UTC](https://discuss.elastic.co/t/communication-between-ruby-and-translate-plugin-in-logstash-filter/257828/5 "2020-12-08T13:01:00Z")

</div>

Hi ylasri,

Thank you so much.  
Unfortunately, I didn't do that as you have suggested.  
I just used xml plugin to parse the xml files and then to pass the xpath to ruby in which I do translation as well.  
I should review all my code and change it in order to call translate filter in xml one.  
To avoid that, do you have another solution with witch ruby can call translate filter?  
Best Regards

---

<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:** [January 5, 2021, 1:01pm UTC](https://discuss.elastic.co/t/communication-between-ruby-and-translate-plugin-in-logstash-filter/257828/6 "2021-01-05T13:01:02Z")

</div>

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