本文档介绍如何配置Google Cloud 项目的指标范围,以便与 Google Cloud Managed Service for Prometheus 搭配使用。
理想的 Managed Service for Prometheus 部署必然与典型的 Prometheus 部署有所不同。Prometheus 高度局限于它自己的实例(该实例本身通常在集群范围内),因为规则和查询在收集数据的 Prometheus 服务器上运行。由于 Managed Service for Prometheus 会将数据发送到全局后端 (Monarch),因此您必须将查询配置为针对 Monarch(而非本地集群)执行。如果您使用代管式集合,则同一要求也适用于规则。
无论您如何查询数据,使用 Managed Service for Prometheus 查询的数据都由 Cloud Monitoring 构造指标范围决定。
指标范围
Monitoring 指标范围是一种只读结构,可让您查询属于多个 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-09-04。"],[],[],null,["# Configuring your metrics scopes\n\nThis document describes how to configure the metrics scopes of your\nGoogle Cloud projects for use with Google Cloud Managed Service for Prometheus.\n\nThe ideal Managed Service for Prometheus deployment is different from the\ntypical Prometheus deployment by necessity. Prometheus is highly scoped to\nits own instance---which is itself typically cluster-scoped---in that\nrules and queries run on the Prometheus server that collects the data.\nBecause Managed Service for Prometheus sends data to the global backend,\n[Monarch](https://research.google/pubs/pub50652/), queries must be configured to execute against\nMonarch, not the local cluster. If you are using managed collection,\nthen the same requirement applies to rules.\n\nThe data you query using Managed Service for Prometheus is determined\nby the Cloud Monitoring construct *metrics scope*, regardless of\nhow you query the data.\n\nMetrics scopes\n--------------\n\nA Monitoring metrics scope is a read-time-only construct that\nlets you query metric data belonging to multiple Google Cloud projects. Every\nmetrics scope is hosted by a designated Google Cloud project, called the\n*scoping project*.\n\nBy default, a project is the scoping project for its own metrics scope,\nand the metrics scope contains the metrics and configuration for that\nproject. A scoping project can have more than one monitored project in its\nmetrics scope, and the metrics and configurations from all the monitored\nprojects in the metrics scope are visible to the scoping project. A\nmonitored project can also belong to more than one metrics scope.\n\nWhen you query the metrics in a scoping project, and if that\nscoping project hosts a multi-project metrics scope, you can retrieve\ndata from multiple projects. If your metrics scope contains all your\nprojects, then your queries and rules evaluate globally.\n\nFor more information about scoping projects and metrics scope,\nsee [Metrics scopes](/monitoring/settings#concept-scope). For information about configuring\nmulti-project metrics scope, see [View metrics for multiple\nprojects](/monitoring/settings/multiple-projects).\n\nTo minimize the complexity of your permissions model, use as few metrics\nscopes as possible. If you do not consider your metric data to be sensitive\nand it is acceptable for all users to be able to access all metrics,\nthen use a single metrics scope that contains all your projects.\n\nGrouping projects together for querying\n---------------------------------------\n\nThe other best-practice scenarios use the following metrics-scope\nconfigurations:"]]