{"id":43572,"date":"2022-08-14T22:17:11","date_gmt":"2023-05-30T05:42:43","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/"},"modified":"2024-01-15T11:43:32","modified_gmt":"2024-01-15T03:43:32","slug":"%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/","title":{"rendered":"\u6211\u4f7f\u7528GCE\u8bd5\u7740\u4f7f\u7528Prometheus"},"content":{"rendered":"<p>\u6211\u5728GCE\u4e0a\u521b\u5efa\u4e86\u4e00\u4e9b\u5b9e\u4f8b\uff0c\u6839\u636e\u5176\u89d2\u8272\u8fdb\u884c\u7ba1\u7406\uff0c\u4f8b\u5982api\uff0cweb\uff0cdb\uff0cstaging\uff0cproduction\u7b49\uff0c\u5e76\u968f\u610f\u4e3a\u5176\u6dfb\u52a0\u4e86\u6807\u7b7e\u4ee5\u8fdb\u884c\u8fd0\u7ef4\u3002<\/p>\n<p>\u5728\u90a3\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u5f00\u59cb\u8003\u8651\u5f15\u5165Prometheus\u6765\u6536\u96c6\u5404\u79cd\u6307\u6807\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u505a\u4e86\u4ee5\u4e0b\u8fd9\u4e9b\u4e8b\u60c5\u3002<\/p>\n<h2>\u751f\u6210\u51ed\u8bc1<\/h2>\n<p>\u8bf7\u53c2\u8003\u6b64\u94fe\u63a5\uff1ahttps:\/\/developers.google.com\/identity\/protocols\/application-default-credentials\uff0c\u83b7\u53d6\u51ed\u636e\u7684JSON\uff0c\u5e76\u5c06\u5176\u653e\u7f6e\u5728\u6267\u884cPrometheus\u7684\u4e3b\u673a\u7684~\/.config\/gcloud\/application_default_credentials.json \u6587\u4ef6\u4e2d\u3002<\/p>\n<h2>GCE_SD\u914d\u7f6e<\/h2>\n<p>\u5982\u679c`__meta_gce_tags`\u4e0a\u6709`foo`\u548c`bar`\u6807\u7b7e\uff0c\u5b83\u4f3c\u4e4e\u4f1a\u8fd4\u56de\u503c`,foo,bar,`\u3002<\/p>\n<h2>\u5173\u4e8eredis_exporter<\/h2>\n<p>\u4e3a\u4e86\u7b80\u5316\u7ba1\u7406\uff0credis_exporter\u5728\u542f\u52a8\u65f6\u7684\u53c2\u6570\u4e2d\u4f1a\u5217\u51fa\u591a\u4e2aRedis\u670d\u52a1\u5668\u7684\u5730\u5740\u3002\u7136\u800c\uff0c\u8fd9\u6837\u505a\u53ef\u80fd\u4f1a\u4e0d\u592a\u65b9\u4fbf\uff0c\u6240\u4ee5\u6211\u4eec\u51b3\u5b9a\u5728\u6bcf\u4e2aRedis\u5b9e\u4f8b\u4e2d\u8fd0\u884c\u4e00\u4e2aredis_exporter\uff0c\u5e76\u5c06\u5176\u6307\u5411\u672c\u5730\u4e3b\u673a\u3002<\/p>\n<h2>\u6700\u7ec8\u7684 prometheus.yml<\/h2>\n<p>\u6700\u7ec8\u7ed3\u679c\u662f\u8fd9\u6837\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code>  - job_name: 'node'\r\n    gce_sd_configs:\r\n    - project: XXXXXXXXX\r\n      zone: asia-east1-c\r\n      port: 9100\r\n    relabel_configs:\r\n    - source_labels: [__meta_gce_instance_name]\r\n      target_label: instance\r\n      regex: (.*)\r\n      replacement: $1\r\n    - source_labels: [__meta_gce_tags]\r\n      target_label: stage\r\n      regex: \".*,(staging|production),.*\"\r\n      replacement: $1\r\n    - source_labels: [__meta_gce_tags]\r\n      target_label: role\r\n      regex: \".*,(api|web|db|redis),.*\"\r\n      replacement: $1\r\n\r\n  - job_name: 'redis_exporter'\r\n    gce_sd_configs:\r\n    - project: XXXXXXXXX\r\n      zone: asia-east1-c\r\n      port: 9121\r\n    relabel_configs:\r\n    - source_labels: [__meta_gce_instance_name]\r\n      target_label: instance\r\n      regex: (.*)\r\n      replacement: $1\r\n    - source_labels: [__meta_gce_tags]\r\n      target_label: stage\r\n      regex: \".*,(staging|production),.*\"\r\n      replacement: $1\r\n    - source_labels: [__meta_gce_tags]\r\n      target_label: role\r\n      regex: \".*,redis,.*\"\r\n      action: keep\r\n<\/code><\/pre>\n<p>\u518d\u7a0d\u5fae\u52aa\u529b\u4e00\u4e0b\uff0c\u53ef\u80fd\u53ef\u4ee5\u641e\u5b9a\u6b63\u5219\u8868\u8fbe\u5f0f\u8fd9\u4e00\u5757\u2026<br \/>\n\u603b\u4e4b\uff0c\u56e0\u4e3a\u5b83\u5df2\u7ecf\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\uff0c\u6240\u4ee5\u5c31\u7b97\u4e86\u5427\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u5728GCE\u4e0a\u521b\u5efa\u4e86\u4e00\u4e9b\u5b9e\u4f8b\uff0c\u6839\u636e\u5176\u89d2\u8272\u8fdb\u884c\u7ba1\u7406\uff0c\u4f8b\u5982api\uff0cweb\uff0cdb\uff0cstaging\uff0cproduction [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-43572","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>\u6211\u4f7f\u7528GCE\u8bd5\u7740\u4f7f\u7528Prometheus - 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\/\u6211\u4f7f\u7528gce\u8bd5\u7740\u4f7f\u7528prometheus\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6211\u4f7f\u7528GCE\u8bd5\u7740\u4f7f\u7528Prometheus\" \/>\n<meta property=\"og:description\" content=\"\u6211\u5728GCE\u4e0a\u521b\u5efa\u4e86\u4e00\u4e9b\u5b9e\u4f8b\uff0c\u6839\u636e\u5176\u89d2\u8272\u8fdb\u884c\u7ba1\u7406\uff0c\u4f8b\u5982api\uff0cweb\uff0cdb\uff0cstaging\uff0cproduction [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u6211\u4f7f\u7528gce\u8bd5\u7740\u4f7f\u7528prometheus\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-30T05:42:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-15T03:43:32+00:00\" \/>\n<meta name=\"author\" content=\"\u79d1, \u9896\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u9896\" \/>\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\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/\",\"name\":\"\u6211\u4f7f\u7528GCE\u8bd5\u7740\u4f7f\u7528Prometheus - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-05-30T05:42:43+00:00\",\"dateModified\":\"2024-01-15T03:43:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6211\u4f7f\u7528GCE\u8bd5\u7740\u4f7f\u7528Prometheus\"}]},{\"@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\/8ca01ba7f7362ad4edb7da206a12f29e\",\"name\":\"\u79d1, \u9896\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u9896\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keying\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u6211\u4f7f\u7528GCE\u8bd5\u7740\u4f7f\u7528Prometheus - 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\/\u6211\u4f7f\u7528gce\u8bd5\u7740\u4f7f\u7528prometheus\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u6211\u4f7f\u7528GCE\u8bd5\u7740\u4f7f\u7528Prometheus","og_description":"\u6211\u5728GCE\u4e0a\u521b\u5efa\u4e86\u4e00\u4e9b\u5b9e\u4f8b\uff0c\u6839\u636e\u5176\u89d2\u8272\u8fdb\u884c\u7ba1\u7406\uff0c\u4f8b\u5982api\uff0cweb\uff0cdb\uff0cstaging\uff0cproduction [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u6211\u4f7f\u7528gce\u8bd5\u7740\u4f7f\u7528prometheus\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-05-30T05:42:43+00:00","article_modified_time":"2024-01-15T03:43:32+00:00","author":"\u79d1, \u9896","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u9896","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/","name":"\u6211\u4f7f\u7528GCE\u8bd5\u7740\u4f7f\u7528Prometheus - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-05-30T05:42:43+00:00","dateModified":"2024-01-15T03:43:32+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u6211\u4f7f\u7528GCE\u8bd5\u7740\u4f7f\u7528Prometheus"}]},{"@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\/8ca01ba7f7362ad4edb7da206a12f29e","name":"\u79d1, \u9896","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g","caption":"\u79d1, \u9896"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keying\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%88%91%e4%bd%bf%e7%94%a8gce%e8%af%95%e7%9d%80%e4%bd%bf%e7%94%a8prometheus%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/43572","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\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=43572"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/43572\/revisions"}],"predecessor-version":[{"id":59160,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/43572\/revisions\/59160"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=43572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=43572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=43572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}