我是Kibana的新手。
我可能在这里犯了一些基本错误。
我正在尝试每10分钟在日志文件中搜索一个字符串,并希望向此人发送电子邮件。
我试过这个来创建一个观察者:
{
"trigger": {
"schedule": {
"interval": "10m"
}
},
"input": {
"search": {
"request": {
"body": {
"size": 0,
"query": {
"match_all": {}
}
},
"indices": [
"*"
]
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gte": 10
}
}
},
"actions": {
"my-logging-action": {
"logging": {
"text": "There are {{ctx.payload.hits.total}} documents in your index. Threshold is 10."
}
}
}
}
我在这里缺少什么?
我可以把我要搜索的字符串放在哪里?假设我想搜索一个字符串这里的系统崩溃了。
答案 0 :(得分:0)
而不是match_all
运行match
query;例如,在字段message
中搜索:
"match" : {
"message" : "The system here is crashed."
}
答案 1 :(得分:0)
在您的代码中,您需要将操作类型更改为邮件。您还需要在其中使用查询和匹配。 转到 DevTools 并创建一个观察者。代码如下。
POST /_Watcher/watch/{watch id}/
{
"trigger": {
"schedule": {
"interval": "5m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"*"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"match": {
"field_name": "The system here is crashed."
}
}
}
}
} },
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 1
}
}
},
"actions": {
"email_administrator": {
"email": {
"profile": "standard",
"attachments": {
"attached_data": {
"data": {
"format": "json"
}
}
},
"priority": "high",
"to": [
"destination.mail.id@mail.com"
],
"subject": "Mail Subject",
"body":"Mail Body"
}
}
}
}