{"id":10696,"date":"2020-10-13T11:15:57","date_gmt":"2020-10-13T03:15:57","guid":{"rendered":"https:\/\/www.microfusion.cloud\/hk\/?p=10696"},"modified":"2025-01-13T14:47:36","modified_gmt":"2025-01-13T06:47:36","slug":"gcp-log-viewer-20201013","status":"publish","type":"post","link":"https:\/\/www.microfusion.cloud\/hk\/2020\/10\/13\/gcp-log-viewer-20201013\/","title":{"rendered":"GCP \u76e3\u63a7Log Viewer\u662f\u5426\u6709Critical\u8207Error\u7b49\u5c64\u7d1a\u8a18\u9304"},"content":{"rendered":"<p>\u7576 VM \u670d\u52d9\u51fa\u73fe\u7570\u5e38\u7684\u6642\u5019\uff0c\u5c31\u53ef\u80fd\u9020\u6210\u7cfb\u7d71\u66f4\u65b0\u5931\u6557\u3001\u7db2\u9801\u7121\u6cd5\u986f\u793a\u7b49\u72c0\u6cc1\uff0c\u9019\u6642\u5019\u53ef\u4ee5\u7528 Log Viewer \u505a\u521d\u6b65\u76e3\u63a7\uff0c\u907f\u514d\u6709\u7570\u5e38\u537b\u6c92\u767c\u73fe\uff0c\u9020\u6210\u4f01\u696d\u71df\u904b\u4e0a\u7684\u640d\u5931\u3002<\/p>\n\n\n<p>\u00a0<\/p>\n<h3>\u9810\u8a08\u6d41\u7a0b<\/h3>\n<p style=\"margin-bottom: 0.9rem;\">1.\u00a0\u67e5\u770bVM \u6240\u62cb\u51fa\u7684 \u8a18\u9304 (Log Viewer)<\/p>\n<p style=\"margin-bottom: 0.9rem;\">2.\u00a0\u6839\u64da\u8a18\u9304\u5efa\u7acb\u6307\u6a19 (Logs-based Metrics)<\/p>\n<p style=\"margin-bottom: 0.9rem;\">3.\u00a0\u5efa\u7acb Monitoring Alarm<\/p>\n<p>\u00a0<\/p>\n<h3>\u5be6\u4f5c\u6b65\u9a5f<\/h3>\n<p><b>1. \u67e5\u770bVM \u6240\u62cb\u51fa\u7684 \u8a18\u9304 (Log Viewer)<\/b><\/p>\n<p>Step.1 \u9ede\u64ca Logging \u2192\u00a0 Logs Viewer<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-14235\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/01-1-300x160.jpeg\" alt=\"\" width=\"383\" height=\"204\" srcset=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/01-1-300x160.jpeg 300w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/01-1.jpeg 629w\" sizes=\"auto, (max-width: 383px) 100vw, 383px\" \/><\/p>\n<p>Step.2\u00a0\u5f9eLogs Viewer\u4e2d\u641c\u5c0b\u81ea\u5df1\u60f3\u8981\u7684\u4e3b\u6a5f\uff0c\u6211\u5011\u4ee5\u6b64\u4e3b\u6a5f(zerotest) \u70ba\u7bc4\u4f8b<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/02.jpg\" \/><\/p>\n<p>Step.3\u00a0\u8a2d\u5b9a\u597d\u53c3\u6578\u5f8c\uff0cLogs Viewer\u00a0\u5c07\u6703\u986f\u793a\u8a72VM\u6240\u62cb\u51fa\u7684\u76f8\u95dc\u4fe1\u606f<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/03-1-1024x505.jpg\" \/><\/p>\n<h3><b>\uff12.\u00a0<\/b><b>\u6839\u64da\u8a18\u9304\u5efa\u7acb\u6307\u6a19 (Logs-based Metrics)<\/b><\/h3>\n<p>Step.1 \u9ede\u64ca<b>\u5efa\u7acb\u6307\u6a19<\/b>\uff0c\u5efa\u7acb Logs-based Metrics<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/04-.jpg\" \/><\/p>\n<p>Step.2 \u5efa\u7acb\u6307\u6a19\u7de8\u8f2f\u5de5\u5177<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/05.jpg\" width=\"298\" height=\"297\" \/><\/p>\n<p>Step.3 \u4fee\u6539\u6a19\u7c64\u53c3\u6578(WARNING|ERROR|CRITICAL)\uff0c\u5b8c\u6210\u5f8c\u9ede\u64caDONE<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/07.jpg\" \/><\/p>\n<p># \u95dc\u65bcRegEx \u7684\u8a2d\u5b9a\u6211\u5011\u53ef\u4ee5\u5f9e\u7db2\u4e0a\u7684\u7dda\u4e0a\u6a21\u64ec\u5668\u4e2d\u6e2c\u8a66<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/08-1024x330.jpg\" \/><\/p>\n<p>Step.4 \u5f9e<b>\u6839\u64da\u8a18\u9304\u5efa\u7acb\u7684\u6307\u6a19<\/b>\u5167\u67e5\u770b\u662f\u5426\u5df2\u7d93\u5b8c\u6210\u5efa\u7acb\u6307\u6a19<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/09-1024x584.jpg\" \/><\/p>\n<h3><b>3.\u00a0<\/b><b>\u5efa\u7acb Monitoring Alarm<\/b><\/h3>\n<p>Step.1 \u5efa\u7acb Monitoring \u5feb\u8a0a<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/10.jpg\" \/><\/p>\n<p>Step.2 \u9ede\u64ca<b>Create Policy<\/b><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/11.jpg\" \/><\/p>\n<p>Step.3\u00a0\u8f38\u5165\u00a0<em>Policy \u540d\u7a31<\/em>\uff0c\u9ede\u64ca\u00a0<b>ADD CONDITION<\/b><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/12.jpg\" \/><\/p>\n<p>Step.4\u00a0\u8a2d\u5b9a\u544a\u8b66\u503c\u53c3\u6578\uff0c\u5b8c\u6210\u8a2d\u5b9a\u5f8c\u9ede\u64ca<b>Save<\/b><\/p>\n<ul>\n<li>Resource Type : VM Instance<\/li>\n<li>Metric : logging\/user\/get_metric_severity (\u525b\u525b\u6240\u5efa\u7acbLogs-based Metrics \u540d\u7a31)<\/li>\n<li>Filter : get_metric_severity = \u201cERROR\u201d (\u6b64\u8655\u8f38\u5165\u60a8\u60f3\u76e3\u63a7\u7684severity\u7684\u72c0\u6cc1)<\/li>\n<li>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0get_metric_severity = \u201cWARNING\u201d (\u6b64\u8655\u8f38\u5165\u60a8\u60f3\u76e3\u63a7\u7684severity\u7684\u72c0\u6cc1)<\/li>\n<li>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0get_metric_severity = \u201cCRITICAL\u201d (\u6b64\u8655\u8f38\u5165\u60a8\u60f3\u76e3\u63a7\u7684severity\u7684\u72c0\u6cc1)<\/li>\n<li>Period : 1minute\u00a0<\/li>\n<li>Condition triggers if : Any time series violates<\/li>\n<li>Condition : is above\u00a0<\/li>\n<li>Threshold : 0.01\u00a0<\/li>\n<li>For : 1 minute (\u6301\u7e8c\u6642\u9593)<\/li>\n<\/ul>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/13.jpg\" \/><\/p>\n<p>Step.5\u00a0\u8a2d\u5b9aNotification\u806f\u7e6b\u65b9\u5f0f\uff0c\u5b8c\u6210\u8a2d\u5b9a\u5f8c\u9ede\u64ca\u00a0<b>ADD NOTIFICATION CHANNEL<\/b>\u00a0\u2192\u00a0<b>Save<\/b><\/p>\n<ul>\n<li>Notification Channel Type :\u00a0<em>\u8f38\u5165 Email<\/em><\/li>\n<li>\u96fb\u5b50\u90f5\u4ef6\u5730\u5740 :\u00a0<em>\u8f38\u5165\u4f60\u60f3\u63a5\u6536 Alarm\u7684Email<\/em><\/li>\n<\/ul>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/17.jpg\" \/><\/p>\n<p>Step.6\u00a0\u67e5\u770b\u5efa\u7acb\u5b8c\u6210\u7684\u544a\u8b66<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/10\/16-1024x306.jpg\" \/><\/p>\n<p>\u9019\u6a23\u5c31\u5927\u529f\u544a\u6210\u5566! \u662f\u4e0d\u662f\u6e05\u695a\u7c21\u55ae\u53c8\u5feb\u901f\u5462?\u00a0<\/p>\n<p>\u82e5\u60f3\u4e86\u89e3\u5b8c\u6574\u61c9\u7528\uff0c\u8acb\u6301\u7e8c\u95dc\u6ce8<a href=\"https:\/\/www.microfusion.cloud\/hk\/blog\/\">\u5b8f\u5ead\u67b6\u69cb\u5e2b\u5c08\u6b04<\/a>\uff0c\u82e5\u6709\u4efb\u4f55 \u96f2\u7aef\u9700\u6c42\uff0c\u4e5f\u6b61\u8fce\u96a8\u6642\u8207\u6211\u5011\u806f\u7e6b\u5594!<\/p>\n<p>\u00a0<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.microfusion.cloud\/hk\/contact\/\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.microfusion.cloud\/hk\/wp-content\/uploads\/2020\/02\/%E8%81%AF%E7%B5%A1%E6%88%91%E5%80%91.png\" alt=\"\" width=\"185\" height=\"103\" \/><\/a><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\u00a0<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\u00a0<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u7576 VM \u670d\u52d9\u51fa\u73fe\u7570\u5e38\u7684\u6642\u5019\uff0c\u5c31\u53ef\u80fd\u9020\u6210\u7cfb\u7d71\u66f4\u65b0\u5931\u6557\u3001\u7db2\u9801\u7121\u6cd5\u986f\u793a\u7b49\u72c0\u6cc1\uff0c\u9019\u6642\u5019\u53ef\u4ee5\u7528 Log Viewer \u505a\u521d\u6b65\u76e3\u63a7\uff0c\u907f\u514d\u6709\u7570\u5e38\u537b\u6c92\u767c\u73fe\uff0c\u9020\u6210\u4f01\u696d\u71df\u904b\u4e0a\u7684\u640d\u5931\u30021.\u67e5\u770bVM \u6240\u62cb\u51fa\u7684 \u8a18\u9304 (Log Viewer) 2.\u6839\u64da\u8a18\u9304\u5efa\u7acb\u6307\u6a19 (Logs-based Metrics)<\/p>\n","protected":false},"author":3,"featured_media":7826,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[173],"tags":[199,172],"class_list":["post-10696","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical_gcp","tag-gcp"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/posts\/10696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/comments?post=10696"}],"version-history":[{"count":33,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/posts\/10696\/revisions"}],"predecessor-version":[{"id":20575,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/posts\/10696\/revisions\/20575"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/media\/7826"}],"wp:attachment":[{"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/media?parent=10696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/categories?post=10696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/tags?post=10696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}