I want to index this JSON file :
{"environment":"urban","envType":"outdoor","positionNumber":1,"frameIndex":15,"fcntUp":22324,"numberOfGateways":3,"numberOfTimestamps":0,"serverTimestamp":"23:44:36","lnsAppEui":"4883C7DF30040000","lnsDevEui":"4883C7DF3004223A","lnsNetId":"000007","lnsServerTimestamp":"27/10/2017 23:44:36","gtwFrequency":868.1,"gtwDataRate":"SF10_BW_125","estimatedLongitudeWGS84":null,"estimatedLatitudeWGS84":null,"deviceLongitudeWGS84":2.289511063734628,"deviceLatitudeWGS84":48.88373587201055,"spreadingFactor":10,"accuracy":null,"estimatedAccuracy":null,"averageISD":null,"hdopDevice":null,"hdopEstimated":null,"gateways":[{"antennaLongitude":2.2957080835783388,"rssi":-107.7376019773414,"rssiStandardDeviation":-95.0,"elapsedTimeSince1PPS":0.0,"antennaID":"1","antennaLatitude":48.89112433031253,"gatewayTimestamp":"27/10/2017 23:44:31","snr":-12.5,"frequencyOffset":0,"lnsServerTimestamp":"27/10/2017 23:44:36","rssiSignal":-95.0,"gatewayID":"M15279"},{"antennaLongitude":2.2932473657963164,"rssi":-107.1244260279434,"rssiStandardDeviation":-103.0,"elapsedTimeSince1PPS":0.0,"antennaID":"1","antennaLatitude":48.88193968215203,"gatewayTimestamp":"27/10/2017 23:44:32","snr":-2.0,"frequencyOffset":0,"lnsServerTimestamp":"27/10/2017 23:44:36","rssiSignal":-103.0,"gatewayID":"M15073"},{"antennaLongitude":2.3014574627818787,"rssi":-104.59612087980607,"rssiStandardDeviation":-94.0,"elapsedTimeSince1PPS":0.0,"antennaID":"1","antennaLatitude":48.87684647097623,"gatewayTimestamp":"27/10/2017 23:44:32","snr":-10.2,"frequencyOffset":0,"lnsServerTimestamp":"27/10/2017 23:44:36","rssiSignal":-94.0,"gatewayID":"M15913"}],"loraDevAddr":"0F127D87"}
My goal is to map gateways positions on the kibana Map (position = [antennaLongitude, antennaLatitude]
I changed my template by adding a nested field here is my template:
{
"template" : "logstash-*",
"version" : 50001,
"settings" : {
"index.refresh_interval" : "5s",
"index.mapping.ignore_malformed": true
},
"mappings" : {
"_default_" : {
"_all" : {"enabled" : true, "norms" : false},
"dynamic_templates" : [ {
"message_field" : {
"path_match" : "message",
"match_mapping_type" : "string",
"mapping" : {
"type" : "text",
"norms" : false
}
}
}, {
"string_fields" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "text", "norms" : false,
"fields" : {
"keyword" : { "type": "keyword", "ignore_above": 256 }
}
}
}
} ],
"properties" : {
"@timestamp": { "type": "date", "include_in_all": false },
"@version": { "type": "keyword", "include_in_all": false },
"geoip" : {
"type" : "geo_point"
},
"geoip_Dev": {
"type" : "geo_point"
},
"geoip_gwy": {
"type" : "geo_point"
},
"gateways":{
"type": "nested",
"properties": {
"antennaLatitude":{"type":"float"},
"antennaLongitude":{"type":"float"},
"position": {"type": "geo_point"}
}
}
}
}
}
}
and Here is my logstash conf file
input {
file {
type => "gtw"
path => ["D:/Users/G361164/Desktop/test/*STATIC*.json"]
start_position => beginning
# to read from the beginning of file
sincedb_path => "/dev/null"
codec => json
}
}
filter{
if [type] == "gtw"{
mutate {
add_field => { "[gateways]" => "%{[gateways]}" }
#add_field => { "[gateways][position][lon]" => "%{[gateways][antennaLongitude]}" }
}
ruby {
code => "
event.get('gateways').each { |x|
event.set([gateways.position][lat] , event.get(x['antennaLongitude']))
event.set([gateways.position][lon] , event.get(x['antennaLongitude']))
}
"
}
}
}
output {
elasticsearch {
index => "logstash-gatewaysss222222%{+YYYY.MM.dd}"
template => "D:/Users/G361164/Desktop/Demo/template/template_geoip.json"
template_name => "gateways_positions"
}
stdout { codec => rubydebug }
}
I received this error while indexing:
failed to execute bulk item (index) BulkShardRequest [[logstash-gatewaysss2222222018.04.16][0]] containing [index {[logstash-gatewaysss2222222018.04.16][gtw][AWLOld1-1vhpJFP5cFy-], source[n/a, actual length: [2.7kb], max length: 2kb]}]
org.elasticsearch.index.mapper.MapperParsingException: object mapping for [gateways] tried to parse field [null] as object, but found a concrete value
Can help me to attend my goal by adding a geo_point varibale "position" inside each gateway and contains latitude and longitude !!?