# Help me to convert hexa in decimal value

**URL:** https://discuss.elastic.co/t/help-me-to-convert-hexa-in-decimal-value/77625
**Category:** Logstash
**Created:** [March 7, 2017, 9:42am UTC](https://discuss.elastic.co/t/help-me-to-convert-hexa-in-decimal-value/77625 "2017-03-07T09:42:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Beuhlet\_Reseau](https://avatars.discourse-cdn.com/v4/letter/b/e95f7d/32.png) [@Beuhlet\_Reseau](https://discuss.elastic.co/u/Beuhlet_Reseau)
#### Post date: [March 7, 2017, 9:42am UTC](https://discuss.elastic.co/t/help-me-to-convert-hexa-in-decimal-value/77625/1 "2017-03-07T09:42:47Z")

</div>

Hello, i search to convert hexa value in decimal value for performing.

I have found a ruby code in disucss but it's seems to be fail.

I use it to upload logs :

```
 mutate {
  convert => { "hexa_value" => "integer" }
       }

 ruby {
  code => "event.set('hexa_value', event.get('hexa_value').hex)"
      }

```

The error message :

```
 [ERROR][logstash.filters.ruby] Ruby exception occurred: undefined method `hex' for 2:Fixnum

```

Thank you

---

<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: [March 9, 2017, 3:25pm UTC](https://discuss.elastic.co/t/help-me-to-convert-hexa-in-decimal-value/77625/2 "2017-03-09T15:25:44Z")

</div>

Try `.to_s.hex` instead of `.hex`.

---

<div class="post-metadata">

### Author: ![Beuhlet\_Reseau](https://avatars.discourse-cdn.com/v4/letter/b/e95f7d/32.png) [@Beuhlet\_Reseau](https://discuss.elastic.co/u/Beuhlet_Reseau)
#### Post date: [March 13, 2017, 2:31pm UTC](https://discuss.elastic.co/t/help-me-to-convert-hexa-in-decimal-value/77625/3 "2017-03-13T14:31:49Z")

</div>

> [@Beuhlet\_Reseau](#):
>
> ruby {  
> code =\> "event.set('hexa\_value', event.get('hexa\_value').hex)"  
> }

@magnusbaeck You are a god 🙂

For everyone who search to convert hexa value in decimal value this code is ok :

```
ruby {
  code => "event.set('your_hexa_value', event.get('your_hexa_value').to_s.hex)"
     }

```

In Output your hexa value become a decimal value !

Thank a lots

---

<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: [April 10, 2017, 2:31pm UTC](https://discuss.elastic.co/t/help-me-to-convert-hexa-in-decimal-value/77625/4 "2017-04-10T14:31:55Z")

</div>

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