2016-09-30 72 views
0

如果過去10分鐘內發生錯誤,我正在使用ElastAlert通知我的消費者。我想發送發生的錯誤列表。但是,在列表中的項目被分成兩個,如果有連字符(「 - 」)出現在的errorCodeElastAlert拆分字段

這是結果,我想

errorCode: 
error1: 10 
error-place-2: 15 
error-new-place-3: 20 

這是結果我得到

erorrCode: 
error1: 10 
error: 35 
place: 35 
2: 15 
new: 20 
3: 20 

有沒有獲得理想結果的方法?

更新 - 索引映射的結果添加

{ 
"indexdate":{  
     "mappings":{ 
     "app_log":{ 
      "properties":{ 
     }, 
     "transaction_log":{ 
      "properties":{ 
       "@timestamp":{ 
        "type":"date", 
        "format":"strict_date_optional_time||epoch_millis" 
       }, 
       "other":{ 
       }, 
       "errorCode":{ 
        "type":"string" 
       }, 
       "other":{ 
       }, 
      } 
     } 
     } 
    } 
} 
+0

你需要確保你的'errorCode'場'not_analyzed'as它似乎並沒有這樣的情況,因此,爲什麼你的錯誤代碼被分割。 – Val

+0

我需要將'errorCode'字段設置爲'not_analyzed'嗎? – warrior107

+0

在你的映射中。它現在如何?運行'curl -XGET localhost:9200/your-index /'並將'your-index'替換爲真正的索引名稱。用你得到的結果更新你的問題。 – Val

回答

1

你需要確保你的errorCodenot_analyzed,因爲它似乎並沒有這樣的情況,因此,爲什麼你的錯誤代碼被分割。

您可以修改您的映射是這樣的:

curl -XPUT localhost:9200/indexdate/_mapping/transaction_log -d '{ 
    "properties": { 
     "errorCode":{ 
     "type":"string", 
     "fields": { 
      "raw": { 
       "type": "string", 
       "index": "not_analyzed" 
      } 
     } 
     } 
    } 
}' 

進行此更改後,需要重新索引,以填充errorCode.raw場數據。

然後,你需要在你的ElastAlert配置使用errorCode.raw而不是errorCode

+0

非常感謝。將嘗試一下,檢查它是否有效。 – warrior107

+0

很酷,這是否工作? – Val

+0

是的,這工作。 – warrior107