映射 ElasticSearch apache 模块字段

Mapping ElasticSearch apache module field

我是 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"
          }
        }
      }
    }
}

还是ESreturns下面的错误:

{
  "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

Returns

{
  "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命令有误?

提前致谢,

一个工作示例:

创建新索引

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