{"id":43682,"date":"2023-06-02T11:02:46","date_gmt":"2023-02-27T03:11:08","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/"},"modified":"2024-04-30T07:00:10","modified_gmt":"2024-04-29T23:00:10","slug":"%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/","title":{"rendered":"\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406"},"content":{"rendered":"<h1>\u9996\u5148<\/h1>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u662f\u5bcc\u58eb\u901a\u4e91\u6280\u672f\u76842023\u5e74\u5723\u8bde\u8282\u65e5\u5386\u7684\u7b2c11\u5929\u6587\u7ae0\uff0c\u4ecb\u7ecd\u4e86\u63d0\u4f9b\u4e86Nifcloud\u7b49\u670d\u52a1\u7684\u5bcc\u58eb\u901a\u4e91\u6280\u672f\u3002<br \/>\n(\u8fd9\u7bc7\u6587\u7ae0\u662f\u5bcc\u58eb\u901a\u4e91\u6280\u672f2023\u5e74\u5723\u8bde\u65e5\u5386\u7684\u7b2c11\u5929\u6587\u7ae0\uff0c\u4ecb\u7ecd\u4e86\u63d0\u4f9bNifcloud\u7b49\u670d\u52a1\u7684\u5bcc\u58eb\u901a\u4e91\u6280\u672f\u3002)<\/p>\n<p>\u6628\u5929\u6211\u4f7f\u7528 @ktakaaki \u5148\u751f\u7684 SwitchBot \u7684 BLE \u529f\u80fd\u6765\u83b7\u53d6\u6570\u636e\u3002<br \/>\n\u201cHome Dashboard\u201d \u8fd9\u4e2a\u8bcd\u6211\u4e4b\u524d\u4ece\u672a\u542c\u8bf4\u8fc7\uff0c\u771f\u662f\u4ee4\u6211\u60ca\u8bb6\u3002\u867d\u7136\u6211\u5bb6\u4e5f\u6709 Switch Bot \u7684\u4ea7\u54c1\uff0c\u4f46\u662f\u6211\u5374\u4e00\u76f4\u6ca1\u6709\u597d\u597d\u5229\u7528\u5b83\u4eec\uff0c\u611f\u89c9\u6709\u70b9\u9057\u61be\u5462\uff0c\u8fd9\u6b21\u771f\u662f\u5b66\u5230\u4e86\u4e0d\u5c11\u4e1c\u897f\u3002<\/p>\n<p>\u597d\u7684\uff0c\u4eca\u5929<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Alertmanager \u3068 Gitlab \u3092\u9023\u643a\u3055\u305b\u3066\u30c1\u30b1\u30c3\u30c8\u767a\u884c\u3092\u81ea\u52d5\u5316\u3059\u308b\u65b9\u6cd5<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">Alertmanager \u3068 webhook \u3092\u9023\u643a\u3055\u305b\u3066\u30a2\u30e9\u30fc\u30c8\u5bfe\u5fdc\u3092\u81ea\u52d5\u5316\u3059\u308b\u65b9\u6cd5<\/ul>\n<p>\u6211\u4eec\u5c06\u4ee5&#8230;\u4e3a\u4e2d\u5fc3\u8fdb\u884c\u4ecb\u7ecd\u3002<\/p>\n<h1>\u5728\u8fc7\u53bb\u7684\u4e00\u5e74\u91cc\u505a\u8fc7\u7684\u4e8b\u60c5<\/h1>\n<p>\u53bb\u5e74\u6211\u4eec\u6240\u5c5e\u7684\u56e2\u961f\u7b2c\u4e00\u6b21\u8fdb\u884c\u4e86\u969c\u788d\u8bad\u7ec3\uff0c\u5e76\u5728\u56e2\u961f\u4e2d\u8fdb\u884c\u4e86\u969c\u788d\u8bad\u7ec3\u7684\u8bb2\u8ff0\u4e2d\u5411\u5927\u5bb6\u4ecb\u7ecd\u4e86\u8fd9\u4e2a\u6d41\u7a0b\u3002<br \/>\n\u4eca\u5e74\u7531\u4e8e\u56e2\u961f\u6210\u5458\u6709\u6240\u53d8\u52a8\uff0c\u6211\u4eec\u4e5f\u8fdb\u884c\u4e86\u969c\u788d\u8bad\u7ec3\u3002<\/p>\n<p>\u53bb\u5e74\u6211\u4eec\u81f4\u529b\u4e8e\u8fdb\u884c\u969c\u788d\u8bad\u7ec3\uff0c\u800c\u4eca\u5e74\u5b9e\u65bd\u672c\u8eab\u987a\u5229\u8fdb\u884c\uff0c\u56e0\u6b64\u5728\u8bad\u7ec3\u7ed3\u675f\u540e\uff0c\u6211\u4eec\u8fdb\u884c\u4e86\u6539\u8fdb\u3002<\/p>\n<p>\u56de\u8fc7\u5934\u6765\u770b\uff0c\u6211\u4eec\u6309\u7167\u4ee5\u4e0b\u7684\u987a\u5e8f\u9010\u6b65\u8fdb\u884c\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">2\u5ea6\u76ee\u306e\u969c\u5bb3\u8a13\u7df4\u5b9f\u65bd<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c1\u30b1\u30c3\u30c8\u767a\u884c\u306e\u81ea\u52d5\u5316<\/ul>\n<\/li>\n<\/ul>\n<p>\u904e\u53bb\u306e\u30ca\u30ec\u30c3\u30b8\u3092\u84c4\u7a4d\u3059\u308b\u5834\u6240\u3092\u7528\u610f<\/p>\n<p>\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u66f4\u65b0<\/p>\n<p>\u30a2\u30e9\u30fc\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u306b\u5fdc\u3058\u305f\u5bfe\u5fdc\u624b\u9806\u3092\u7528\u610f<\/p>\n<p>\u30a2\u30e9\u30fc\u30c8\u5bfe\u5fdc\u306e\u81ea\u52d5\u5316<\/p>\n<p>\u672c\u6b21\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u7968\u52a1\u53d1\u884c\u548c\u8b66\u62a5\u54cd\u5e94\u7684\u81ea\u52a8\u5316\u5904\u7406\u3002<\/p>\n<h1>\u7968\u52a1\u53d1\u884c\u7684\u81ea\u52a8\u5316<\/h1>\n<p>\u5728\u969c\u5bb3\u8bad\u7ec3\u5b9e\u65bd\u540e\u7684\u53cd\u601d\u4e2d\uff0c\u6709\u4eba\u63d0\u51fa\u4e86\u4e00\u4e2a\u89c2\u70b9\uff0c\u8ba4\u4e3a\u4e0d\u4ec5\u9700\u8981\u6539\u5584\u53c2\u8003\u969c\u5bb3\u53d1\u751f\u65f6\u4f7f\u7528\u7684\u6587\u6863\uff0c\u8fd8\u5e94\u8be5\u6709\u4e00\u4e2a\u5730\u65b9\u6765\u50a8\u5b58\u8fc7\u53bb\u5904\u7406\u8b66\u62a5\u65f6\u79ef\u7d2f\u7684\u77e5\u8bc6\u3002\u7531\u4e8e\u6211\u4eec\u7684\u56e2\u961f\u5728\u5e94\u5bf9\u969c\u5bb3\u65f6\u7ecf\u5e38\u5728\u6c9f\u901a\u5de5\u5177\u4e0a\u7559\u4e0b\u4fe1\u606f\uff0c\u56e0\u6b64\u6211\u4eec\u51b3\u5b9a\u8981\u4e3a\u4fe1\u606f\u79ef\u7d2f\u63d0\u4f9b\u4e00\u4e2a\u7a33\u5b9a\u7684\u573a\u6240\u3002\u4e3a\u4e86\u907f\u514d\u624b\u52a8\u53d1\u884c\u7968\u52a1\u7684\u9ebb\u70e6\uff0c\u6211\u4eec\u4f7f\u5f97\u7968\u52a1\u81ea\u52a8\u53d1\u884c\u3002<\/p>\n<p>\u6211\u4eec\u4f7f\u7528Prometheus\u8fdb\u884c\u76d1\u89c6\uff0c<br \/>\n\u4f7f\u7528Alertmanager\u8fdb\u884c\u8b66\u62a5\u7ba1\u7406\u3002<br \/>\n\u56e0\u6b64\uff0c\u5f53Alertmanager\u68c0\u6d4b\u5230\u8b66\u62a5\u65f6\uff0c\u6211\u4eec\u8bbe\u7f6e\u5b83\u81ea\u52a8\u521b\u5efaGitlab\u7684incident\uff08ticket\uff09\u3002<\/p>\n<h2>\u4e0eGitlab\u7684\u6574\u5408<\/h2>\n<p>\u203b\u53c2\u8003\uff1aGitlab\u5b98\u65b9\u6587\u4ef6\u8d44\u6599<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u51c6\u5907\u4e00\u4e2a\u9879\u76ee\uff0c\u5728\u53d1\u751f\u8b66\u62a5\u65f6\u751f\u6210\u4e00\u4e2a\u6545\u969c\u5355<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u6253\u5f00\u9879\u76ee\u7684Settings &gt; Monitor<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u70b9\u51fbAlerts<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u9009\u62e9Add new integration<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u5728\u9009\u62e9\u96c6\u6210\u7c7b\u578b\u7684\u4e0b\u62c9\u83dc\u5355\u4e2d\u9009\u62e9Prometheus<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u5207\u6362\u5230Active<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u8f93\u5165Prometheus API\u7684\u57fa\u672cURL<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u4fdd\u5b58\u8bbe\u7f6e\uff0c\u70b9\u51fbSave integration<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\u6253\u5f00View credentials\u9009\u9879\u5361\uff0c\u786e\u8ba4\u80fd\u591f\u67e5\u770bWebhook URL\u548cAuthorization key\u5373\u53ef\u3002<\/ol>\n<h2>2. \u4e0eAlertmanager\u7684\u534f\u4f5c<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">alertmanager.yml \u306b\u4ee5\u4e0b\u306e\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">receivers:<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">&#8211; name: gitlab<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">webhook_configs:<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">&#8211; http_config:<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">authorization:<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">bearer_token: 1.9\u3067\u78ba\u8a8d\u3057\u305f Authorization key \u3092\u5165\u529b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">send_resolved: true<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">url: 1.9\u3067\u78ba\u8a8d\u3057\u305f Webhook URL \u3092\u5165\u529b<\/ul>\n<p>\u73b0\u5728\uff0c\u5f53\u53d1\u751f\u8b66\u62a5\u65f6\uff0c\u5c06\u81ea\u52a8\u521b\u5efa\u4e8b\u4ef6\u3002\u521b\u5efa\u7684\u4e8b\u4ef6\u53ef\u4ee5\u4ece\u95ee\u9898\u5217\u8868\u4e2d\u8fdb\u884c\u786e\u8ba4\u3002<br \/>\n\u7531\u4e8e\u81ea\u52a8\u586b\u5199\u4e86\u53d1\u751f\u65f6\u95f4\u548c\u8b66\u62a5\u540d\u79f0\uff0c\u56e0\u6b64\u65e0\u9700\u624b\u52a8\u8f93\u5165\u3002<br \/>\n\u8fd8\u53ef\u4ee5\u8bbe\u7f6e\u9002\u7528\u4e8e\u81ea\u52a8\u521b\u5efa\u4e8b\u4ef6\u7684\u6a21\u677f\u3002<br \/>\n\u6211\u4eec\u51c6\u5907\u4e86\u4e00\u4e2a\u57fa\u672c\u8b66\u62a5\u5904\u7406\u6d41\u7a0b\u7684\u68c0\u67e5\u6e05\u5355\u6a21\u677f\uff0c\u5e76\u5c06\u5176\u5e94\u7528\u3002<br \/>\n\u5728\u53d1\u751f\u8b66\u62a5\u65f6\uff0c\u5c06\u6253\u5f00\u81ea\u52a8\u521b\u5efa\u7684\u4e8b\u4ef6\uff0c\u5e76\u6309\u7167\u6e05\u5355\u4e2d\u6240\u8ff0\u7684\u6d41\u7a0b\u8fdb\u884c\u5347\u7ea7\u6216\u8c03\u67e5\u3002<\/p>\n<h1>\u81ea\u52a8\u5316\u62a5\u8b66\u54cd\u5e94<\/h1>\n<p>\u7ecf\u8fc7\u969c\u788d\u8bad\u7ec3\u540e\uff0c\u6587\u6863\u4e5f\u5df2\u66f4\u65b0\u3002\u4ee5\u524d\uff0c\u6839\u636e\u4e8b\u4ef6\uff08\u4f8b\u5982\uff1aAPI\u54cd\u5e94\u53d8\u6162\uff09\u51c6\u5907\u4e86\u76f8\u5e94\u5bf9\u7b56\u7684\u6587\u6863\uff0c\u6709\u65f6\u5019\u6839\u636e\u8b66\u62a5\u6d88\u606f\u5f88\u96be\u786e\u5b9a\u5c5e\u4e8e\u54ea\u4e2a\u4e8b\u4ef6\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u91cd\u65b0\u6574\u7406\u4e86\u6839\u636e\u6bcf\u4e2a\u8b66\u62a5\u6d88\u606f\u7684\u5904\u7406\u65b9\u6cd5\u3002<\/p>\n<p>\u56e0\u4e3a\u6709\u4eba\u63d0\u5230\uff0c\u53ef\u4ee5\u5c06\u6bcf\u4e2a\u8b66\u62a5\u6d88\u606f\u7684\u5904\u7406\u65b9\u6cd5\u91cd\u65b0\u6574\u7406\u4e00\u4e0b\uff0c\u7136\u540e\u5c1d\u8bd5\u81ea\u52a8\u5316\u5904\u7406\u3002<\/p>\n<p>\u5982\u524d\u6240\u8ff0, \u6211\u4eec\u4f7f\u7528 Alertmanager \u8fdb\u884c\u8b66\u62a5\u7ba1\u7406\uff0c\u73b0\u5728\u6211\u4eec\u51b3\u5b9a\u5c06 Alertmanager \u4e0e webhook \u914d\u5408\u4f7f\u7528\uff0c\u4ee5\u5b9e\u73b0\u81ea\u52a8\u5316\u3002\u4ee5\u4e0b\u662f\u6982\u8ff0\uff1a<\/p>\n<pre class=\"post-pre\"><code>Alertmanager\r\n\u3000\u3000\u2193\r\n webhook\r\n\u3000\u3000\u2193\r\n\u30a2\u30e9\u30fc\u30c8\u30c1\u30a7\u30c3\u30af\u30b9\u30af\u30ea\u30d7\u30c8\r\n\u3000\u3000\u2193\r\n\u81ea\u52d5\u5316\u7528\u30b9\u30af\u30ea\u30d7\u30c8\r\n<\/code><\/pre>\n<p>\u5728\u8b66\u62a5\u53d1\u751f\u65f6\uff0cAlertmanager\u4f1a\u8c03\u7528webhook\u3002<br \/>\nwebhook\u5c06\u6267\u884c\u8b66\u62a5\u68c0\u67e5\u811a\u672c\u4ee5\u5224\u65ad\u6240\u53d1\u751f\u7684\u8b66\u62a5\uff0c\u7136\u540e\u8c03\u7528\u4e0e\u8b66\u62a5\u76f8\u5173\u7684\u81ea\u52a8\u5316\u811a\u672c\u3002<br \/>\n\u901a\u8fc7\u5728\u81ea\u52a8\u5316\u811a\u672c\u4e2d\u8bb0\u5f55\u5e0c\u671b\u5728\u8b66\u62a5\u53d1\u751f\u65f6\u6267\u884c\u7684\u5904\u7406\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5b9e\u73b0\u8b66\u62a5\u54cd\u5e94\u7684\u81ea\u52a8\u5316\u3002<\/p>\n<p>\u5177\u4f53\u7684\u7684\u65b9\u5f0f\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<h2>1. \u51c6\u5907\u6bcf\u4e2a\u8b66\u62a5\u7684\u81ea\u52a8\u5316\u811a\u672c\u3002<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\/path\/to\/script\/Alert_A.sh<\/ul>\n<\/li>\n<\/ul>\n<p>\u30a2\u30e9\u30fc\u30c8\u304c\u767a\u751f\u3057\u305f\u969b\u306b\u5b9f\u65bd\u3057\u305f\u3044\u5185\u5bb9\u3092\u8a18\u8f09\u3057\u3066\u304f\u3060\u3055\u3044<br \/>\n\u30a2\u30e9\u30fc\u30c8\u540d\u6bce\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u308b\u3068\u898b\u5206\u3051\u3084\u3059\u3044\u3067\u3059<br \/>\n\u4f8b\u3067\u306f\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u4ed6\u306e\u8a00\u8a9e\u3067\u3082\u554f\u984c\u3042\u308a\u307e\u305b\u3093<\/p>\n<h2>\u51c6\u5907\u8b66\u62a5\u68c0\u67e5\u811a\u672c<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\/path\/to\/script\/AlertCheck.sh<\/ul>\n<\/li>\n<\/ul>\n<p>\u4eca\u56de\u306f\u30a2\u30e9\u30fc\u30c8\u540d\u306e\u307f\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u307b\u304b\u306e\u60c5\u5831\u3082\u540c\u69d8\u306b\u53d6\u5f97\u53ef\u80fd\u3067\u3059<br \/>\n\u30a2\u30e9\u30fc\u30c8\u540d\u306b\u5fdc\u3058\u3066\u3001\u5bfe\u5fdc\u3059\u308b\u81ea\u52d5\u5316\u7528\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u547c\u3073\u51fa\u3059\u3088\u3046\u306b\u6761\u4ef6\u5206\u5c90\u3055\u305b\u307e\u3059<\/p>\n<p>#!\/bin\/bash<\/p>\n<p># Alertmanager API \u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u73fe\u5728\u767a\u751f\u3057\u3066\u3044\u308b\u30a2\u30e9\u30fc\u30c8\u4e00\u89a7\u3092\u53d6\u5f97<br \/>\napi_result=`curl -X GET -G https:\/\/Alertmanager\u306eURL:\u30dd\u30fc\u30c8\/api\/v2\/alerts?receiver=receiver\u540d`<br \/>\n# \u30a2\u30e9\u30fc\u30c8\u4ef6\u6570\u3092\u53d6\u5f97<br \/>\nalert_count=`echo ${api_result} | jq length`<\/p>\n<p># \u30a2\u30e9\u30fc\u30c8\u4e00\u89a7\u304b\u3089\u30a2\u30e9\u30fc\u30c8\u60c5\u5831\u3092\u53d6\u5f97<br \/>\nfor ((i=0; i&lt;=`expr ${alert_count} &#8211; 1` i++)) do<br \/>\n# \u30a2\u30e9\u30fc\u30c8\u540d\u3092\u53d6\u5f97<br \/>\nalertname=`echo ${api_result} | jq -r &#8220;.[$i].labels.alertname&#8221;`<\/p>\n<p># \u30a2\u30e9\u30fc\u30c8\u540d\u306b\u5fdc\u3058\u3066\u81ea\u52d5\u5316\u7528\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u547c\u3073\u51fa\u3057<br \/>\nif [ ${alertname} = &#8220;Alert_A&#8221; ]; then<br \/>\n\/path\/to\/script\/Alert_A.sh<br \/>\nfi<br \/>\ndone<\/p>\n<h2>3. \u5728Ubuntu\u4e0a\u5b89\u88c5webhook\u3002<\/h2>\n<pre class=\"post-pre\"><code>apt install webhook\r\n<\/code><\/pre>\n<h2>\u521b\u5efa webhook.json \u6587\u4ef6<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\/path\/to\/script\/webhook.json \u306b\u4ee5\u4e0b\u3092\u8a18\u8f09\u3057\u307e\u3059<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">[<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">{<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">&#8220;id&#8221;: &#8220;alertautomation&#8221;,<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">&#8220;execute-command&#8221;: &#8220;\/path\/to\/script\/AlertCheck.sh&#8221;,<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">&#8220;command-working-directory&#8221;: &#8220;\/path\/to\/script&#8221;<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">}<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">]<\/ul>\n<h2>5. \u6fc0\u6d3bWebhook<\/h2>\n<pre class=\"post-pre\"><code>webhook -hooks \/path\/to\/script\/webhook.json -verbose\r\n<\/code><\/pre>\n<h2>Alertmanager \u8c03\u7528 webhook<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">alertmanager.yml \u306b\u4ee5\u4e0b\u306e\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">receivers:<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">&#8211; name: &#8216;webhook&#8217;<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">webhook_configs:<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">&#8211; url: &#8216;http:\/\/Webhook\u306eURL:9000\/hooks\/alertautomation&#8217;<\/ul>\n<p>\u203b\u53c2\u8003\uff1a\u5982\u4f55\u5728Alertmanager\u63a5\u6536\u5230\u8b66\u62a5\u65f6\u6267\u884cShell\u811a\u672c<\/p>\n<p>\u8bbe\u5b9a\u81ea\u52a8\u5316\u811a\u672c\u5728\u5904\u7406\u5b8c\u6210\u540e\u901a\u77e5\u7ed3\u679c\uff0c\u80fd\u591f\u4f7f\u60c5\u51b5\u66f4\u5bb9\u6613\u7406\u89e3\uff0c\u907f\u514d\u6210\u4e3a\u9ed1\u76d2\u5b50\u3002<br \/>\n\u6b64\u5916\uff0c\u5373\u4f7f\u4e0d\u80fd\u5b8c\u5168\u81ea\u52a8\u5316\u5904\u7406\u7684\u8b66\u62a5\uff0c\u4e5f\u53ef\u4ee5\u90e8\u5206\u81ea\u52a8\u5316\u5730\u8fdb\u884c\u65e5\u5fd7\u8c03\u67e5\uff0c\u901a\u77e5\u7ed3\u679c\u6709\u52a9\u4e8e\u539f\u56e0\u8c03\u67e5\u3002<\/p>\n<h1>\u603b\u7ed3<\/h1>\n<p>\u6211\u4eec\u7ee7\u7eed\u4eca\u5e74\u7684\u969c\u788d\u8bad\u7ec3\uff0c\u5e76\u4ece\u56de\u987e\u4e2d\u63d0\u53d6\u51fa\u4ee5\u4e0b\u8981\u70b9\uff1a<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30a2\u30e9\u30fc\u30c8\u60c5\u5831\u3092\u84c4\u7a4d\u3059\u308b\u5834\u6240\u306e\u7528\u610f<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u4e00\u90e8\u30a2\u30e9\u30fc\u30c8\u5bfe\u5fdc\u306e\u81ea\u52d5\u5316<\/ul>\n<p>\u6211\u80fd\u591f\u63a8\u8fdb\u8fd9\u4e00\u70b9\u3002\u5e0c\u671b\u80fd\u7ee7\u7eed\u8fdb\u4e00\u6b65\u6539\u5584\uff01<\/p>\n<p>\u660e\u5929\u662f @Syuparn \u7684\u300c\u5229\u7528WASI\u5236\u4f5c\u7f16\u8f91\u5668\u5de5\u5177\u300d\u7684\u8bfe\u7a0b\u3002\u5982\u679c\u80fd\u591f\u5236\u4f5c\u51fa\u81ea\u5df1\u559c\u6b22\u7684\u7f16\u8f91\u5668\uff0c\u5de5\u4f5c\u4f3c\u4e4e\u4e5f\u4f1a\u66f4\u987a\u5229\u5462&#8230;\uff01\u656c\u8bf7\u671f\u5f85\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148 \u8fd9\u7bc7\u6587\u7ae0\u662f\u5bcc\u58eb\u901a\u4e91\u6280\u672f\u76842023\u5e74\u5723\u8bde\u8282\u65e5\u5386\u7684\u7b2c11\u5929\u6587\u7ae0\uff0c\u4ecb\u7ecd\u4e86\u63d0\u4f9b\u4e86Nifcloud\u7b49\u670d\u52a1\u7684\u5bcc\u58eb\u901a\u4e91 [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-43682","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406\" \/>\n<meta property=\"og:description\" content=\"\u9996\u5148 \u8fd9\u7bc7\u6587\u7ae0\u662f\u5bcc\u58eb\u901a\u4e91\u6280\u672f\u76842023\u5e74\u5723\u8bde\u8282\u65e5\u5386\u7684\u7b2c11\u5929\u6587\u7ae0\uff0c\u4ecb\u7ecd\u4e86\u63d0\u4f9b\u4e86Nifcloud\u7b49\u670d\u52a1\u7684\u5bcc\u58eb\u901a\u4e91 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-27T03:11:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T23:00:10+00:00\" \/>\n<meta name=\"author\" content=\"\u6e05, \u626c\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u626c\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/\",\"name\":\"\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-02-27T03:11:08+00:00\",\"dateModified\":\"2024-04-29T23:00:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\",\"name\":\"\u6e05, \u626c\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u626c\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406\/","og_locale":"zh_CN","og_type":"article","og_title":"\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406","og_description":"\u9996\u5148 \u8fd9\u7bc7\u6587\u7ae0\u662f\u5bcc\u58eb\u901a\u4e91\u6280\u672f\u76842023\u5e74\u5723\u8bde\u8282\u65e5\u5386\u7684\u7b2c11\u5929\u6587\u7ae0\uff0c\u4ecb\u7ecd\u4e86\u63d0\u4f9b\u4e86Nifcloud\u7b49\u670d\u52a1\u7684\u5bcc\u58eb\u901a\u4e91 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-02-27T03:11:08+00:00","article_modified_time":"2024-04-29T23:00:10+00:00","author":"\u6e05, \u626c","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u626c","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/","name":"\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-02-27T03:11:08+00:00","dateModified":"2024-04-29T23:00:10+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u81ea\u52d5\u5316\u7684\u8b66\u5831\u8655\u7406"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461","name":"\u6e05, \u626c","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","caption":"\u6e05, \u626c"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%87%aa%e5%8b%95%e5%8c%96%e7%9a%84%e8%ad%a6%e5%a0%b1%e8%99%95%e7%90%86\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/43682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=43682"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/43682\/revisions"}],"predecessor-version":[{"id":90406,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/43682\/revisions\/90406"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=43682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=43682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=43682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}