Mapelasticsearch apache模块字段

eanckbw9  于 2021-06-14  发布在  ElasticSearch
关注(0)|答案(1)|浏览(400)

我是es的新手,我正面临着一个我正在努力解决的小问题。
我将metricbeat apache模块与es集成在一起,它运行良好。
问题是metricbeat apache module报告apache的web流量(字段apache.status.total\u kbytes),而我想创建自己的字段,其名称是“apache.status.total\u mbytes”。
我正在尝试通过dev console使用以下api命令创建新Map:

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

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

仍然返回以下错误:

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

我错过了什么?\uMap命令是否错误?
提前谢谢,

hjzp0vay

hjzp0vay1#

一个有效的例子:
创建新索引

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

现在,如果要向现有Map添加新字段,请按以下方式使用api:
更新现有索引

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

那么 GET metricbeat-7.2.0/_mapping 将向您显示更新的Map:

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

另外,看一下putMapapi

相关问题