本文档介绍了 Cloud Monitoring 如何确定 Google Cloud 项目可以绘制图表和监控的时序数据。如果您只想对 Google Cloud 项目收集的时序数据绘制图表并进行监控,则无需执行任何配置。我们建议您完成 Compute Engine 快速入门。但是,如果您想对多个 Google Cloud 项目收集的时序数据绘制图表并进行监控,则需要进行一些配置。本文档介绍了数据模型和最佳实践。如需了解配置信息,请参阅后续步骤部分中列出的文档。
数据模型
本部分将介绍资源容器、指标范围和范围项目的概念。
资源容器
资源容器是 Google Cloud 项目。资源容器会存储该容器所使用的服务和配额的时序数据。资源容器存储的时序数据包括标识资源容器的标签。查看存储在多个资源容器中的数据时,您可以按该标签进行过滤和分组。
指标范围
Google Cloud 项目的指标范围定义项目可以对其时序数据绘制图表并进行监控的资源容器集。受监控的数据包括您所构建并与 SLO 和提醒政策相关联的服务。默认情况下, Google Cloud 项目的指标范围仅包含该项目。因此,除非您配置指标范围,否则 Google Cloud 项目只能对其存储的时序数据绘制图表并进行监控。您可以使用 Google Cloud 控制台、Google Cloud CLI 和 Cloud Monitoring API 修改指标范围中包含的资源容器的列表。
限定范围的项目
范围项目托管指标范围。范围项目会存储您配置的提醒政策、拨测、信息中心、合成监控工具、服务和监控组。每个 Google Cloud 项目都托管一个指标范围,因此每个项目也是一个范围限定项目。使用 Google Cloud 控制台时,范围限定项目是 Google Cloud 控制台项目选择器选择的项目。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-29。"],[],[],null,["# Metrics scopes overview\n\nThis document describes how [Cloud Monitoring](/monitoring/docs/monitoring-overview)\ndetermines what time-series data your Google Cloud project can chart\nand monitor. If you only want to chart and monitor the time-series data\ncollected by your Google Cloud project, then\nyou don't need to perform any configuration. We recommend completing the\n[Compute Engine quickstart](/monitoring/monitor-compute-engine-virtual-machine).\nHowever, if you want to chart and monitor the time-series data collected by\nmultiple Google Cloud projects,\nthen some configuration is required.\nThis document introduces the data model and best practices.\nFor configuration information, see the documents listed in the\n[What's next](#whats-next) section.\n\nData model\n----------\n\nThis section introduces the concepts of a resource container,\na metrics scope, and a scoping project.\n\nResource container\n: A *resource container* is a Google Cloud project.\n Resource containers store time-series data for\n the services and quota used by that container. The time-series data stored by\n a resource container includes a label\n that identifies the resource container. When viewing data stored in multiple\n resource containers, you can filter and group by that label.\n\nMetrics scope\n: The *metrics scope* of a Google Cloud project defines the set\n resource containers whose time-series data the project can chart and monitor.\n The monitored data includes the [services](/stackdriver/docs/solutions/slo-monitoring/ui/define-svc) that you construct and\n associate with SLOs and alerting policies.\n By default, the metrics scope of a Google Cloud project only includes that\n project. Therefore, unless you configure the metrics scope,\n a Google Cloud project can only chart and monitor the time-series data it stores.\n You can use the Google Cloud console, the Google Cloud CLI, and the\n Cloud Monitoring API to modify the list of resource containers that are\n included in a metrics scope.\n\nScoping project\n: A *scoping project* hosts a metrics scope. The scoping project\n stores the alerting policies,\n uptime checks, dashboards, synthetic monitors, [services](/stackdriver/docs/solutions/slo-monitoring/ui/define-svc),\n and monitoring groups that you configure.\n Because every Google Cloud project hosts a metrics scope,\n every project is also a scoping project. When you use the Google Cloud console,\n the scoping project is the project selected by the Google Cloud console project picker.\n\nApp Hub applications and metrics scopes\n---------------------------------------\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nYou manage the metrics scope for [App Hub](/app-hub/docs/overview)\nhost projects. You can manage this scope either by using the\n[Google Cloud console](/monitoring/settings/multiple-projects) or the\n[Cloud Monitoring API](/monitoring/settings/manage-api).\n\nGoogle Cloud manages the metrics scope for app-enabled folders, unless\nadding a project to the metrics scope fails due to exhaustion of the\nmetrics scope quota. In this case, you can request a quota increase and\nthen manually add projects to the metrics scope of the\nmanagement project for the app-enabled folder. To learn more, see\n[Metrics scopes for app-enabled folders](/monitoring/settings/metrics-scope-app-enabled-folders).\n\nExample metrics scope configuration\n-----------------------------------\n\nAssume that you have two projects, named `Staging` and `Production`,\nthat contain Compute Engine virtual machine (VM) instances. To view the\nmetrics for all of your VMs in a single view, you create\nanother project, `AllEnvironments`, and then add the `Staging` and `Production`\nprojects to the metrics scope of the project named `AllEnvironments`.\n\nWith this configuration, to create a chart that displays time-series data stored\nin the `Staging` project, your first step is to open the Google Cloud console and\nselect a project with the Google Cloud console project picker:\n\n- If you select `AllEnvironments`, then your chart can display\n time-series data stored by the `Staging` project along with\n time-series data stored by the `Production` and `AllEnvironments`\n projects. To view time-series data that is stored by the\n `Staging` project, you can add a filter.\n\n The dashed line in the following diagram shows the projects whose\n time-series data can be charted and monitored by the\n `AllEnvironments` project:\n\n- If you select `Staging`, then your chart displays\n time-series data stored by the `Staging` project.\n\nBest practices\n--------------\n\n- When you want to chart or monitor time-series data stored in multiple\n resource containers, we recommend that you use a new Google Cloud project\n or one without resources as the scoping project, because these\n projects don't store any time-series data.\n\n Consider a scenario where your scoping project contains resources\n such as VMs. To chart or monitor only the time-series data for the VMs\n in the scoping project, you must specify [filters](/monitoring/charts/selecting-aggregating-metrics#filter-option)\n to exclude the time series from VMs stored in monitored resource containers.\n The requirement to use filters increases the\n complexity of configuring a chart and an alerting policy, and it increases\n the possibility of a configuration error.\n- Consider using multiple scoping projects to control which teams have\n access to the time-series data stored in your projects. The following table\n illustrates a possible configuration:\n\nGrant access to Cloud Monitoring\n--------------------------------\n\nTo view the time-series data that can be charted or monitored by a project,\nyour Identity and Access Management (IAM) role on the\nproject must include all the permissions in the\nMonitoring Viewer (`roles/monitoring.viewer`) role.\n*You don't need any other permissions.*\nFor example, suppose the metrics scope of a scoping project\nmonitors three Google Cloud projects and that you have a role of\nMonitoring Viewer on the scoping project. When you access the\nscoping project by using the Google Cloud console,\nyou can view the time-series data stored in that project and the\ntime-series data stored in the other three Google Cloud projects.\n\nTo modify a metrics scope, your IAM roles on the\nscoping project and on each resource container that you\nwant to add must include all permissions in the\nMonitoring Admin (`roles/monitoring.admin`) role.\n\nFor more information, see\n[Control access with Identity and Access Management](/monitoring/access-control).\n\nPricing\n-------\n\nIn general, Cloud Monitoring system metrics are free, and metrics\nfrom external systems, agents, or applications are not. Billable metrics are\nbilled by either the number of bytes or the number of samples ingested.\n\nFor more information, see the Cloud Monitoring sections of the [Google Cloud Observability pricing](https://cloud.google.com/stackdriver/pricing) page.\n\nWhat's next\n-----------\n\n- [Metrics scopes for app-enabled folders](/monitoring/settings/metrics-scope-app-enabled-folders).\n- [Configure a metrics scope for projects](/monitoring/settings/multiple-projects).\n- [Configure a metrics scope by using the Cloud Monitoring API](/monitoring/settings/manage-api).\n- [Quotas and limits](/monitoring/quotas)."]]