网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
sentinl文档地址:http://sentinl.readthedocs.io/en/latest/
使用步骤
1.在kibana界面上配置sentinl,点击右上角new创建watchers
2.点击 +watcher创建新的Watcher
3.填写General页面内容, title是watcher的名称,Schedule是执行周期。
4.填写input页面内容, body 里面填写ES查询语句,可根据具体业务编写相应的查询语句
5.填写Condition页面内容, payload.hits.total > 1 (当查询结果数大于1时,触发Actions),可以自己制定条件。
6.Transform 可对input查询的结果做一些处理,此处没有使用,可以不填写
7.填写Actions页面内容,Actions包括webhook,email,email html,report,slack,console,此处介绍webhook。
7.1 使用webhook发rest请求,可以选择 get或post两种方式。
7.1.1 填好对应数据之后,点击右上角的Save按钮。
7.1.2 可以点击单次执行按钮进行测试。如下显示接收到参数,测试成功
7.2 使用webhook执行新的watchers(仅执行一次),在新的watchers中发rest请求。
path: /api/sentinl/watcher/_execute(固定值)
body的内容如下:
{
"\_source": {
"actions": {
"testRest": {
"throttle\_period": "0h0m10s",
"webhook": {
"method": "POST",
"host": "10.16.232.66",
,
"proxy": false,
"path": "/kyle",
"body": "{\n \"id\":100,\n \"name\":\"kyle20\"\n}"
}
}
},
"input": {
"search": {
"request": {
"index": [
"movies"
],
"body": {
"query": {
"match\_all": {}
}
}
}
}
},
"condition": {
"script": {
"script": "payload.hits.total > 1"
}
},
"transform": {},
"trigger": {
"schedule": {
"later": "every 5 minutes"
}
},
"disable": true,
"report": false,
"title": "watcher\_title"
}
}
测试结果:
7.3 使用sentinl 执行多个watcher方案
原理:将第一个watcher的结果写入es index 中,以供其他watcher使用(可以作为触发其他watcher方式)
7.3.1 新建第一个watcher,内容如下:
{
"actions": {
"New console action txv1ad1yazr": {
"throttle\_period": "0h0m1s",
"console": {
"message": "{\n{{#payload.hits.hits}}\n\"name\":\"{{\_source.name}}\",\n\"age\":{{\_source.age}}\n{{/payload.hits.hits}}\n}"
}
},
"New webhook action 20wm9sojv9j": {
"throttle\_period": "0h0m1s",
"webhook": {
"method": "POST",
"host": "10.16.232.163",
,
"proxy": false,
"path": "/twoindex/doc",
"body": "{\n{{#payload.hits.hits}}\n\"name\":\"{{\_source.name}}\",\n\"age\":{{\_source.age}}\n{{/payload.hits.hits}}\n}",
"save\_payload": false,
"headers": {
"content-type": "application/json"
}
}
}
},
"input": {
"search": {
"request": {
"index": [
"trumantest"
],
"body": {
"query": {
"match": {
"
}
}
}
}
}
},
"condition": {
"script": {
"script": "payload.hits.total > 0"
}
},
"transform": {},
"trigger": {
![img](https://img-blog.csdnimg.cn/img_convert/9b333aa32a5a0c2340768e2ddcb81b1d.png)
![img](https://img-blog.csdnimg.cn/img_convert/5006e14d46f33026202945efc952aa9e.png)
![img](https://img-blog.csdnimg.cn/img_convert/c3c3178756f71e9ef7c9721234f765cd.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上软件测试知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[需要这份系统化的资料的朋友,可以戳这里获取](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[需要这份系统化的资料的朋友,可以戳这里获取](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**