[[["易于理解","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-28。"],[],[],null,["# Explore synthetic monitor results\n\nThis document describes how you explore the execution history of your\nsynthetic monitors, and it also describes how to view the collected metrics and\nlogs.\n\nThis feature is supported only for Google Cloud projects.\nFor [App Hub](/app-hub/docs/overview)\nconfigurations, select the App Hub host project or\nthe app-enabled folder's management project.\n\nBefore you begin\n----------------\n\nComplete the following in the Google Cloud project that stores your synthetic monitor:\n\n-\n\n To get the permissions that\n you need to view synthetic monitors execution results by using the Google Cloud console,\n\n ask your administrator to grant you the\n following IAM roles on your project:\n\n - [Monitoring Viewer](/iam/docs/roles-permissions/monitoring#monitoring.viewer) (`roles/monitoring.viewer`)\n - [Cloud Functions Developer](/iam/docs/roles-permissions/cloudfunctions#cloudfunctions.developer) (`roles/cloudfunctions.developer`)\n - [Logs Viewer](/iam/docs/roles-permissions/logging#logging.viewer) (`roles/logging.viewer`)\n\n\n For more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\n You might also be able to get\n the required permissions through [custom\n roles](/iam/docs/creating-custom-roles) or other [predefined\n roles](/iam/docs/roles-overview#predefined).\n\nView execution history for a synthetic monitor\n----------------------------------------------\n\nTo understand the history of passing and failing executions, view the\n**Synthetic monitor details** page for the synthetic monitor:\n\n1. In the Google Cloud console, go to the\n **Synthetic monitoring** page:\n\n [Go to **Synthetic monitoring**](https://console.cloud.google.com/monitoring/synthetic-monitoring)\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 Google Cloud console, select your Google Cloud project. For [App Hub](/app-hub/docs/overview) configurations, select the App Hub host project or the app-enabled folder's management project.\n3. To open the **Synthetic monitor details** page, locate the synthetic monitor that you want to view, and then click its name.\n\nThe **Synthetic monitor details** page lists summary information, such as\nthe success rate and duration and the most recent status. This page also charts\nthe recorded duration of the execution and it contains a table that displays\none row for each execution.\n\nEach row in the table lists the status, date, duration, and it links to a\npage that displays the current code and logs relevant to that execution.\n\nView logs and traces for an execution\n-------------------------------------\n\nTo view the logs, traces, and summary information for an execution,\non the **Synthetic monitor details** page, click the link to the execution.\nFrom this page, you can do the following:\n\n- [View log data](#log-data).\n- [View trace data](#trace-data).\n- View the *current* code.\n\n | **Note:** Cloud Run functions stores one copy of your code. When you view the results for any execution, the displayed code is the *current* code and it might not be relevant to the specific execution.\n- Access the Cloud Run function.\n\n- For [Mocha](https://mochajs.org/) test, view results for each test. For example,\n if your synthetic monitor contains four Mocha tests,\n then the **Test results** pane contains four entries.\n Each entry in the list is annotated as a pass or fail.\n\n If you select an entry marked as failed, then the failing code is displayed\n and highlighted.\n\n### View log data\n\nLogs are automatically collected by Cloud Monitoring. These logs contain\ninformation about the test and failure details. The available logs depend on\nyour Cloud Run function. For example, if you use\n[Mocha](https://mochajs.org/), then the\nlogs include information about whether the test passed or failed, test\nduration, and, in the case of failure, a full stack trace. The\nstack trace includes the line of code that failed, error types, and\nerror messages.\n\nTo view details of your related logs, in the **Execution logs** pane,\nexpand a log entry.\n\nThe log entry is displayed in JSON format. If you prefer to view the\nlogs with the Logs Explorer, then click **Open in Logs Explorer**.\nThe Logs Explorer is opened and a query is preconfigured.\n\n### View trace data\n\nTrace data is collected when your Cloud Run function\nexecutes. To view trace data, use the Google Cloud console or the Cloud Trace API to\nview trace data. \n\n### Console\n\n\nTo view your trace data, do one of the following:\n\n- To view summary information for a trace, in the toolbar of the details page\n for an execution, click **View trace details**.\n\n The **Details** panel opens and displays a Gantt chart with information\n about each span, which is a record of an operation, in the trace. For\n complete information about the trace and its spans, click\n **View in Cloud Trace** , which opens the **Trace Explorer** page.\n- View your traces in Cloud Trace:\n\n 1. In the Google Cloud console, go to the **Trace explorer** page:\n\n [Go to **Trace explorer**](https://console.cloud.google.com/traces/explorer)\n\n \u003cbr /\u003e\n\n You can also find this page by using the search bar.\n 2. In the toolbar of the Google Cloud console, select your Google Cloud project. For [App Hub](/app-hub/docs/overview) configurations, select the App Hub host project or the app-enabled folder's management project.\n 3. In the heatmap chart or in the table, select a trace.\n\nYour trace and spans can include circles in the timeline that represent log\nentries or events that occurred during execution. Click the circle to\ndisplay information about the log entry or event. To identify a\nCloud Run function in a log entry, view the `resource.labels.service_name`\nfield.\n\nFor more information about exploring your trace data, see\n[Find and explore traces](/trace/docs/finding-traces).\n\n\u003cbr /\u003e\n\n### API\n\nWe recommend that you use the Google Cloud console to view trace data.\nHowever, if you want to use the Cloud Trace API, use the\n[`traces.list` method](/trace/docs/reference/v1/rest/v1/projects.traces/list) to list the available traces,\nand then use the\n[`traces.get` method](/trace/docs/reference/v1/rest/v1/projects.traces/get) to get the details of a trace.\n\nView logs and metrics for a Cloud Run function\n----------------------------------------------\n\nLogs and metrics provide you with information about the actions your\nCloud Run function is performing. For example, logs that contain a\nfield named `userAgent` with a value of\n`GoogleStackdriverMonitoring-UptimeChecks`, indicate that your service\nreceived a request from the uptime check service.\n\nThe remainder of this section describes how to view the logs and metrics\ncollected by Cloud Run functions.\n\n### View function logs\n\n### Console\n\n\nTo view Cloud Run function logs, do the following:\n\n1. In the pane with the name of your synthetic monitor, click the Cloud Run function name.\n2. On the **Function details** page, select the **Logs** tab.\n\nTo explore the log data in a chart in more detail, expand a log entry and then\nselect **Open in Logs Explorer** .\nFrom the [Logs Explorer](/logging/docs/view/logs-explorer-interface), you can\nperform actions such as refining the query, creating a\n[log-based metric](/logging/docs/logs-based-metrics), or\ncreate a [log-based alert](/logging/docs/alerting/log-based-alerts).\n\n\u003cbr /\u003e\n\n### API\n\nFor information about how to read and write Cloud Run function\nlogs programmatically, see\n[Writing, Viewing, and Responding to Logs](/functions/docs/monitoring/logging).\n\n### View function metrics\n\nFor synthetic monitors, metrics are collected by both Cloud Monitoring and\nCloud Run functions:\n\n- Cloud Monitoring collects metrics about each execution of a\n synthetic monitor. These metrics include the latency of the code execution and\n the success history. For information about how to view these metrics, see\n [View execution history for a synthetic monitor](#history).\n\n- Cloud Run functions collects metrics about each Cloud Run function. These\n metrics record the execution time, the memory utilization, the instance\n count, and the number of invocations per section. The remainder of\n this section describes how to view these metrics.\n\n### Console\n\n\nTo view Cloud Run function metrics, do the following:\n\n1. In the pane with the name of your synthetic monitor, click the Cloud Run function name.\n2. On the **Function details** page, select the **Metrics** tab.\n\nTo zoom into a specific time range, do the following:\n\n1. On a chart, place your pointer at one end of the time range and then left-click your pointer.\n2. Drag your pointer horizontally to the other end of the time range, and then release the pointer button.\n\nTo explore the displayed data in a chart in more detail,\non the chart toolbar, select *more_vert* **More chart options**,\nand then make a selection. The options include the following:\n\n- Download the chart as a PNG or CSV\n- Save the chart to a custom dashboard\n- Open Metrics Explorer\n- Expand or collapse the chart legend\n- Reset the zoom\n\n\u003cbr /\u003e"]]