Elasticsearch

使用欄位類型映射整數創建的 Elasticsearch 索引,在 Kibana 4 中被辨識為“字元串”

  • October 15, 2015

我在 elasticsearch 1.7 中創建了一個索引,如下所示:

   curl -XPUT 'http://localhost:9200/test' -d '
{
   "test" : {
       "properties" : {
           "user" : {"type" : "string", "index" : "not_analyzed"},
           "message" : {"type" : "string", "null_value" : "na"},
           "syslogtimestamp" : {"type" : "date"},
           "transact" : {"type" : "integer"},
           "subscriber" : {"type" : "integer"},
           "pid" : {"type" : "integer"},
           "acquirertime" : {"type" : "float"}
       }
   }
}
'

我正在使用來自 logstash 的數據填充它,如下所示:

filter {
 if [type] == "test" {
   grok {
     match => { "message" => "%{TEST}" }
   }
geoip {
     source => "clientip"
     target => "geoip"
     database => "/etc/logstash/GeoLiteCity.dat"
     add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
     add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}"  ]
   }
   mutate {
     convert => [ "[geoip][coordinates]", "float"]
   }

}
}

Pattern:
TEST %{MONTH:month} (?:(\s+|)) %{INT:day} %{TIME:time} (?<hostname>[a-z0-9_-]+) (?<application>[a-zA-Z0-9-_]+\.(cgi|pml|pfml)):(?:\s+)\[(?:(\s+|))%{INT:pid}\] %{IPORHOST:clientip} (?:\s+\()(?<acquirer>[a-zA-Z0-9_-]+)(?:(\s|))\) (?<event>[a-zA-Z0-9]+)(?:\s+)id=%{INT:transact}(?:\s+)sub=%{INT:subscriber}

所以我試圖將elasticsearch中映射的欄位“transact”作為整數。但是,當我在 Kibana 4 中查找欄位時,我的所有欄位都是“字元串”類型。怎麼會這樣?

您應該在此處查看 ES 索引模板:https ://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

您可以讓 logstash 傳遞它們,也可以通過 curl 或 config 直接將它們提供給 elasticsearch。

引用自:https://serverfault.com/questions/720415