Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
API-Monitoring
Auf dieser Seite wird beschrieben, wie Sie mithilfe der von API Gateway automatisch erfassten Logs und Messwerte den Zustand Ihrer API Gateway APIs beobachten können.
Wenn Sie eine API erstellen, wird in API Gateway automatisch ein entsprechender verwalteter Dienst erstellt. Den Namen des erstellten verwalteten Dienstes finden Sie in der Ausgabe des folgenden Befehls:
gcloud api-gateway apis describe API_ID
Der Name Ihres Dienstes ist der Wert des Felds managedService.
Wenn Nutzer Anfragen an Ihre API senden, protokolliert API Gateway Informationen über die Anfragen und Antworten. API Gateway verfolgt außerdem drei der vier goldenen Überwachungssignale: Latenz, Traffic und Fehler. Mit diesen Nutzungs- und Leistungsmesswerten können Sie Ihre API überwachen.
Hinweis
Wenn Sie Logs und Messwerte zur Ansicht generieren möchten, stellen Sie eine API bereit und senden Sie Anfragen an die API. Wenn Sie noch keine API erstellt und in einem Gateway bereitgestellt haben, sehen Sie sich die API Gateway-Kurzanleitung an.
API-Übersicht
Wenn Sie einen Fehler in Ihrem Dienst beheben oder einfach sicherstellen wollen, dass alles wie erwartet abläuft, rufen Sie die API-Übersicht auf.
Rufen Sie in der Google Cloud Console die Seite API Gateway > APIs für Ihr Projekt auf:
Wenn Sie mehr als eine API haben, klicken Sie auf die zu überwachende API.
Achten Sie darauf, dass Sie sich auf dem Tab Übersicht befinden.
Grafiken
Auf der Übersichtsseite finden Sie eine Reihe von Diagrammen für einige der Messwerte. So können Sie auf einen Blick Spitzenwerte, Rückgänge oder unerwartete Aktivitäten erkennen. Mit den Filtern oben auf der Seite können Sie Folgendes tun:
Wählen Sie in der Drop-down-Liste Grafiken auswählen die für Sie interessanten Messwerte aus und entfernen Sie die Messwerte, die nicht angezeigt werden sollen.
Sie können den Umfang der Grafiken anpassen, indem Sie verschiedene Zeitspannen auswählen. Die in der Grafik angezeigten Werte werden an die Zeitspanne angepasst und auch die Punktgranularität ändert sich.
Methodentabelle
Wenn Sie die Daten weiter aufschlüsseln möchten, scrollen Sie zur Tabelle unter den Grafiken. Sie enthält Messwerte für einzelne Methoden der API. Sie haben folgende Möglichkeiten:
Klicken Sie links oben in der Tabelle auf das Symbol Tabelle filtern, um im Drop-down-Menü Optionen für die erweiterte Filterabfrage auszuwählen. Fügen Sie zwischen den Filterabfragen ein OR ein, um nach mehreren Begriffen zu suchen.
Klicken Sie rechts oben in der Tabelle auf das Symbol Spaltenanzeigeoptionen, um eine Drop-down-Liste aufzurufen. Setzen Sie ein Häkchen bei den gewünschten Messwerten und entfernen Sie die Häkchen bei den Messwerten, die nicht angezeigt werden sollen.
Wählen Sie in der rechten oberen Ecke der Übersicht mit dem entsprechenden Auswahlelement eine Zeitspanne für die Messwerte in der Tabelle aus. Die ausgewählte Zeitspanne gilt sowohl für die Grafiken als auch für die Tabelle.
Logs
Wenn Sie ein Problem in den Messwerten feststellen, können Sie auf der Seite Log-Explorer in derGoogle Cloud Console die Protokolle der Anfragen und Antworten für Ihre API aufrufen.
Sie können Logs für einzelne Methoden der API aufrufen. Dafür klicken Sie in der Tabelle auf Logs ansehen.
Sie können Logs für alle Methoden der API aufrufen. Klicken Sie dafür in der unteren rechten Ecke auf Alle Logs ansehen.
So finden Sie API Gateway-Logs direkt in der Log-Explorer-Seite:
Rufen Sie in der Google Cloud Console die Seite Log-Explorer auf:
Machen Sie sich zuerst mit der Log-Explorer vertraut.
Im Abfragebereich können Sie die anzuzeigenden Logeinträge einschränken. Sie können beispielsweise angeben, dass alle Anfragen mit einer Latenz von mehr als 300 Millisekunden ausgegeben werden sollen.
Senken konfigurieren und verwalten
Sie können Logs an BigQuery streamen und dort weitere Analysen vornehmen, die unbearbeiteten Logs in Cloud Storage speichern oder die Logs an Messaging-Themen in Pub/Sub senden.
Nach einem bestimmten Nutzerprojekt filtern
So filtern Sie Messwerte für ein bestimmtes Nutzerprojekt:
Rufen Sie die Projektnummer des API-Nutzerprojekts ab. Wenn Sie keine Berechtigung für den Zugriff auf das API-Nutzerprojekt haben, bitten Sie eine berechtigte Person, die Projektnummer für Sie zu ermitteln.
Rufen Sie in der Google Cloud Console die Seite API Gateway > APIs für Ihr Projekt auf.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-03 (UTC)."],[[["\u003cp\u003eAPI Gateway automatically maintains logs and metrics for monitoring API health, including latency, traffic, and errors, and creates a managed service for each created API.\u003c/p\u003e\n"],["\u003cp\u003eThe API overview page displays graphs for various metrics, which can be customized and filtered by time span and specific metrics.\u003c/p\u003e\n"],["\u003cp\u003eThe methods table allows for in-depth examination of individual API methods, with options to filter queries, adjust displayed metrics, and select a time span.\u003c/p\u003e\n"],["\u003cp\u003eThe Logs Explorer can be used to view detailed logs of requests and responses for your API, either for specific methods or for all methods.\u003c/p\u003e\n"],["\u003cp\u003eMetrics can be filtered to show data from a specific consumer project by entering the project number in the "Filter by Project Number" field.\u003c/p\u003e\n"]]],[],null,["# Monitoring your API\n===================\n\nThis page describes how you can monitor the health of your API Gateway APIs using the logs and metrics that API Gateway maintains for you automatically.\n\nWhen you create an API, API Gateway automatically creates a corresponding [managed service](/service-infrastructure/docs/overview#creating_apis_and_services). The name of the managed service created can be found in the output of the following command: \n\n```\ngcloud api-gateway apis describe API_ID\n```\n\nThe name of your service is the value of the `managedService` field.\n\nWhen users make requests to your API, API Gateway logs information about\nthe requests and responses. API Gateway also tracks three of the\n[four golden signals of monitoring](https://landing.google.com/sre/book/chapters/monitoring-distributed-systems.html#xref_monitoring_golden-signals):\nlatency, traffic, and errors. These usage and performance metrics help you monitor\nyour API.\n\nBefore you begin\n----------------\n\nTo generate logs and metrics for viewing, deploy an API and send requests to it. If you have not created and deployed an API to a gateway yet, try the\n[API Gateway quickstart](/api-gateway/docs/quickstart).\n\nAPI overview\n------------\n\nWhen you are debugging an issue with your service or just want to ensure that\neverything is running as expected, go to your API's overview:\n\n1. In the Google Cloud console, go to the **API Gateway** \\\u003e **APIs** page for\n your project:\n\n [Go to APIs](https://console.cloud.google.com/api-gateway/api)\n2. If you have more than one API, click the one you want to monitor.\n\n3. Ensure you are on the **Overview** tab.\n\n### Graphs\n\nThe overview page provides a number of graphs for some of the metrics, so you can spot any spikes, drops, or unexpected activity right away. Using the filters at the top of the page, you can:\n\n- Use the **Select graphs** drop-down list to show graphs for metrics you are interested in, and remove the ones you don't want to view.\n- Adjust the scope of the graphs by selecting from the various time spans. This adjusts the time range of values displayed, which also alters the point granularity.\n\n### Methods table\n\nWhen you are ready to drill down further, scroll below the graphs for a table\nwith metrics for individual methods in your API. You can:\n\n- In the top-left corner of the table, click the **Filter Table** icon to select refined filter query options from the drop-down table. Add an `OR` between each filter query to search for multiple terms.\n- In the top-right corner of the table, click the **Column Display Options** icon to display a drop-down list. Check the metrics you are interested in and clear the ones you don't want displayed.\n- In the top-right corner of the **Overview** page, select a time span for the metric values in the table by using the time span picker. This picks a time span for both the graphs and the table.\n\n### Logs\n\nWhen you spot an issue in the metrics, you can use the **Logs Explorer** page in the\nGoogle Cloud console to see logs of the requests and responses for your API.\n\n- To see logs for individual methods of your API, in the table click\n **View logs**.\n\n- To see logs for all methods in your API, in the bottom-right corner click\n [**View all logs**](https://console.cloud.google.com/logs/query).\n\n- To locate API Gateway logs directly from the Logs Explorer page:\n\n 1. In the Google Cloud console, go to the **Logs Explorer**\n page:\n\n [Go toLogs Explorer](https://console.cloud.google.com/logs/query)\n 2. Select **Produced API, \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e** , where\n \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e is the name of the\n managed service.\n\nSee the\n[API Gateway logs reference](/api-gateway/docs/audit-logging)\nfor details on the structure of the logs in the Logs Explorer.\n\nLearn what else you can do with the logs:\n\n- Get started using the\n [Logs Explorer](/logging/docs/view/logs-explorer-interface).\n\n Use the query pane to specify the set of log entries that you want to view,\n such as getting all requests with a latency greater than 300 milliseconds.\n- [Configure and manage sinks](/logging/docs/export/configure_export_v2).\n This lets you stream logs to BigQuery for further analysis, save the\n raw logs to Cloud Storage, or send them to Pub/Sub messaging\n topics.\n\n### Filter for a specific consumer project\n\nTo filter metrics for a specific consumer project:\n\n1. Get the\n [project number](/resource-manager/docs/creating-managing-projects#identifying_projects)\n of the API consumer's project. If you don't have permission to access the\n API consumer's project, ask someone who has permission to get the project\n number for you.\n\n2. In the Google Cloud console, go to the **API Gateway** \\\u003e **APIs** page\n for your project.\n\n [Go to APIs](https://console.cloud.google.com/api-gateway/api)\n3. In the top-left corner of the **Overview** page, enter the project number in\n the **Filter by Project Number** field.\n\n4. Click **Filter**.\n\nThe metrics on the page update to reflect traffic only from the specified\nproject.\n\nWhat's next\n-----------\n\n- [Tracing your API](/api-gateway/docs/tracing)"]]