# Translate doesnt work when key in yml dictionary is a number

**URL:** <https://discuss.elastic.co/t/translate-doesnt-work-when-key-in-yml-dictionary-is-a-number/284767>\
**Category:** Logstash\
**Created:** [September 21, 2021, 9:14pm UTC](https://discuss.elastic.co/t/translate-doesnt-work-when-key-in-yml-dictionary-is-a-number/284767 "2021-09-21T21:14:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [September 21, 2021, 9:14pm UTC](https://discuss.elastic.co/t/translate-doesnt-work-when-key-in-yml-dictionary-is-a-number/284767/1 "2021-09-21T21:14:54Z")

</div>

Hi, I have this yml dictionary

```auto
1967345056 : "VISACI nodata IIS"

```

and this is the translate:

```auto
    translate {
        field => "[monitorgroup]"
        destination => "[nuevo_campo]"
        dictionary_path => "/etc/logstash/conf.d/list-clients.yml"
        fallback => "no match"
    }

```

-The path is right, the field exists, is a string  
-I have tried to convert the field "monitorgroup" to integer, doesnt work either  
-I have checked that the spaces in the dictionary are not tabs in VScode  
-Usually when you open a YML in Vim editor, it colours the dictionary, but with this file that doesnt happens, I dont know if this is relevant  
-Im running logstash with the command:  
` /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/filebeat/my.conf`  
dont know if this is relevant either

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 21, 2021, 9:39pm UTC](https://discuss.elastic.co/t/translate-doesnt-work-when-key-in-yml-dictionary-is-a-number/284767/2 "2021-09-21T21:39:57Z")

</div>

The translate filter [coerces](https://github.com/logstash-plugins/logstash-filter-translate/blob/e3670bb3137437ad05a90036a90b4711a67e04ea/lib/logstash/filters/single_value_update.rb#L34) the key to be a string before doing the lookup.

I wonder if this is because either libyaml or [Psych](https://github.com/ruby/psych) (the ruby wrapper for it) convert numeric keys to strings.

Can you change your dictionary to this?...

```
"1967345056" : "VISACI nodata IIS"
```

---

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [September 21, 2021, 9:51pm UTC](https://discuss.elastic.co/t/translate-doesnt-work-when-key-in-yml-dictionary-is-a-number/284767/3 "2021-09-21T21:51:16Z")

</div>

Hi, badger, tried just now, doesnt work either, as a string or as an integer, when adding the quotes

the logstash version is 7.2, I have other pipelines with translate, one with IP addreses as keys, and another with strings as key, but this is only one that doesnt work....same file permission.

---

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [September 21, 2021, 10:26pm UTC](https://discuss.elastic.co/t/translate-doesnt-work-when-key-in-yml-dictionary-is-a-number/284767/4 "2021-09-21T22:26:24Z")

</div>

Hey @Badger , I think you where into something....I preppend an "a" to the value of the field in the pipeline and in the yml, and now it works.

```auto
    mutate {
              add_field => { "testmon" => "a%{monitorgroup}" }
   }

```

YML

```auto
a1967345056 : "VISACI nodata IIS"

```

can you think of what whas happening? i dont get it.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 21, 2021, 10:49pm UTC](https://discuss.elastic.co/t/translate-doesnt-work-when-key-in-yml-dictionary-is-a-number/284767/5 "2021-09-21T22:49:59Z")

</div>

> [@Badger](#):
>
> `"1967345056" : "VISACI nodata IIS"`

When I tested that it worked OK. You did have [monitorgroup] as a string too, right?

---

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [September 21, 2021, 10:53pm UTC](https://discuss.elastic.co/t/translate-doesnt-work-when-key-in-yml-dictionary-is-a-number/284767/6 "2021-09-21T22:53:09Z")

</div>

yes, I tried as a string and as a integer 🤷‍♂️

---

<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:** [October 19, 2021, 10:53pm UTC](https://discuss.elastic.co/t/translate-doesnt-work-when-key-in-yml-dictionary-is-a-number/284767/7 "2021-10-19T22:53:31Z")

</div>

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