ELK host.ip 在 kong-* 索引模式中存在冲突的数据类型

问题描述 投票:0回答:1

我使用 ELK 版本 8.10.x 来记录 Kong API 网关日志。在 Kibana 仪表板中,我发现

host.ip
具有冲突数据类型。经过调查,我发现有一个索引调用kong-01
host.ip
字段为
text
类型,而其他索引为
ip
类型。

这种冲突会导致数据可视化时出现问题。

如何将

host.ip
字段的数据类型修改为现有索引的
ip
类型?

这是 kong-01 索引的当前映射配置:

{
  "kong-01": {
    "mappings": {
      "host.ip": {
        "full_name": "host.ip",
        "mapping": {
          "ip": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}
elasticsearch elastic-stack
1个回答
0
投票

您可以执行重新索引并删除映射错误的旧索引。步骤如下:

使用正确的映射创建新索引

PUT kong-01-new
{
  "mappings": {
    "host.ip": {
      "full_name": "host.ip",
      "mapping": {
        "ip": {
          "type": "ip"
        }
      }
    }
  }
}

运行重建索引

POST _reindex?wait_for_completion=false
{
  "conflicts": "proceed",
  "source": {
    "index": "kong-01"
  },
  "dest": {
    "index": "kong-01-new"
  }
}

删除旧索引并将旧索引别名添加到新索引

POST _aliases
{
  "actions": [
    {
      "remove_index":
      {
        "index": "kong-01"
      }
    },
    {
      "add": {
        "index": "kong-01-new",
        "alias": "kong-01"
      }
    }
  ]
}

添加图像以显示别名。

© www.soinside.com 2019 - 2024. All rights reserved.