【问题标题】:Mapping ElasticSearch apache module field映射 ElasticSearch apache 模块字段
【发布时间】:2021-01-27 17:49:26
【问题描述】:

我是 ES 新手,我遇到了一个我正在努力解决的小问题。

我将 metricbeat apache 模块与 ES 集成,它工作正常。

问题是metricbeat apache模块报告了apache的网络流量KB(字段apache.status.total_kbytes),而不是我想创建自己的字段,名称为“apache.status.total_mbytes” .

我正在尝试使用以下 api 命令通过开发控制台创建新映射:

PUT /metricbeat-7.2.0/_mapping
{
  "settings":{

  },
      "mappings" : {
      "apache.status.total_mbytes" : {
        "full_name" : "apache.status.total_mbytes",
        "mapping" : {
          "total_mbytes" : {
            "type" : "long"
          }
        }
      }
    }
}

Still ES 返回如下错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "Root mapping definition has unsupported parameters:  [settings : {}] [mappings : {apache.status.total_mbytes={mapping={total_mbytes={type=long}}, full_name=apache.status.total_mbytes}}]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Root mapping definition has unsupported parameters:  [settings : {}] [mappings : {apache.status.total_mbytes={mapping={total_mbytes={type=long}}, full_name=apache.status.total_mbytes}}]"
  },
  "status" : 400
}

仅供参考

以下内容可能会有所启发

GET /metricbeat-*/_mapping/field/apache.status.total_kbytes

返回

{
  "metricbeat-7.9.2-2020.10.06-000001" : {
    "mappings" : {
      "apache.status.total_kbytes" : {
        "full_name" : "apache.status.total_kbytes",
        "mapping" : {
          "total_kbytes" : {
            "type" : "long"
          }
        }
      }
    }
  },
  "metricbeat-7.2.0-2020.10.05-000001" : {
    "mappings" : {
      "apache.status.total_kbytes" : {
        "full_name" : "apache.status.total_kbytes",
        "mapping" : {
          "total_kbytes" : {
            "type" : "long"
          }
        }
      }
    }
  }
}

我错过了什么? _mapping 命令错了吗?

提前致谢,

【问题讨论】:

    标签: apache elasticsearch elk metricbeat


    【解决方案1】:

    一个工作示例:

    创建新索引

    PUT /metricbeat-7.2.0
    {
      "settings": {},
      "mappings": {
        "properties": {
          "apache.status.total_kbytes": {
              "type": "long"
            }
        }
      }
    }
    

    然后GET metricbeat-7.2.0/_mapping/field/apache.status.total_kbytes 将导致(与您的示例相同):

    {
      "metricbeat-7.2.0" : {
        "mappings" : {
          "apache.status.total_kbytes" : {
            "full_name" : "apache.status.total_kbytes",
            "mapping" : {
              "total_kbytes" : {
                "type" : "long"
              }
            }
          }
        }
      }
    }
    

    现在,如果您想将新字段添加到现有映射,请按以下方式使用 API:

    更新现有索引

    PUT /metricbeat-7.2.0/_mapping
    {
      "properties": {
        "total_mbytes": {
          "type": "long"
        }
      }
    }
    

    然后GET metricbeat-7.2.0/_mapping 将显示更新的映射:

    {
     "metricbeat-7.2.0" : {
        "mappings" : {
          "properties" : {
            "apache" : {
              "properties" : {
                "status" : {
                  "properties" : {
                    "total_kbytes" : {
                      "type" : "long"
                    }
                  }
                }
              }
            },
            "total_mbytes" : {
              "type" : "long"
            }
          }
        }
      }
    }
    

    另外,看看Put Mapping Api

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-31
      • 2017-10-13
      • 2017-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多