Questa pagina descrive come monitorare lo stato delle API di tua proprietà utilizzando i log e le metriche che Cloud Endpoints gestisce automaticamente per te. Quando
gli utenti effettuano richieste alla tua API, Endpoints registra informazioni sulle
richieste e sulle risposte. Gli endpoint monitorano anche tre dei
quattro segnali aurei del monitoraggio:
latenza, traffico ed errori. Queste metriche di utilizzo e rendimento ti aiutano a monitorare
la tua API.
Prima di iniziare
Devi eseguire il deployment dell'API e inviarle richieste per generare log e metriche da visualizzare. Se non hai ancora configurato nulla, prova la
guida rapida di Endpoints.
Panoramica dell'API
Quando esegui il debug di un problema con il tuo servizio o vuoi semplicemente assicurarti che
tutto funzioni correttamente, vai alla panoramica della tua API:
Nella console Google Cloud , vai alla pagina Endpoints > Servizi per il tuo progetto:
Se hai più di un'API, fai clic su quella che vuoi monitorare.
Assicurati di essere nella scheda Panoramica.
Grafici
Nella parte superiore sono presenti i grafici di alcune metriche, in modo da poter individuare immediatamente eventuali picchi
e cali. Puoi:
In alto a destra del primo grafico, utilizza l'elenco a discesa Seleziona grafici
per mostrare i grafici delle metriche che ti interessano e rimuovere quelli che
non vuoi visualizzare. Ogni voce dell'elenco a discesa ha un punto interrogativo
su cui puoi passare il puntatore per visualizzare una descrizione della metrica
che mostra.
Nell'angolo in alto a destra della panoramica, modifica i grafici selezionando uno dei vari intervalli di tempo. In questo modo viene modificato l'intervallo di tempo dei valori visualizzati in questi grafici, il che altera anche la granularità dei punti.
Tabella dei metodi
Quando vuoi esaminare i dati in dettaglio, scorri sotto i grafici per visualizzare una tabella
con le metriche per i singoli metodi della tua API. Puoi:
In alto a destra nella tabella, utilizza l'elenco a discesa Seleziona colonne per
mostrare le metriche che ti interessano e rimuovere quelle che non vuoi
visualizzare. Anche le voci qui presentano il punto interrogativo su cui puoi passare il puntatore per visualizzare una descrizione.
Nell'angolo in alto a destra della panoramica, seleziona un intervallo di tempo per i valori delle metriche nella tabella utilizzando il selettore dell'intervallo di tempo. In questo modo viene selezionato un intervallo di tempo sia per i grafici sia per la tabella.
Log
Quando noti un problema nelle metriche, vai alla pagina Esplora log nella console
Google Cloud per visualizzare i log delle richieste e delle risposte per la tua API.
Per visualizzare i log dei singoli metodi dell'API, fai clic su
Visualizza log nella tabella.
Per visualizzare i log di tutti i metodi dell'API, fai clic su
Visualizza tutti i log nell'angolo in basso a destra.
Per individuare i log di Endpoints direttamente dalla pagina Esplora log:
Nella console Google Cloud , vai alla pagina Stackdriver > Logging:
Crea query per specificare l'insieme di voci di log che vuoi visualizzare, ad esempio per ottenere tutte le richieste con una latenza superiore a 300 millisecondi.
Configura e gestisci i sink per
indirizzare i log alle destinazioni supportate
In questo modo puoi trasmettere i log in streaming a BigQuery per un'ulteriore analisi, salvare i
log non elaborati in Cloud Storage o inviarli agli argomenti di messaggistica Pub/Sub.
Filtrare in base a un progetto consumer specifico
Per visualizzare le metriche per un progetto consumer specifico, i tuoi consumer API devono inviare una
chiave API quando effettuano una richiesta. Poiché Endpoints utilizza la chiave API
per identificare il progetto a cui è associata l'applicazione chiamante, la chiave API deve essere stata creata nel progettoGoogle Cloud del consumer API. Per scoprire come limitare l'accesso alla tua API utilizzando
una chiave API, consulta
Limitazione dell'accesso all'API con chiavi API.
Per filtrare le metriche per un progetto consumer specifico:
Recupera il
numero di progetto
del progetto del consumer API. Se non hai l'autorizzazione per accedere al progetto
del consumer API, chiedi a qualcuno che ha l'autorizzazione di recuperare il numero del progetto.
Nella console Google Cloud , vai alla pagina Endpoint > Servizi
per il tuo progetto.
Nell'angolo in alto a sinistra della pagina Panoramica, inserisci il numero di progetto nel campo Filtra per numero di progetto.
Fai clic su Filtra.
Le metriche nella pagina vengono aggiornate in modo da riflettere il traffico solo dal progetto specificato.
Avvisi
Le metriche raccolte da Endpoints sono disponibili anche in
Cloud Monitoring. Puoi utilizzare Monitoring per configurare avvisi
su latenza, traffico ed errori. L'unico
indicatore chiave di prestazione
per cui non puoi configurare un avviso utilizzando le metriche di Endpoints è
la saturazione. Le metriche che devi monitorare per la saturazione dipendono dalla tua
applicazione. Consulta l'elenco delle
metriche
disponibili in Cloud Monitoring per le metriche che puoi utilizzare per configurare gli avvisi
sulla saturazione.
Per configurare gli avvisi:
Nella Google Cloud console, seleziona il Google Cloud progetto
con l'API Endpoints monitorata associata all'account.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eCloud Endpoints automatically logs request and response information, tracking latency, traffic, and errors to help monitor API health.\u003c/p\u003e\n"],["\u003cp\u003eThe Endpoints Services page provides an overview with graphs and tables to visualize API performance and identify issues quickly.\u003c/p\u003e\n"],["\u003cp\u003eYou can filter metrics for specific consumer projects by entering the project number in the "Filter by Project Number" field on the Overview page.\u003c/p\u003e\n"],["\u003cp\u003eAlerts can be set up in Cloud Monitoring for latency, traffic, and error metrics, using the "Produced API" resource type.\u003c/p\u003e\n"],["\u003cp\u003eThe logs collected can be viewed and analyzed in Logs Explorer, and can be routed to other destinations like BigQuery, Cloud Storage, or Pub/Sub for further analysis.\u003c/p\u003e\n"]]],[],null,["# Monitoring your API\n\nOpenAPI \\| [gRPC](/endpoints/docs/grpc/monitoring-your-api \"View this page for the Cloud Endpoints gRPC docs\")\n\n\u003cbr /\u003e\n\nThis page describes how you can monitor the health of APIs you own by using the\nlogs and metrics Cloud Endpoints maintains for you automatically. When\nusers make requests to your API, Endpoints logs information about\nthe requests and responses. Endpoints 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\nYou must deploy your API and send requests to it in order to generate logs and\nmetrics for viewing. If you don't have anything set up yet, try the\n[Endpoints quickstart](/endpoints/docs/deploy-api).\n\nAPI overview\n------------\n\nWhen you are debugging an issue with your service or just want to ensure that\neverything is running fine, go to your API's overview:\n\n1. In the Google Cloud console, go to the **Endpoints** \\\u003e **Services** page for\n your project:\n\n\n [Go to the Endpoints Services page](https://console.cloud.google.com/endpoints)\n\n \u003cbr /\u003e\n\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\nAt the top are graphs for some of the metrics, so you can spot any spikes\nand drops right away. You can:\n\n- In the top-right of the first graph, use the **Select graphs** drop-down list\n to show graphs for metrics you are interested in, and remove the ones you\n don't want to view. Each entry in the drop-down list has a question-mark\n that you can hold your pointer over to to see a description of the metric\n it displays.\n\n- In the top-right corner of the overview, adjust the graphs by selecting from\n the various time spans. This adjusts the time range of values displayed in\n these graphs, 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-right of the table, use the **Select columns** drop-down list to\n show the metrics you are interested in and remove the ones you don't want\n displayed. Entries here also have the question-mark that you can hold your\n pointer over to see a description.\n\n- In the top-right corner of the overview, select a time span for the\n metric values in the table by using the time span picker. This picks a time\n span for both the graphs and the table.\n\n### Logs\n\nWhen you spot an issue in the metrics, go to 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**.\n\n- To locate Endpoints logs directly from the Logs Explorer page:\n\n 1. In the Google Cloud console, go to the **Stackdriver** \\\u003e **Logging**\n page:\n\n\n [Go to the Logs Explorer page](https://console.cloud.google.com/logs/query)\n\n \u003cbr /\u003e\n\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 Endpoints service.\n\nSee the\n[Endpoints logs reference](/endpoints/docs/openapi/ref-endpoints-logs)\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 Build queries to specify the set of log entries that you want to view, such\n as getting all requests with a latency greater than 300 milliseconds.\n- [Configure and manage sinks](/logging/docs/export/configure_export_v2) to\n route your logs to supported destinations\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\n|\n| **Alpha**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nTo see metrics for a specific consumer project, your API consumers must send an\nAPI key when making a request. Because Endpoints uses the API key\nto identify the project that the calling application is associated\nwith, the API key must have been created in the API consumer's\nGoogle Cloud project. To learn how to restrict access to your API by using\nan API key, see\n\n[Restricting API access with API keys](/endpoints/docs/openapi/restricting-api-access-with-api-keys).\n\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 **Endpoints** \\\u003e **Services** page\n for your project.\n\n\n [Go to the Endpoints Services page](https://console.cloud.google.com/endpoints)\n\n \u003cbr /\u003e\n\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\nAlerting\n--------\n\n|\n| **Beta**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nMetrics collected by Endpoints are also available in\nCloud Monitoring. You can use Monitoring to set up alerting\non latency, traffic, and errors. The only\n[golden signal](https://landing.google.com/sre/book/chapters/monitoring-distributed-systems.html#xref_monitoring_golden-signals)\nthat you cannot set up an alert for using Endpoints metrics is\nsaturation. The metrics that you need to monitor for saturation depend on your\napplication. See the list of\n[metrics](/monitoring/api/metrics)\navailable in Cloud Monitoring for metrics that you can use to set up alerting\non saturation.\n\nTo set up alerting:\n\n1. In the Google Cloud console, select the Google Cloud project\n with your Endpoints monitored API which is associated with the\n account.\n\n [Go to Google Cloud console](https://console.cloud.google.com/)\n2. By using the navigation pane, select **Monitoring**.\n\n3. Create an [alerting policy](/monitoring/alerts)\n to set up alerts for the\n [golden signals](https://landing.google.com/sre/book/chapters/monitoring-distributed-systems.html#xref_monitoring_golden-signals)\n by using the following:\n\n - Latency\n\n 1. For **Condition Type** , enter `Metric Threshold`.\n 2. For **Resource Type** , enter `Produced API`.\n 3. For the metric, enter `Request latencies`.\n 4. Enter the threshold you want to alert on and follow the rest of the [Alerts guide](/monitoring/alerts).\n - Traffic\n\n 1. For **Condition Type** , enter `Metric Threshold`.\n 2. For **Resource Type** , enter `Produced API`.\n 3. For the metric, enter `Request count`.\n 4. Enter the threshold you want to alert on and follow the rest of the [Alerts guide](/monitoring/alerts).\n - Errors\n\n 1. For **Condition Type** , enter `Metric Threshold`.\n 2. For **Resource Type** , enter `Produced API`.\n 3. For the metric, enter `Request count`.\n 4. For response-code-class, enter `5xx`.\n 5. Enter the threshold you want to alert on and follow the rest of the [Alerts guide](/monitoring/alerts).\n\n| **Note:** If your API hasn't logged a 5xx response yet, the alerting policy form doesn't offer it as a response-code-class.\n| **Note:** If the critical constraint for your service is network IO, you might be able to use one of the Endpoints's metrics to set up an alert. All Endpoints logs are under the **Resource Type** of `Produced API`.\n\nWhat's next\n-----------\n\n- [Endpoints logs](/endpoints/docs/openapi/ref-endpoints-logs)\n- [Endpoints metrics](/monitoring/api/metrics_gcp_p_z#gcp-serviceruntime)"]]