如何将logstash中的位置(lon,lat)映射到kibana中可视化? [英] How to map location (lon, lat) in logstash to visualize in 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然后删除你的
上面的模板表示任何使用名称<$ 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
The above template says that any index that gets created with the name
twitter*
will that have any_type
'slocation
field turned into ageo_point
.这篇关于如何将logstash中的位置(lon,lat)映射到kibana中可视化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!