簡體   English   中英

Flume / Elasticsearch創建新索引,並忽略顯式創建的索引

[英]Flume / Elasticsearch creating a new index and ignoring the index explicitly created

我們在Elasticsearch中創建了一個索引,如下所示,索引名稱是apachelog,動態映射設置為“ strict”,我們將httpresponse字段設置為integer類型:

curl -X PUT 'http://localhost:9200/**apachelog**' -d \
'{
  "log": {
<b>"dynamic": "strict"</b>,
    "properties": {
      "@fields": {
        "properties": {
          "agent": {"type": "string"},
          "city": {"type": "string"},
          "client_ip": {"type": "string"},
          "hitTime": {"type": "string"},
          "host": {"type": "string"},
          <b>"httpresponse": {"type": "integer"}</b>
        }
      },
      "@message": {"type": "string"},
      "@source_host": {"type": "string"},
      "@timestamp": {"type": "date", "format": "dateOptionalTime"}
    }
  }
}'

我們的水槽ElasticSearch接收器配置如下,請注意索引名稱與apachelog相同,已經在ES中創建了索引:

寫入ElasticSearch

collector.sinks.elasticsearch.type =          org.apache.flume.sink.elasticsearch.ElasticSearchSink
collector.sinks.elasticsearch.channel = mc2
collector.sinks.elasticsearch.batchSize=100
collector.sinks.elasticsearch.hostNames = localhost:9300
collector.sinks.elasticsearch.indexName = apachelog
collector.sinks.elasticsearch.clusterName = logsearch
collector.sinks.elasticsearch.serializer =    org.apache.flume.sink.elasticsearch.ElasticSearchLogStashEventSerializer

現在,當我們啟動並運行水槽代理時,我們注意到在ElasticSearch中創建了一個名稱為apachelog-2015-09-09的新索引,字段httpresponse的數據類型為string 我們注意到Flume / ES正在將文檔添加到新創建的索引中,而我們使用名稱apachelog顯式創建的索引處於休眠狀態。

知道為什么會發生這種情況以及如何讓Flume / ES使用索引而不是創建索引嗎?

Flume Elasticsearch Sink的行為符合其默認行為。 它正在根據UTC時間戳寫入索引名稱。 這就是Kibana工具將要尋找的東西。

您可以將索引名稱格式更改為例如寫入每月索引,而不是每天。 我不記得我們是否離開時沒有時間因素。

我建議您可能不希望所有事件都有一個索引。 當ES變得龐大時,ES將開始出現問題,您將無能為力以更改復制或分片因素。 這就是GrayLog擁有單個索引時的經驗。

由於您似乎想要配置字段類型,因此建議您研究一下索引模板,並為apachelog *添加一個可以滿足您需求的模板。 然后刪除舊索引,並讓ES在該模板之后創建索引。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM