點選Stack Management,再進入Watcher 然後按Create選Create advanced watch
{
"trigger": {
"schedule": { #設定排程間格1分
"interval": "1m"
}
},
"input": {
"search": {
"request": {
"body": {
"size": 10,
"query": { #設定DSL查詢語法
"match": {
"level": {
"query": "INFO"
}
}
}
},
"indices": [
"30day-*"
]
}
}
},
"condition": { #設定條件
"compare": {
"ctx.payload.hits.total": {
"gte": 1 #DSL查詢命中大於等於1時
}
}
},
"actions": { #設定達到條件後要執行的動作(這邊設定寫入watcherlog index)
"index_1": {
"index": {
"index": "watcherlog"
}
}
}
}
然後按Create watch就完成了
確認狀態是OK或是Firing就代表設定成功