# How use translate in json object?

**URL:** <https://discuss.elastic.co/t/how-use-translate-in-json-object/108421>\
**Category:** Logstash\
**Created:** [November 20, 2017, 4:07pm UTC](https://discuss.elastic.co/t/how-use-translate-in-json-object/108421 "2017-11-20T16:07:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kar](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@kar](https://discuss.elastic.co/u/kar)\
**Post date:** [November 20, 2017, 4:07pm UTC](https://discuss.elastic.co/t/how-use-translate-in-json-object/108421/1 "2017-11-20T16:07:14Z")

</div>

Hello  
This is my json:

> {"serial\_number":"36307","time":"2017-11-20 08:10:40.340 +03:00","transaciton\_id":"","card\_hash":"","component":"READER","level":"DEBUG","message":"Request": SrvOpen: SrvOpenRequest: {"TgComName":"/dev/oti"}"}

I need translate my field serial\_number according with my yml file.

krotov@test:~$ cat /etc/logstash/dict.yml  
"36322": It worked!  
So. How i can translate this field?  
My config:

> input {  
> tcp {  
> port =\> 5044  
> host =\> '0.0.0.0'  
> }  
> }  
> filter {  
> date {  
> match =\> ["timestamp" , "dd/MMM/YYYY:HH:mm:ss Z"]  
> remove\_field =\> ["timestamp"]  
> }  
> json {  
> source =\> "message"  
> target =\> "css"  
> remove\_field =\> "message"  
> add\_field =\> {"sn" =\> "%{serial\_number}" } ###- this not work. in kibana saw sn: %{serial\_number}. ###  
> }  
> translate {  
> field =\> "serial\_number"  
> destination =\> "translate"  
> dictionary\_path =\> "/etc/logstash/dict.yml"  
> override =\> "true"  
> }  
> }  
> output {  
> elasticsearch {  
> hosts =\> "127.0.0.1:9200"  
> index =\> "mgt"  
> codec =\> rubydebug  
> document\_type =\> "%{[@metadata][type]}"  
> }

Pls help with this. Sorry for bad language

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 21, 2017, 6:48am UTC](https://discuss.elastic.co/t/how-use-translate-in-json-object/108421/2 "2017-11-21T06:48:55Z")

</div>

> ###- this not work. in kibana saw sn: %{serial\_number}.

That indicates that your document doesn't have a `serial_number` field, which would also explain why the translate filter isn't working. Show a complete example document, e.g. by using a `stdout { codec => rubydebug }` output.

---

<div class="post-metadata">

**Author:** ![kar](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@kar](https://discuss.elastic.co/u/kar)\
**Post date:** [November 21, 2017, 7:21am UTC](https://discuss.elastic.co/t/how-use-translate-in-json-object/108421/3 "2017-11-21T07:21:02Z")

</div>

Thank you. output there:

> output received {"event"=\>{"css"=\>{"card\_hash"=\>"", "component"=\>"PLATFORM", "level"=\>"DEBUG", "serial\_number"=\>"36307", "time"=\>"2017-11-20 08:10:40.332 +03:00", "transaciton\_id"=\>"", "message"=\>"Получена команда от АСКП"}, "@timestamp"=\>2017-11-21T07:17:23.943Z, "port"=\>34116, "@version"=\>"1", "host"=\>"localhost", "@metdata"=\>{"ip\_address"=\>"127.0.0.1"}, "sn"=\>"%{serial\_number}"}}

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [November 21, 2017, 7:22am UTC](https://discuss.elastic.co/t/how-use-translate-in-json-object/108421/4 "2017-11-21T07:22:29Z")

</div>

If your json document has a `serial_number` field, you are putting this under `css` as you have the `target` parameter set. This means that you would need to specify `%{[css][serial_number]}`.

---

<div class="post-metadata">

**Author:** ![kar](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@kar](https://discuss.elastic.co/u/kar)\
**Post date:** [November 21, 2017, 7:40am UTC](https://discuss.elastic.co/t/how-use-translate-in-json-object/108421/5 "2017-11-21T07:40:31Z")

</div>

It worked!  
Thank you!  
This way exist in documentation? I could not find.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [November 21, 2017, 7:45am UTC](https://discuss.elastic.co/t/how-use-translate-in-json-object/108421/6 "2017-11-21T07:45:09Z")

</div>

[Here is an example](https://www.elastic.co/guide/en/logstash/6.0/event-dependent-configuration.html#sprintf) of how to address nested fields.

---

<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:** [December 19, 2017, 7:45am UTC](https://discuss.elastic.co/t/how-use-translate-in-json-object/108421/7 "2017-12-19T07:45:28Z")

</div>

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