ElastAlert 拆分字段

ElastAlert splits the field

如果过去 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":{
               },
            }
         }
      }
   }
}

您需要确保您的 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 字段。

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