# How to write this algorithm in Logstash and display the new fields in Kibana

**URL:** https://discuss.elastic.co/t/how-to-write-this-algorithm-in-logstash-and-display-the-new-fields-in-kibana/93534
**Category:** Logstash
**Created:** [July 18, 2017, 9:12am UTC](https://discuss.elastic.co/t/how-to-write-this-algorithm-in-logstash-and-display-the-new-fields-in-kibana/93534 "2017-07-18T09:12:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Alex\_S](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@Alex\_S](https://discuss.elastic.co/u/Alex_S)
#### Post date: [July 18, 2017, 9:12am UTC](https://discuss.elastic.co/t/how-to-write-this-algorithm-in-logstash-and-display-the-new-fields-in-kibana/93534/1 "2017-07-18T09:12:09Z")

</div>

Hello Geeks 🙂

I have this pesudo code that I want to translate into a Logstash plugin and show the lat and long fields into Kibana ...

Assume the following variables are to be used in the calculation/conversion:

x\_range = 2360  
y\_range = 718  
lat\_min = -45.025760784097045  
lat\_max = 45  
long\_min = -105  
long\_max = 104.96748940076955  
lat\_range = lat\_max - lat\_min  
long\_range = long\_max - long\_min

Based on this you need to project the coordinate onto the lat/long space.

lat = lat\_min + (Y \* lat\_range / y\_range)  
long = long\_min + (X \* long\_range / x\_range)

As I am not a Ruby developer I couldn't translate this into a Ruby filter ;'))  
and display the new fields into Kibana

Thanks very much for you efforts ;)))

---

<div class="post-metadata">

### Author: ![Andrew\_Cholakian1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_cholakian1/32/3612_2.png) [@Andrew\_Cholakian1](https://discuss.elastic.co/u/Andrew_Cholakian1)
#### Post date: [July 21, 2017, 3:21pm UTC](https://discuss.elastic.co/t/how-to-write-this-algorithm-in-logstash-and-display-the-new-fields-in-kibana/93534/2 "2017-07-21T15:21:24Z")

</div>

The ruby code should be something like:

```auto
event.set('[lat]', event.get('[lat_min]') + (event.get('[y]') * event.get('[lat_range]') / event.get('[y_range]') )

```

That assumes the values you provided are included as fields on the event. If that is not the case, then you can just sub out any occurrence of `event.get('[field]')` with a constant like `2360`.

for the lat, you'd need a second line doing the same for long of course. Also, you'd need to set the `y` property in logstash.

---

<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: [August 18, 2017, 3:21pm UTC](https://discuss.elastic.co/t/how-to-write-this-algorithm-in-logstash-and-display-the-new-fields-in-kibana/93534/3 "2017-08-18T15:21:25Z")

</div>

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