elasticsearch - 如何使用elasticsearch在logstash中映射geoip字段,以便在Kibana4的平铺 map 中显示它

标签 elasticsearch logstash kibana

我想在Kibana4的瓷砖 map 中显示geoip字段。
使用标准/自动logstash geoip映射进行elasticsearch,一切正常。

但是,当创建一个非标准的geoip字段时,我不太确定如何在logstash中自定义elasticsearch-template.json以便在elasticsearch中正确表示此字段,以便可以在Kibana4中选择该字段以用于 slice map 创建。

当然,自定义标准模板不是最好的方法-更好地创建一个自定义模板,并在logstash.conf的elasticsearch输出中指向它。我只是想快速检查一下如何定义映射,因此我修改了标准模板。

我的logstash.conf:

input {
    tcp {
        port => 514
        type => syslog
    }
    udp {
        port => 514
        type => syslog
    }
}

filter {
    # Standard geoip field is automatically mapped by logstash to 
    # elastic search by using the elasticsearch-template.json file
    geoip { source => "host" }

    grok {
        match => [ 
            "message", "<%{POSINT:syslog_pri}>%{YEAR} %{SYSLOGTIMESTAMP:syslog_timestamp} %{DATA:device} <%{POSINT:status}> %{WORD:activity} %{DATA:inout} \(%{DATA:msg}\) Src:%{IPV4:src} SPort:%{INT:sport} Dst:%{IPV4:dst} DPort:%{INT:dport} IPP:%{INT:ipp} Rule:%{INT:rule} Interface:%{WORD:iface}",
            "message", "<%{POSINT:syslog_pri}>%{YEAR} %{SYSLOGTIMESTAMP:syslog_timestamp} %{DATA:device} <%{POSINT:status}> %{WORD:activity} %{DATA:inout} \(%{DATA:msg}\) Src:%{IPV4:src} Dst:%{IPV4:dst} IPP:%{INT:ipp} Rule:%{INT:rule} Interface:%{WORD:iface}",                    
            "message", "<%{POSINT:syslog_pri}>%{YEAR} %{SYSLOGTIMESTAMP:syslog_timestamp} %{DATA:device} <%{POSINT:status}> %{WORD:activity} %{DATA:inout} \(%{DATA:msg}\) Src:%{IPV4:src} Dst:%{IPV4:dst} Type:%{POSINT:type} Code:%{INT:code} IPP:%{INT:ipp} Rule:%{INT:rule} Interface:%{WORD:iface}"
        ]
    }
    # Is not mapped automatically by logstash in that it can be 
    # chosen in Kibana4 for tile map creation
    geoip {
        source => "src"
        target => "src_geoip"
    }   
}

output {
    elasticsearch {
        host => "localhost"
        protocol => "http"
    }
}

我的... logstash-1.4.2 \ lib \ logstash \ outputs \ elasticsearch \ elasticsearch-template.json:
    {
  "template" : "logstash-*",
  "settings" : {
    "index.refresh_interval" : "5s"
  },
  "mappings" : {
    "_default_" : {
       "_all" : {"enabled" : true},
       "dynamic_templates" : [ {
         "string_fields" : {
           "match" : "*",
           "match_mapping_type" : "string",
           "mapping" : {
             "type" : "string", "index" : "analyzed", "omit_norms" : true,
               "fields" : {
                 "raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
               }
           }
         }
       } ],
       "properties" : {
         "@version": { "type": "string", "index": "not_analyzed" },
         "geoip"  : {
           "type" : "object",
             "dynamic": true,
             "path": "full",
             "properties" : {
               "location" : { "type" : "geo_point" }
             }
         },
         "src_geoip"  : {
           "type" : "object",
             "dynamic": true,
             "path": "full",
             "properties" : {
               "location" : { "type" : "geo_point" }
             }
         }
       }
    }
  }
}

更新:我还没有弄清楚何时将此json文件应用于elasticsearch。我按照this question中列出的提示进行操作,并将json文件复制到elasticsearch目录中的config / templates文件夹中。删除indizes并重新启动elasticsearch之后,模板已成功应用。

无论如何,字段“src_geoip.location”仍然不会在Kibana4的 slice map 创建表单中显示(仅标准geoip.location字段会显示)。

最佳答案

编辑模板后尝试覆盖模板。更改配置后,在Kibana中重新创建索引。

output {
   elasticsearch {
       template_overwrite => "true"
        ...
   }
}

关于elasticsearch - 如何使用elasticsearch在logstash中映射geoip字段,以便在Kibana4的平铺 map 中显示它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29237194/

相关文章:

elasticsearch - bool 查询在Elasticsearch中不返回预期数据

elasticsearch - Elasticsearch Nest获取和更新单个文档

elasticsearch - Elasticsearch 索引经常被删除

elasticsearch - 我应该在ElasticSearch集群中设置多少个机架

elasticsearch - 从整数字段创建图表

azure - 将 Azure 应用服务日志连接到 ELK

ruby - 将 Logstash 中的时间戳时区转换为输出索引名称

javascript - Elasticsearch 5.3 - 找不到geo_point字段

elasticsearch - Kibana饼图

elasticsearch - 如何使用FileBeat将管道分隔格式的日志数据以JSON格式发送到Elasticsearch?