[[["易于理解","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-08-17。"],[],[],null,["# Monitor topics within Pub/Sub\n\nYou can use the Google Cloud console to access the monitoring dashboard\nfor a single topic or all the topics available in your project.\n| **Key Point:** Learn how to access the monitoring dashboard for Pub/Sub topics, understand some key metrics, and learn how to create a custom monitoring experience.\n\nBefore you begin\n----------------\n\nEnsure that you've prepared the following:\n\n- A Cloud Billing account\n\n- A Pub/Sub project with billing enabled\n\n- At least one topic in your Pub/Sub project\n\n- Familiarity with [Cloud Monitoring](/monitoring/docs/monitoring-overview)\n and [Metrics Explorer](/monitoring/mql)\n\nView the monitoring dashboard for all topics\n--------------------------------------------\n\nTo view the monitoring dashboard for all the topics\nin a project, perform the following steps:\n\n1. In the Google Cloud console, go to the Pub/Sub **Topics** page.\n\n [Go to Topics](https://console.cloud.google.com/cloudpubsub/topic)\n2. Click the **Metrics** tab.\n\n The monitoring dashboard is displayed for all topics in the project.\n\nThe monitoring dashboard has two sections: **Overview** and **Quota**.\n\nView the monitoring dashboard for a single topic\n------------------------------------------------\n\nTo view the monitoring dashboard for a single topic\nin a project, perform the following steps:\n\n1. In the Google Cloud console, go to the Pub/Sub **Topics** page.\n\n [Go to Topics](https://console.cloud.google.com/cloudpubsub/topic)\n2. In the **Topics** page, click any topic.\n\n The topic details page is displayed.\n3. Within the topic details page, click the **Metrics** tab.\n\n The monitoring dashboard is displayed for the single topic.\n\nThe monitoring dashboard has three sections: **Overview** , **Subscriptions** ,\nand **Retention** . You can see the **Retention** section only if you\nenable message retention for the topic. For more information about message\nretention, see [Properties of a topic](/pubsub/docs/admin#properties_of_a_topic).\n\nCustomize the monitoring dashboard\n----------------------------------\n\nYou can create a custom dashboard or add individual charts to an\nexisting custom dashboard.\n\nTo create a custom dashboard, perform the following steps:\n\n1. Follow the steps to go to the monitoring page for [all topics](#monitor_all_topics) or for\n a [single topic](#monitor_topic).\n\n2. Choose one of the following options:\n\n - To create a new dashboard containing all the charts, or to add all the\n charts to an existing custom dashboard, click **Save as custom dashboard**.\n\n - To add a single chart to a new or custom dashboard, in an individual chart,\n expand the more_vert\n **More Actions** option and click **Add to custom dashboard**.\n\nYou can view all your dashboards in the [Monitoring](https://console.cloud.google.com/monitoring/dashboards/) console.\n\nModify a chart\n--------------\n\nTo modify a chart, perform the following steps:\n\n1. Follow the steps to go to the monitoring page for [all topics](#monitor_all_topics) or for\n a [single topic](#monitor_topic).\n\n2. In an individual chart, expand the more_vert\n **More Actions** option and click **View in Metrics Explorer**.\n\n The chart opens in **Metrics Explorer**.\n3. You can use [Monitoring Query Language](/monitoring/mql) queries to make changes to your\n chart and test the output.\n\n4. Click **Save chart** to save the changes.\n\nCreate an alerting policy\n-------------------------\n\nCreating an alerting policy for a chart lets you set up an alert monitoring\nmetric in the chart, configure the circumstances under which you want to be\nalerted, and configure how you want to be notified.\n\nFor more information about how to create alerts, see [Create metric-based alert policies](/monitoring/alerts/using-alerting-ui).\n\nSome charts might not offer a **Create alerting policy** option.\nIn this case, perform the following steps:\n\n1. Save the chart to a custom dashboard.\n\n2. In the custom dashboard, for the individual chart, expand\n the more_vert **More Actions** option.\n\n3. Click **Convert to alert chart**.\n\nKey charts to monitor topics\n----------------------------\n\nAlthough there are a number of charts available to monitor a single topic,\nthe following charts in the **Overview** section are a good starting point:\n\n- The **Publish requests** chart lets you check if there are sudden spikes\n in the topic for receiving publish requests.\n\n- The **Average number of messages per batch** chart lets you check\n if the batching size is adequate for your requirements. A smaller batch size\n leads to reduced publish latency.\n\nThe following charts in the **Quota** section for all topics help you monitor quotas\nfor all the topics in your project:\n\n- The **Administrator operations** chart lets you monitor administrative operations regarding topics. Each administrator operation charges one unit against this quota.\n\nFor more information, see [Pub/Sub quotas and limits](/pubsub/quotas).\n\nMetrics to monitor import topics\n--------------------------------\n\nYou can use the following metrics to monitor import topics:\n\n- [**Ingestion byte count**](/monitoring/api/metrics_gcp_p_z#pubsub/topic/ingestion_byte_count):\n This metric displays the\n total volume of data (in bytes) ingested from an import source into an\n import topic. It provides a breakdown of byte counts for each import\n source and partition (shard).\n\n- [**Ingestion message count**](/monitoring/api/metrics_gcp_p_z#pubsub/topic/ingestion_message_count):\n This metric displays\n the total number of import messages for each import source and partition.\n\n- [**Ingestion data source state**](/monitoring/api/metrics_gcp_p_z#pubsub/topic/ingestion_data_source_state):\n This metric\n displays the state of the external source from which the import topic is\n ingesting data. The error codes and their workarounds are listed in the\n troubleshooting section of the import topics.\n For more information, see the following:\n\n - [Troubleshooting Amazon Kinesis Data Streams import topics](/pubsub/docs/aws-kinesis-import-topic-troubleshooting).\n - [Troubleshooting Cloud Storage import topics](/pubsub/docs/cloud-storage-import-topic-troubleshooting).\n - [Troubleshooting Amazon MSK import topics](/pubsub/docs/amazon-msk-import-topic-troubleshooting).\n - [Troubleshooting Azure Event Hubs import topics](/pubsub/docs/azure-event-hub-import-topic-troubleshooting).\n - [Troubleshooting Confluent Cloud import topics](/pubsub/docs/confluent-cloud-import-topic-troubleshooting).\n- [**Ingestion failure count**](/monitoring/api/metrics_gcp_p_z#pubsub/topic/ingestion_failure_count):\n This metric displays the number of failures encountered during ingestion.\n For Cloud Storage import topics, this metric includes the bucket\n name and the failure reason. For Amazon MSK, Azure Event Hubs, and Confluent\n Cloud import topics, this metric includes the Kafka topic or event hub name,\n the partition, and the failure reason.\n\nTo check these metrics, follow the steps described in\n[View the monitoring dashboard for a single topic](#monitor_topic).\n\nWhat's next\n-----------\n\n- To monitor subscriptions,\n see [Monitor subscriptions in Pub/Sub](/pubsub/docs/monitor-subscription).\n\n- To learn more about using MQL to build\n monitoring charts, see [Using the Query Editor](/monitoring/mql/query-editor)."]]