簡體   English   中英

來自Logstash的ElasticSearch中的動態索引

[英]Dynamic Index in ElasticSearch from Logstash

我在logstash中進行以下配置,從而可以根據收到的輸入JSON將動態“ document_type”創建到ES:

 elasticsearch {
                hosts => ["localhost:9200"]
                index => "queuelogs"
                document_type => "%{action}"
            }

在這里,“ action ”是我在JSON中收到的參數,並且根據收到的不同操作創建了不同的document_type。

現在,我希望對索引創建執行相同的操作,例如:

elasticsearch {
            hosts => ["localhost:9200"]
            index => "%{logtype}"
            document_type => "%{action}"
        }

在這里,“ logtype ”是我在JSON中收到的參數。

但是以某種方式在ES中,它僅將索引創建為“%{logtype}”,而不是根據實際logtype值創建索引。

輸入的JSON如下所示:

{
  "action": "UPLOAD",
  "user": "123",
  "timestamp": "2016 Jun 14 12:00:12",
  "data": {
    "file_id": "2345",
    "file_name": "xyz.pdf"
  },
  "header": {
    "proj_id": "P123",
    "logtype": "httplogs"
  },
  "comments": "Check comments"
}

在這里,我嘗試通過以下方式生成索引:

  • index =>“%{logtype}”

  • 索引=>“%{header.logtype}”

但是在兩種情況下,Logstash都不會替換JSON中的logtype的實際值。

您需要像這樣指定它:

elasticsearch {
        hosts => ["localhost:9200"]
        index => "%{[header][logtype]}"
        document_type => "%{action}"
    }

暫無
暫無

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

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