# Logstash translate filter

**URL:** https://discuss.elastic.co/t/logstash-translate-filter/119923
**Category:** Logstash
**Created:** [February 15, 2018, 6:51am UTC](https://discuss.elastic.co/t/logstash-translate-filter/119923 "2018-02-15T06:51:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Harsh\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harsh_jain/32/132648_2.png) [@Harsh\_Jain](https://discuss.elastic.co/u/Harsh_Jain)
#### Post date: [February 15, 2018, 6:51am UTC](https://discuss.elastic.co/t/logstash-translate-filter/119923/1 "2018-02-15T06:51:09Z")

</div>

I'm new to the Elastic stack and Logstash. I have a new Logstash instance that is accepting logs from beats sending to Elasticsearch. I am trying to apply translate filter based on regex keys. Here the key point to note is that I want replacement based on backreferences, i.e., replacement string must contain substring of searched string.

For e.g.  
/abc/xyz/3rfd3ed32dedece has to be translated into /abc/xyz/. Here “/abc/xyz” may vary.

I have used dictonary (json) for applying translation.

Dictionary contains:  
{  
“^(\/[\w]\*\/[\w]\*\/).\*$”: “$1”  
}

I am not able to use backreferences in translate filter. Is it possible to use them. If yes, then how we can use it.

---

<div class="post-metadata">

### Author: ![paz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paz/32/28003_2.png) [@paz](https://discuss.elastic.co/u/paz)
#### Post date: [February 15, 2018, 1:56pm UTC](https://discuss.elastic.co/t/logstash-translate-filter/119923/2 "2018-02-15T13:56:52Z")

</div>

Sounds like you just want to grab a specific part of the value and skip the rest. Is that correct?  
If so, I don't think the translate filter is the most suitable for that kind of operation. Some custom Ruby code would be far easier.

---

<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: [March 15, 2018, 1:57pm UTC](https://discuss.elastic.co/t/logstash-translate-filter/119923/3 "2018-03-15T13:57:16Z")

</div>

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