# My own logstash filter doesn't extract the input field value correctly

**URL:** https://discuss.elastic.co/t/my-own-logstash-filter-doesnt-extract-the-input-field-value-correctly/59803
**Category:** Logstash
**Created:** [September 5, 2016, 11:17am UTC](https://discuss.elastic.co/t/my-own-logstash-filter-doesnt-extract-the-input-field-value-correctly/59803 "2016-09-05T11:17:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)
#### Post date: [September 5, 2016, 11:17am UTC](https://discuss.elastic.co/t/my-own-logstash-filter-doesnt-extract-the-input-field-value-correctly/59803/1 "2016-09-05T11:17:25Z")

</div>

Hello folks,

I have built my own plugin filter for logstash. The principle of this  
filter is to get some coordinates (x,y) formated in a coordinates  
system called "lambertII" and to convert them in gps system (latitude,  
longitude). Here is an example:

```
lambert {
    convert => ["lambertII", x, y]
    latitude => ["lat"] #return as output latitude
    longitude => ["long"] #return as output longitude
}

```

It works well when I write for instance:

```
 convert => ["LambertII", 2478517.33, 547536.68]

```

However, when I extract data from a json file as shown below

```
{"x":2478517.33, "y":547536.68}
{"x":2699120.65, "y":544959.56}

```

but it does not work, when I write:

```
 convert => ["LambertII", "%{[x]}", "%{[y]}"] 

```

or

```
convert => ["LambertII", "%{x}", "%{y}"] 

```

Indeed, my ruby code does not extract the float value from the  
expressions "%{[..]}" or "%{..}" but it interprets them like string  
expressions.

I have already seen this following link but it didn't solve my problem: [https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#event-dependent-configuration](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#event-dependent-configuration)

I didn't find out how to solve this problem. I would be very thankful for any help.

Thank you for your attention and your help !

PS: I can provide my ruby code lambert.rb if it is usefull

---

<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: [September 5, 2016, 11:40am UTC](https://discuss.elastic.co/t/my-own-logstash-filter-doesnt-extract-the-input-field-value-correctly/59803/2 "2016-09-05T11:40:44Z")

</div>

It seems you're not calling event.sprintf() on the field values.

---

<div class="post-metadata">

### Author: ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)
#### Post date: [September 5, 2016, 11:57am UTC](https://discuss.elastic.co/t/my-own-logstash-filter-doesnt-extract-the-input-field-value-correctly/59803/3 "2016-09-05T11:57:41Z")

</div>

thank you very much Magnus, I was so stuck 😃 !

---

<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: [July 6, 2017, 4:39am UTC](https://discuss.elastic.co/t/my-own-logstash-filter-doesnt-extract-the-input-field-value-correctly/59803/4 "2017-07-06T04:39:54Z")

</div>


