我能夠對這樣的各種錯誤進行分類---

但我想根據錯誤訊息向群組發送電子郵件。
就像是 - -
當錯誤即“key”=“回應狀態代碼不表示成功服務不可用”時---發送電子郵件到組 1 [[email protected],[email protected],[email protected]]
當錯誤即“key”=“回應狀態代碼不指示成功網關”時---發送電子郵件到組 2 [[email protected],[email protected],[email protected]]
我做了這么多——
"actions": {
"send_email": {
"throttle_period_in_millis": 300000,
"condition": {
"script": {
"source": " def status = false; for(int i=0; i<ctx.payload.failure_request.aggregations.categories.buckets.length;i ) {if(ctx.payload.failure_request.aggregations.categories.buckets[i].key.contains('Response status code does not indicate success')) {status = true}} return status ",
"lang": "painless"
}
},
"email": {
"profile": "standard",
"to": [
"[email protected]"
],
"subject": "{{ctx.metadata.email_subject}}",
"body": {
"html": "Error Found: <ul> {{ctx.payload.aggregations.categories.buckets.length}}"
}
}
}
}
當條件通過時,即使是電子郵件也會轉到給定的電子郵件,即當密鑰包含該訊息時。但是我想一次性根據特定組的訊息匹配發送電子郵件。
如果我們有一些無痛的語言來撰寫像案例陳述這樣的邏輯,任何人都可以幫助我。
提前感謝您的幫助。
uj5u.com熱心網友回復:
以上是我的建議,希望對你有所幫助。
"actions": {
"email_group_one" : {
"condition": {
"script": {
"source": "def status = ctx.payload.failure_request.aggregations.categories.buckets; if (status.size() == 0) return false; return hosts.stream().anyMatch(p -> p.key == 'Response status code does not indicate success Service Unavailable');"
"lang": "painless"
}
},
"email" : {
"to" : ["[email protected]","[email protected]","[email protected]"],
"subject" : "YOUR SUBJEC",
"body" : {
"html": "YOUR HTML CODE"
}
}
},
"email_group_two" : {
"condition": {
"script": {
"source": "def status = ctx.payload.failure_request.aggregations.categories.buckets; if (status.size() == 0) return false; return hosts.stream().anyMatch(p -> p.key == 'Response status code does not indicate success Gateway');"
"lang": "painless"
}
},
"email" : {
"to" : ["[email protected]","[email protected]","[email protected]"],
"subject" : "YOUR SUBJECT",
"body" : {
"html": "YOUR HTML CODE"
}
}
}
}
代碼未經測驗,您可能有語法錯誤。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/490111.html
標籤:弹性搜索 弹性堆栈 弹性搜索-5 弹性搜索无痛 弹性搜索观察者
下一篇:useRef值不持久
