【问题标题】:Elastic Search GeoIp location not of type geo_point弹性搜索 GeoIp 位置不是 geo_point 类型
【发布时间】:2017-11-03 13:02:49
【问题描述】:

我正在使用基于解决方案的 Docker Compose 运行 ElasticSearch、Logstash 和 Kibana:https://github.com/deviantony/docker-elk

我正在按照本教程尝试在处理我的网络日志时添加 geoip 信息:https://www.elastic.co/blog/geoip-in-the-elastic-stack

在 logstash 中,我正在处理来自 FileBeat 的文件,并且我已将 geoip 添加到我的过滤器中:

filter {
    ...

    geoip {
      source => "client_ip"
    }
}

当我在 Kibana 中查看文档时,它们确实包含其他信息,例如 geoip.country_namegeoip.city_name 等,但我希望我的索引中的 geoip.location 字段类型为 geo_point

以下是一些 geoip 字段如何映射的示例:

我看到的是location.latlocation.lon,而不是geo_point。为什么我的位置不是geo_point 类型?我需要某种映射等吗?

ingest-commoningest-geoipingest-user-agentx-pack 在 ElasticSearch 启动时加载。我在 Kibana 中刷新了我的索引的字段列表。

EDIT1:

根据@Val 的回答,我正在尝试更改索引的映射:

PUT iis-log-*/_mapping/log
{
  "properties": {
    "geoip": {
      "dynamic": true,
      "properties": {
        "ip": {
          "type": "ip"
        },
        "location": {
          "type": "geo_point"
        },
        "latitude": {
          "type": "half_float"
        },
        "longitude": {
          "type": "half_float"
        }
      }
    }
  }
}

但这给了我这个错误:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "mapper [geoip.ip] of different type, current_type [text], merged_type [ip]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "mapper [geoip.ip] of different type, current_type [text], merged_type [ip]"
  },
  "status": 400
}

【问题讨论】:

    标签: elasticsearch logstash geoip


    【解决方案1】:

    在您提到的article 中,他们确实解释说您需要在“映射,用于地图”部分中为geo_point 字段放置一个特定的映射。

    如果您使用默认索引名称(即logstash-*)和默认映射类型(即log),则由Logstash 为您处理映射。但如果没有,您需要自己安装:

    PUT your_index
    {
      "mappings" : {
        "_default_" : {
          "_all" : {"enabled" : true, "norms" : false},
          "dynamic_templates" : [ {
            "message_field" : {
              "path_match" : "message",
              "match_mapping_type" : "string",
              "mapping" : {
                "type" : "text",
                "norms" : false
              }
            }
          }, {
            "string_fields" : {
              "match" : "*",
              "match_mapping_type" : "string",
              "mapping" : {
                "type" : "text", "norms" : false,
                "fields" : {
                  "keyword" : { "type": "keyword", "ignore_above": 256 }
                }
              }
            }
          } ],
          "properties" : {
            "@timestamp": { "type": "date", "include_in_all": false },
            "@version": { "type": "keyword", "include_in_all": false },
            "geoip"  : {
              "dynamic": true,
              "properties" : {
                "ip": { "type": "ip" },
                "location" : { "type" : "geo_point" },
                "latitude" : { "type" : "half_float" },
                "longitude" : { "type" : "half_float" }
              }
            }
          }
        }
      }
    }
    

    在上述映射中,您会看到 geoip.location 字段被视为 geo_point

    【讨论】:

    • 感谢您的回答。我正在尝试更改映射,但出现错误,请参阅我更新的问题 (edit1)。
    • 是的,您需要删除索引并重新开始。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-08
    • 1970-01-01
    • 1970-01-01
    • 2016-01-12
    • 1970-01-01
    • 1970-01-01
    • 2016-08-06
    相关资源
    最近更新 更多