{"componentChunkName":"component---src-templates-best-practice-detail-tsx","path":"/best-practice/2021-12-16-eb","result":{"data":{"currentBlog":{"id":"44398282-4e90-598e-b188-5e5dc9ed194b","frontmatter":{"thumbnail":"https://qcloudimg.tencent-cloud.cn/raw/6d6bcba1df7d10f01db0674358f0267d.jpg","authors":["杜佳辰"],"categories":["best-practice"],"date":"2021-12-16T00:00:00.000Z","title":"EventBridge 最佳实践场景二：使用 EventBridge + SCF 实现服务器异常的自动回滚","description":"本文以服务器异常为例为您介绍自动化运维架构快速搭建的方法。","authorslink":null,"translators":null,"translatorslink":null,"tags":["Serverless","云函数"],"keywords":null,"outdated":null},"wordCount":{"words":126,"sentences":26,"paragraphs":26},"fileAbsolutePath":"/opt/build/repo/content/best-practice/2021-12-16-eb.md","fields":{"slug":"/best-practice/2021-12-16-eb/","keywords":["serverless","无服务器","云函数","推送","告警","事件","tencent","docs","qq"]},"html":"<h2 id=\"01-背景介绍\"><a href=\"#01-%E8%83%8C%E6%99%AF%E4%BB%8B%E7%BB%8D\" aria-label=\"01 背景介绍 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>01. 背景介绍</h2>\n<p>对于企业的生产环境而言，监控与报警不可或缺的，完善的监控与及时的报警和自动化处理，可以帮助企业快速定位并解决问题，从而减少经济损失。</p>\n<p>腾讯云事件总线（EventBridge）是一款安全、稳定、高效的无服务器事件管理平台。事件中心的事件总线可以接收来自您自己的应用程序、软件即服务（SaaS）和腾讯云服务的实时事件及相关数据流，通过集成消息推送和 SCF 云函数，实现告警信息的实时通知和自动化处理。</p>\n<p>本文以服务器异常为例，为您介绍当云服务器产生告警事件后，如何基于 EventBridge 事件总线和 SCF 云函数，实现告警消息的实时推送和硬盘快照的自动回滚，完成自动化运维架构的快速搭建。</p>\n<h2 id=\"02-架构设计\"><a href=\"#02-%E6%9E%B6%E6%9E%84%E8%AE%BE%E8%AE%A1\" aria-label=\"02 架构设计 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>02. 架构设计</h2>\n<p>整体架构设计如图，从图上可以看出，当云服务器某台机器出现异常告警， CVM 会自动产生告警事件并主动推送给 EB，经过 EB 绑定的告警规则筛选后，完成到通知渠道的消息触达及时通知到用户，同时触发云函数，以调用 API 的方式完成硬盘快照的快速回滚，保证业务及时恢复。</p>\n<p><img src=\"https://docimg4.docs.qq.com/image/RFCd9jj-Em7vt3e5SIOtwA.png?w=1280&#x26;h=526.9541029207231\"></p>\n<h2 id=\"03-基本步骤\"><a href=\"#03-%E5%9F%BA%E6%9C%AC%E6%AD%A5%E9%AA%A4\" aria-label=\"03 基本步骤 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>03. 基本步骤</h2>\n<ol>\n<li>登录<a href=\"https://console.cloud.tencent.com/scf/list\">云函数控制台</a>新建云函数，通过调用 API 的方式，完成服务器故障后自动处理流程的函数代码编写</li>\n</ol>\n<p>云服务器关机接口：<a href=\"https://cloud.tencent.com/document/product/213/15743\">https://cloud.tencent.com/document/product/213/15743</a></p>\n<p>快照回滚接口：<a href=\"https://cloud.tencent.com/document/product/362/15643\">https://cloud.tencent.com/document/product/362/15643</a></p>\n<ol start=\"2\">\n<li>登录 <a href=\"https://console.cloud.tencent.com/eb\">EventBridge 控制台</a>，配置告警规则</li>\n</ol>\n<p><img src=\"https://docimg4.docs.qq.com/image/ywr6eYkK3QKT9DQhU74MCA.png?w=1280&#x26;h=388.3835616438356\"></p>\n<ol start=\"3\">\n<li>以「云服务器运行异常」事件告警配置为例，您可以选择指定的事件告警类型，也可以选择全部告警事件，详细事件匹配规则请参见 <a href=\"https://cloud.tencent.com/document/product/1359/56084\">管理事件规则</a></li>\n</ol>\n<p><img src=\"https://docimg1.docs.qq.com/image/ZyAavgyBsB5VAG3Q0aDPkA.png?w=1280&#x26;h=767.2976680384087\"></p>\n<ol start=\"4\">\n<li>配置推送目标</li>\n</ol>\n<p>为了满足自动化处理和消息推送两部分能力，对于上述规则，我们需要同时配置消息推送和云函数两个投递目标</p>\n<ul>\n<li>消息推送：通过配置消息推送，将您的告警事件推送至指定的消息接收渠道，完成用户及时触达。</li>\n</ul>\n<p><img src=\"https://docimg9.docs.qq.com/image/yg7MTSTIlNUMg-Em4hI1Rw.png?w=1202&#x26;h=556\"></p>\n<ul>\n<li>云函数投递：触发方式选择「云函数（SCF）」--「已有函数」，选择刚刚已部署好的云函数进行绑定</li>\n</ul>\n<p><img src=\"https://docimg6.docs.qq.com/image/ECG6Be4HFGdXqRHVQquWGA.png?w=1216&#x26;h=894\"></p>\n<ol start=\"5\">\n<li>告警链路测试</li>\n</ol>\n<p>配置完成后，回到事件集控制台，选择刚刚已绑定的事件集，单击发送事件，可以选择已绑定的事件规则模版，单击发送进行测试，如果同时收到了推送消息并自动进行回滚，即可确认您的业务故障自动化运维架构已完成搭建。</p>\n<p>注：测试模版里只展示 data 字段里的内容，其它字段已固定，无法自定义修改。</p>\n<p><img src=\"https://docimg5.docs.qq.com/image/a63b9-GJAMZtmv6gkPLi5Q.png?w=1280&#x26;h=405.8124174372523\"></p>\n<p><img src=\"https://docimg10.docs.qq.com/image/7f4u4wAot7j0-0zLge3-4A.png?w=1280&#x26;h=694.4329896907217\"></p>\n<p>识别下方 👇 二维码，进入「事件总线」交流群</p>\n<img src=\"https://qcloudimg.tencent-cloud.cn/raw/dd4f0a2cc7a171efe8d89aae9b55a600.png\" width=\"200\">\n<hr>\n<blockquote>\n<p><strong>传送门：</strong></p>\n<ul>\n<li>GitHub: <a href=\"https://github.com/serverless/serverless/blob/master/README_CN.md\">github.com/serverless</a></li>\n<li>官网：<a href=\"https://serverless.com/\">serverless.com</a></li>\n</ul>\n</blockquote>\n<p>欢迎访问：<a href=\"https://serverlesscloud.cn/\">Serverless 中文网</a>，您可以在 <a href=\"https://serverlesscloud.cn/best-practice\">最佳实践</a> 里体验更多关于 Serverless 应用的开发！</p>","tableOfContents":"<ul>\n<li><a href=\"/best-practice/2021-12-16-eb/#01-%E8%83%8C%E6%99%AF%E4%BB%8B%E7%BB%8D\">01. 背景介绍</a></li>\n<li><a href=\"/best-practice/2021-12-16-eb/#02-%E6%9E%B6%E6%9E%84%E8%AE%BE%E8%AE%A1\">02. 架构设计</a></li>\n<li><a href=\"/best-practice/2021-12-16-eb/#03-%E5%9F%BA%E6%9C%AC%E6%AD%A5%E9%AA%A4\">03. 基本步骤</a></li>\n</ul>"},"previousBlog":{"id":"784c0655-b24f-5194-bbc4-0dd510124c66","frontmatter":{"thumbnail":"https://qcloudimg.tencent-cloud.cn/raw/17096bffe9b2863930506427e0e4b35a.jpg","authors":["杜佳辰"],"categories":["best-practice"],"date":"2021-12-20T00:00:00.000Z","title":"EventBridge 最佳实践场景三：基于 EventBridge 设计零售业务中台","description":"本文以零售中台为例介绍如何通过 EventBridge 搭建业务中台的基础能力","authorslink":null,"translators":null,"translatorslink":null,"tags":["Serverless","云函数"],"keywords":null,"outdated":null},"wordCount":{"words":208,"sentences":30,"paragraphs":30},"fileAbsolutePath":"/opt/build/repo/content/best-practice/2021-12-20-eb.md","fields":{"slug":"/best-practice/2021-12-20-eb/","keywords":["serverless","无服务器","云函数","事件","投递","中台","EventBridge","业务","处理","自定义","完成"]}},"nextBlog":{"id":"36570569-7eef-52ad-a4ec-98de550dbd95","frontmatter":{"thumbnail":"https://qcloudimg.tencent-cloud.cn/raw/7e24e227c79d7f4fb2551093b1b9c40a.jpg","authors":["杜佳辰"],"categories":["best-practice"],"date":"2021-12-15T00:00:00.000Z","title":"EventBridge 最佳实践场景一：Oceanus 告警消息实时推送","description":"本文演示了如何捕获 Oceanus 集群状态变更，并发送到企业微信或钉钉、飞书客户端。","authorslink":null,"translators":null,"translatorslink":null,"tags":["Serverless","云函数"],"keywords":null,"outdated":null},"wordCount":{"words":142,"sentences":25,"paragraphs":25},"fileAbsolutePath":"/opt/build/repo/content/best-practice/2021-12-15-eb.md","fields":{"slug":"/best-practice/2021-12-15-eb/","keywords":["serverless","无服务器","云函数","推送","事件","告警","qq","docs","Oceanus","image"]}}},"pageContext":{"isCreatedByStatefulCreatePages":false,"blogId":"44398282-4e90-598e-b188-5e5dc9ed194b","previousBlogId":"784c0655-b24f-5194-bbc4-0dd510124c66","nextBlogId":"36570569-7eef-52ad-a4ec-98de550dbd95"}}}