2016-04-25 3 views
1

Ich verwende Logstash 2.3.1, Elasticsearch 2.3.1 und Kibi 0.3.2. Ich habe Probleme, Orte in einer Karte mit Kibi zu visualisieren.Zeige Positionspunkte in einer Kachelkarte mit Kibi

Ich habe die folgende Konfiguration in logstash:

input { 
    file { 
     path => "/opt/logstash-2.3.1/logTest/Dades.csv" 
     type => "Dades" 
     start_position => "beginning" 
    } 
} 

filter { 
    csv { 
     columns => ["c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11", "c12", "c13", "c14", "c15", "c16", "c17", "c18", "c19", "c20", "c21", "c22", "c23"] 
     separator => ";" 
    } 

ruby { 
     code => " 
       temp = event['c17'] 
     event['c17'] = temp[0..1].to_f+ (temp[2..8].to_f/60) 
     temp = event['c19'] 
     event['c19'] = temp[0..2].to_f+ (temp[3..8].to_f/60) 

     " 
    } 

     mutate { 
      convert => { 
      "c3" => "float" 
      "c5" => "float" 
      "c7" => "float" 
      "c9" => "float" 
      "c11" => "float" 
      "c13" => "float" 
      "c15" => "float" 
      "c21" => "float" 
      "c23" => "float" 
     } 

    } 

    date { 
     match => [ "c1", "dd/MM/YYYY HH:mm:ss.SSS", "ISO8601"] 
      target => "ts_date" 
    } 


    mutate { 
      rename => [ "c17", "[location][lat]", 
      "c19", "[location][lon]" ] 
    } 
} 


output { 
    elasticsearch { 
     hosts => localhost 
     index => "tram3" 
     manage_template => false 
     template => "tram3_template.json" 
     template_name => "tram3" 
     template_overwrite => "true" 
    } 
    stdout { 
     codec => rubydebug 
    } 
} 

Die Mapping-Konfigurationsdatei (tram3_template.json) ist wie folgt:

{ 
    "template": "tram3", 
    "order": 1, 
    "settings": { 
    "number_of_shards": 1 
    }, 
    "mappings": { 
    "tram3": { 
     "_all": { 
     "enabled": false 
     }, 
     "properties": { 
      "location": { 
      "type": "geo_point" 
     } 
     } 
    } 
    } 
} 

Wenn ich de CSV-Datei importieren zu Elasticsearch scheint, dass Alles funktioniert gut. Der Ausgang ist so etwas wie diese:

{ 
     "message" => "26/02/2016 00:00:22.984;Total;4231.143555;Trac1;26.547932;Trac2;-338.939697;AA1;-364.611511;AA2;3968.135010;Reo1;0.000000;Reo2;0.000000;Latitud;4125.1846;Longitud;00213.5219;Speed;0.000000;CVS;3873.429443;\r", 
     "@version" => "1", 
    "@timestamp" => "2016-04-25T14:02:52.901Z", 
      "path" => "/opt/logstash-2.3.1/logTest/Dades.csv", 
      "host" => "ubuntu", 
      "type" => "Dades", 
      "c1" => "26/02/2016 00:00:22.984", 
      "c2" => "Total", 
      "c3" => 4231.143555, 
      "c4" => "Trac1", 
      "c5" => 26.547932, 
      "c6" => "Trac2", 
      "c7" => -338.939697, 
      "c8" => "AA1", 
      "c9" => -364.611511, 
      "c10" => "AA2", 
      "c11" => 3968.13501, 
      "c12" => "Reo1", 
      "c13" => 0.0, 
      "c14" => "Reo2", 
      "c15" => 0.0, 
      "c16" => "Latitud", 
      "c18" => "Longitud", 
      "c20" => "Speed", 
      "c21" => 0.0, 
      "c22" => "CVS", 
      "c23" => 3873.429443, 
     "column24" => nil, 
     "ts_date" => "2016-02-25T23:00:22.984Z", 
     "location" => { 
     "lat" => 41.41974333333334, 
     "lon" => 2.22535 
    } 
} 

Aber wenn ich versuche, den Standort Parameter in einer Karte zu visualisieren es zeigt kein Ergebnis:

enter image description here

Ich weiß nicht, was ich mache ich falsch. Warum erscheint der Ortspunkt nicht in der Karte?

Antwort

1

In Ihrer ES-Zuordnungsdatei müssen Sie wahrscheinlich das Speichern des geohash-Unterfelds (standardmäßig false) aktivieren, da die geohash-Aggregation ohne sie nicht funktionieren kann.

{ 
    "template": "tram3", 
    "order": 1, 
    "settings": { 
    "number_of_shards": 1 
    }, 
    "mappings": { 
    "tram3": { 
     "_all": { 
     "enabled": false 
     }, 
     "properties": { 
      "location": { 
      "type": "geo_point", 
      "geohash": true,   <-- add this 
      "geohash_prefix": true  <-- add this 
     } 
     } 
    } 
    } 
} 

Dann können Sie eine geohash Aggregation auf dem location.geohash Feld bauen

Beachten Sie, dass, wenn Sie alle geohash Präfixe auch indizieren möchten, können Sie auch "geohash_prefix": true zu Ihrem Feldzuordnung hinzufügen.

UPDATE

Nach dem Fall wiedergibt, hier sind einige weitere Korrekturen zu tun:

Sie müssen die type in Ihrem file Eingang ändern, da es als Dokumenttyp und Ihre Mapping verwendet werden gibt an, dass der Mapping-Typ dades2 nicht Dades benannt ist:

file { 
    path => "/opt/logstash-2.3.1/logTest/Dades.csv" 
    type => "dades2" 
    start_position => "beginning" 
    sincedb_path => "/dev/null" 
} 

Ihre elasticsearch aus Put sollte wie folgt aussehen, nämlich manage_template sollte wahr sein und den vollen Pfad zu Ihrer dades2_template.json Datei verwenden (stellen Sie sicher, dass Sie /full/path/to mit dem tatsächlichen Pfadnamen ändern.

elasticsearch { 
    hosts => localhost 
    index => "dades2" 
    manage_template => true 
    template => "/full/path/to/dades2_template.json" 
    template_name => "dades2" 
    template_overwrite => "true" 
} 

Die neue dades2_template.json-Datei wie folgt

{ 
    "template": "dades2", 
    "order": 1, 
    "settings": { 
    "number_of_shards": 1 
    }, 
    "mappings": { 
    "dades2": { 
     "_all": { 
     "enabled": false 
     }, 
     "properties": { 
      "location": { 
      "type": "geo_point", 
      "geohash": true, 
      "geohash_prefix": true 
     } 
     } 
    } 
    } 
} 
+0

Dank für Ihre Antwort aussehen sollte! Ich habe "geohash": true' und '" geohash_prefix ": true' in der Mapping-Datei hinzugefügt und die Geopoints erscheinen nicht in der Map :( – JosepB

+0

Haben Sie Ihren Index gelöscht und neu von Grund auf neu erstellt + re -indizierte Ihre Daten? – Val

+0

Ja, ich habe einen neuen Index mit einem anderen Namen und einer neuen Zuordnungsdatei erstellt – JosepB

Verwandte Themen