我已经在Stack Management〉Rules中创建了一个规则(Elasticsearch查询)
选择索引和时间字段
INDEX operations*
使用Query DSL定义查询
{
"query": {
"regexp": {
"o": "user-input"
}
}
}
设置阈值和时间窗
IS ABOVE 64
FOR THE LAST 15 minutes
设置要发送的文档数
SIZE 0
测试查询交付...
最近15m内查询匹配30个文档。
我的连接器是一个自定义的Web服务,用于向Telegram发送消息。
这些是我的模板。
模板:查询匹配时
name: {{rule.name}}
status: CRITICAL
date: {{context.date}}
link: {{context.link}}
hits: {{context.hits}}
Template:When recovered
name: {{rule.name}}
status: OK
date: {{context.date}}
link: {{context.link}}
hits: {{context.hits}}
我在Telegram上看到的结果
name: user-input
status: OK
date: 2023-02-21T08:52:02.958Z
link: https://my-elasticsearch:9243/app/management/insightsAndAlerting/triggersActions/rule/**************
hits:
手工弹出查询,没有日期范围,我明白了
{
"took": 96,
"timed_out": false,
"_shards": {
"total": 215,
"successful": 215,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 10000,
"relation": "gte"
},
"max_score": null,
"hits": []
}
}
因为我的尺寸是0,所以我没有真实的的命中率,但我有命中率的总量。
我一直在阅读这篇文章,但没有成功。
什么是正确的方式来获得点击总数,并显示到我的模板?
1条答案
按热度按时间sz81bmfz1#
解决方案是 {{context.value}}