如何将logstash中的位置(lon,lat)映射到kibana中可视化? [英] How to map location (lon, lat) in logstash to visualize in kibana?

查看:528
本文介绍了如何将logstash中的位置(lon,lat)映射到kibana中可视化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个csv文件,其中包含一些记录的经度和纬度(否则是)。现在我想使用logstash 5.1.2将数据转换为elasticsearch 5.1.2。我写了以下conf文件,但位置字段仍映射到文本。

  input {
file {
path => /usr/local/Cellar/logstash/5.1.2/bin/data.csv
start_position => 开始
sincedb_path => / dev / null
}
}

过滤器{
csv {
列=> ['logtime','text','user','country','location']
separator => ,
}
日期{
match => [logtime,yyyy-MM-dd HH:mm:ss]
timezone => 欧洲/伦敦
目标=> 日期
}
如果[latitude]和[longitude] {
mutate {convert => {纬度=> float}}
mutate {convert => {longitude=> float}}
mutate {rename => {纬度=> [location] [lat]}}
mutate {rename => {longitude=> [location] [lon]}}
}
}

输出{
elasticsearch {
hosts => [localhost:9200]
index => twitter}
}

我应该怎样做位置字段映射作为地理点,并能够在Kibana 5.1.2中将地图上的点可视化?谢谢

解决方案

您需要创建一个将位置映射到geo_point。最简单的方法是使用索引模板,以便在开始使用基于时间的索引时,它会在创建新索引时自动创建映射。

 PUT / _template / twitter 
{
order:0,
template:twitter *,
mappings: {
_default_:{
properties:{
location:{
type:geo_point
}
}



code
$ b

然后删除你的 / twitter 索引并重新索引您的数据。

上面的模板表示任何使用名称<$ c创建的索引$ c> twitter * 会将任何 _type 位置字段变成 geo_point


I have a csv file holding longitude and latitude for some of the records (otherwise it's " "). Now I want to use logstash 5.1.2 to ge the data into elasticsearch 5.1.2. I've written the following conf-file but the location field is still mapped to text.

input {  
      file {
            path => "/usr/local/Cellar/logstash/5.1.2/bin/data.csv"
            start_position => "beginning"
            sincedb_path => "/dev/null"
      }
}

filter {  
    csv {
        columns => ['logtime', 'text', 'user', 'country', 'location']
        separator => ","
    }
    date {
        match => ["logtime", "yyyy-MM-dd HH:mm:ss"]
        timezone => "Europe/London"
        target => "Date"
    }
    if [latitude] and [longitude] {
    mutate { convert => {"latitude" => "float"} }
    mutate { convert => {"longitude" => "float"} }
    mutate { rename => {"latitude" => "[location][lat]"} }
    mutate { rename => {"longitude" => "[location][lon]"} }
    }
}

output {
  elasticsearch { 
    hosts => ["localhost:9200"] 
    index => "twitter"}
}

What am I supposed to do to make the location field mapped as geo-point and be able to visualize the points on the map in Kibana 5.1.2? Thanks

解决方案

You need to create a mapping that maps location to a geo_point. The easiest way to do that is with an index template so that when you start using time based indices, it will auto-create the mapping when a new index is created.

PUT /_template/twitter
{
  "order": 0,
  "template": "twitter*",
  "mappings": {
    "_default_": {
      "properties": {
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}

Then delete your /twitter index and re-index your data.

The above template says that any index that gets created with the name twitter* will that have any _type's location field turned into a geo_point.

这篇关于如何将logstash中的位置(lon,lat)映射到kibana中可视化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆