0

如果过去 10 分钟内发生错误,我正在使用 ElastAlert 通知我的消费者。我想发送发生的错误列表。但是,如果 errorCode 中存在连字符 ('-'),则列表中的项目会一分为二

这是我想要的结果

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":{
               },
            }
         }
      }
   }
}
4

1 回答 1

1

您需要确保您的errorCode字段not_analyzed看起来并非如此,因此为什么您的错误代码会被拆分。

您可以像这样修改映射:

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

进行此更改后,您需要重新索引数据以填充该errorCode.raw字段。

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

于 2016-09-30T08:52:43.773 回答