2016-09-30 83 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