I have a string field that is in Latitude, Longitude, Altitude. In the pipeline, I am taking the location in x, y, z in ECEF coordinates and converting to LLA:
- pipeline.id: entity-state-processing
config.string: |
input { pipeline { address => entitystatelogs } }
filter {
# Checks if the log has locational data before processing it into WGS 84 lat/long
if [attributes][entityLocation] {
mutate {
add_field => {
"[location]" => "null"
}
}
# Ruby script to convert the cartesian x,y,z coordinates into lat/long
ruby {
init => "
R = 6360000
"
code => "
x = event.get('[attributes][entityLocation][x]').to_f
y = event.get('[attributes][entityLocation][y]').to_f
z = event.get('[attributes][entityLocation][z]').to_f
range = Math.sqrt(x*x + y*y + z*z)
lat = 180*Math.asin(z/range)/Math::PI
long = 180*Math.atan2(y,x)/Math::PI
alt = range - 6369783.457722581
event.set('[location]', lat.to_s + ',' + long.to_s, + ',' + alt.to_s)
"
}
}
}
output {
# Sends parsed logs to elasticsearch
elasticsearch {
hosts => ["${OUTPUT_HOST}"]
user => "${ELASTIC_USER}"
password => "${ELASTIC_PASS}"
index => "{{ .Release.Namespace }}-entity-state-%{+yyyy.MM.dd}"
}
}
So, in ELK, location is a string that looks like: (12.5, 50, 1000). Is there a way to convert this to a geo-point inside the pipeline? Do I have to use a template. If so, how is that done?