Managed Service for Prometheus のクエリ インターフェースはすべて、Cloud Monitoring API を使用して Monarch からデータを取得するように構成されています。ローカルの Prometheus サーバーからデータをクエリする代わりに Monarch をクエリすることにより、グローバルなモニタリングを大規模に実施できます。
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"]],["最終更新日 2025-09-04 UTC。"],[],[],null,["# Query using Cloud Monitoring\n\nAfter you have deployed Google Cloud Managed Service for Prometheus,\nyou can query the data sent to the managed service and\ndisplay the results in charts and dashboards.\n\nThis document describes *metrics scopes*, which determine the\ndata you can query, and how to use Cloud Monitoring to retrieve and use the\ndata you've collected.\n\nAll query interfaces for Managed Service for Prometheus are configured to\nretrieve data from Monarch using the Cloud Monitoring API. By\nquerying Monarch instead of querying data from\nlocal Prometheus servers, you get global monitoring at scale.\n\nBefore you begin\n----------------\n\nIf you have not already deployed the managed service,\nthen set up [managed collection](/stackdriver/docs/managed-prometheus/setup-managed) or [self-deployed\ncollection](/stackdriver/docs/managed-prometheus/setup-unmanaged). You can skip this if you're only interested in\n[querying Cloud Monitoring metrics using PromQL](/stackdriver/docs/managed-prometheus/promql).\n\nQueries and metrics scopes\n--------------------------\n\nThe data you can query is determined by the Cloud Monitoring construct\n*metrics scope*, regardless of the method you use to query the data.\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\nManaged Service for Prometheus data in Cloud Monitoring\n-------------------------------------------------------\n\nManaged Service for Prometheus shares the data-storage backend,\nMonarch, with\nCloud Monitoring. You can use all of the tools provided by\nCloud Monitoring with the data collected by\nManaged Service for Prometheus. For example, you can use\n[Metrics Explorer](/monitoring/charts/metrics-explorer), as described in\n[Google Cloud console for Monitoring](#ui-monitoring),\nand you can set alerts based on these metrics. You can also\n[import your Grafana dashboards into Cloud Monitoring](/stackdriver/docs/managed-prometheus/import-grafana-dashboards).\n\nWhen working with metric data, including data from\nManaged Service for Prometheus, in\nCloud Monitoring, you can use the query tools provided by\nCloud Monitoring:\n\n- [PromQL](/monitoring/promql)\n- [Monitoring Query Language (MQL)](/monitoring/mql)\n- [Monitoring filters](/monitoring/api/v3/filters)\n\n### Querying using PromQL in Cloud Monitoring\n\nThe simplest way to query your Prometheus data is to use the Cloud Monitoring\nMetrics Explorer page in the Google Cloud console. To verify that your\nPrometheus data is being collected correctly, do the following:\n\n1. In the Google Cloud console, go to the\n *leaderboard* **Metrics explorer** page:\n\n [Go to **Metrics explorer**](https://console.cloud.google.com/monitoring/metrics-explorer)\n\n \u003cbr /\u003e\n\n If you use the search bar to find this page, then select the result whose subheading is\n **Monitoring**.\n2. In the toolbar of the\n query-builder pane, select the button whose name is either\n *code* **MQL** or *code* **PromQL**.\n\n3. Verify that **PromQL** is selected\n in the **Language** toggle. The language toggle is in the same toolbar that\n lets you format your query.\n\n4. Enter the following query into the editor,\n and then click **Run query**:\n\n ```\n up\n ```\n\nIf your data is being ingested, then you see a chart like the following:\n\nFor information about how to query Cloud Monitoring system metrics using\nPromQL, see [PromQL for Cloud Monitoring metrics](/stackdriver/docs/managed-prometheus/promql).\n\nFor more information about using PromQL in Metrics Explorer and\nCloud Monitoring charts,\nsee [PromQL in Cloud Monitoring](/monitoring/promql).\n\n\u003cbr /\u003e\n\n| **Note:** You can create Cloud Monitoring alerting policies based on PromQL queries and Prometheus alert rules. For more information, see [Alerting policies with PromQL](/monitoring/promql/promql-in-alerting).\n\n### Other query options in Cloud Monitoring\n\nTo view your Prometheus data as Cloud Monitoring\ntime series and to create charts and dashboards, you can also use\nthe menu-driven interfaces or MQL. The following shows a simple\nquery in Metrics Explorer:\n\n1. In the Google Cloud console, go to the\n *leaderboard* **Metrics explorer** page:\n\n [Go to **Metrics explorer**](https://console.cloud.google.com/monitoring/metrics-explorer)\n\n \u003cbr /\u003e\n\n If you use the search bar to find this page, then select the result whose subheading is\n **Monitoring**.\n2. Specify the data to appear on the chart. In addition to using the\n **PromQL** button described previously, you can also use the menu-driven\n interface. To construct a query, do the following:\n\n 1. Within the query-builder pane, click \"Select a metric\".\n\n 2. In the search field, type \"up/\" to filter the list, then\n select **Prometheus Target** , then select **Up** , then select\n **Prometheus/up/gauge**.\n\n 3. Click \"Apply\".\n\nThe chart that results from this query shows the same data as\nthe chart shown in the PromQL example.\n\nQueries created using the menu-driven interface can be converted to PromQL\nby selecting the **PromQL** button. This translation might not correctly\nconvert histogram functions or other uncommon operators.\n\n### The `prometheus_target` resource\n\nIn Cloud Monitoring, time-series data is written against a monitored-resource\ntype. For Prometheus metrics, the monitored-resource type is\n[`prometheus_target`](/monitoring/api/resources#tag_prometheus_target). Monitoring queries for\nPrometheus metrics *that are not written in PromQL*\nmust specify this resource type.\n\nThe `prometheus_target` resource has the following labels, which you can\nuse for filtering and manipulating queried data:\n\n\n- `project_id`: The identifier of the Google Cloud project associated with this resource.\n- `location`: The physical location (Google Cloud region) where the data is stored. This value is typically the region of your GKE cluster or Compute Engine instance. If data is collected from an AWS or on-premises deployment, then the value might be the closest Google Cloud region.\n- `cluster`: The GKE cluster or related concept; might be empty.\n- `namespace`: The GKE namespace or related concept; might be empty.\n- `job`: The job label of the Prometheus target, if known; might be empty for rule-evaluation results.\n- `instance`: The instance label of the Prometheus target, if known; might be empty for rule-evaluation results.\n\nThe values for these labels are set during collection.\n\n\nWhat's next\n-----------\n\n- [Set up PromQL alerts using Cloud Monitoring](/monitoring/promql/promql-in-alerting).\n- [Import Grafana dashboards into Cloud Monitoring](/stackdriver/docs/managed-prometheus/import-grafana-dashboards)."]]