Logstash: convert lambert to latitude and logitude

Hello folks,

I am working on a project where I have in my input data some coordinates in lambert. i would like to convert these coordinates in latitude and longitude. I found on internet a function in ruby to do it: https://github.com/yageek/lambert-ruby . However, I don't think I can use it in logstash. Then, do you know if there is a function or a plugin in logstash.

Thank you for your attention and your help.

S

Unless lambert is some kind of cheese, you may need to explain what it is.

haha
Lambert enables to get another type of geographical coordinates based on coni map projection.
Here is the wikipedia link to get all details: https://en.wikipedia.org/wiki/Lambert_conformal_conic_projection

My purpose is just to convert this reprsentation in latitude and longitude coordinates

I wrote my own plugin by using the ruby code indicated in my question and the following tutorial: https://www.elastic.co/guide/en/logstash/current/_how_to_write_a_logstash_filter_plugin.html

Well that's definitely one solution :wink:
Any plans to open source it?

Yes, i will do in the end of the week !

1 Like

I have just one problem with my filter. Indeed, my filter works like this:
convert => ["typeLambert", x, y]
where:

  • typelambert is the type of lambert (string)
  • x is the lattitude in lamber (float type)
  • y is the longitude in lambert (float type)

where I write, for instance, convert => ["LambertIIExtended", 2478517.33, 547536.68] , it works well !
But, when I read a file or a kafka topic where I have parameters like below:
{"lati":2478517.33, "longi":547536.68}
{"lati":2699120.65, "longi":544959.56}
{"lati":2149001.71, "longi":588529.14}
It does not work when I write convert => ["LambertIIExtended", "%{[lati]}", "%{[longi]}"]

I printed the output results and ruby does not get the float value of my parameters lati and longi, it reads and prints them exactly like strings "%{[lati]}" and "%{[longi]}". Do you knwo how I could solve this ?

I put in Annexe my filter part.
My logstash filter part:
filter {
lambert {
convert => ["LambertIIExtended", "%{[lati]}", "%{[longi]}"] #it does work because
#convert => ["LambertIIExtended", 2478517.33, 547536.68] #it works
latitude => ["latnew"]
longitude => ["longnew"]
}
}

PS: if you need my ruby code, I can provide it. (it is just a little bit long that's why I did not add here)

I don't think your field references are correct, have a look at https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references

Thanks for the link but I already tried to use like shown in the link: "%{lati}" or " %{[lati]} and it does not work !!!

i am really stuck and I don't know how to do

@sen, any chance to see your code already, hosted somewhere like github ?
it would be easier to check how you are retrieving the event value,
It is the responsibility of the plugin to fetch the needed data from the event with event.get() or event.sprintf() and is not done on your behalf internally

1 Like