Cette page vous explique comment surveiller l'état des API dont vous êtes propriétaire, à l'aide des journaux et des métriques que Cloud Endpoints conserve automatiquement. Lorsque des utilisateurs adressent des requêtes à votre API, Endpoints enregistre des informations sur ces requêtes et sur les réponses renvoyées. Il suit également trois des quatre signaux clés de surveillance : la latence, le trafic et les erreurs. Ces métriques d'utilisation et de performances vous aident à surveiller l'API.
Avant de commencer
Vous devez déployer votre API et lui envoyer des requêtes, pour générer des journaux et des métriques à afficher. Si vous n'avez rien configuré pour le moment, consultez le guide de démarrage rapide de Cloud Endpoints.
Présentation de l'API
Lorsque vous corrigez un problème lié au service ou que vous souhaitez simplement vérifier que tout s'exécute correctement, accédez à la présentation de l'API :
Dans la console Google Cloud , accédez à la page Endpoints > Services de votre projet :
Si vous possédez plusieurs API, cliquez sur celle que vous souhaitez surveiller.
Assurez-vous que vous êtes sur l'onglet Aperçu.
Graphiques
En haut se trouvent des graphiques pour certaines métriques, vous permettant ainsi de repérer immédiatement les pics et les chutes d'activité. Vous pouvez alors réaliser les actions suivantes :
Dans le coin supérieur droit du premier graphique, utilisez la liste déroulante Sélectionner des graphiques pour afficher les graphiques des métriques qui vous intéressent et supprimer ceux que vous ne souhaitez pas afficher. Chaque entrée de la liste déroulante comporte un point d'interrogation sur lequel vous pouvez placer votre pointeur pour afficher une description de la métrique affichée.
Dans le coin supérieur droit de l'aperçu, ajustez les graphiques en sélectionnant différentes périodes. Cette action permet de modifier la période appliquée aux valeurs affichées dans ces graphiques, modifiant également le niveau de précision des points.
Tableau des méthodes
Pour une exploration plus approfondie, consultez le tableau situé en dessous des graphiques contenant les métriques par méthode de votre API. Vous pouvez effectuer les actions suivantes :
Dans le coin supérieur droit du tableau, utilisez la liste déroulante Sélectionner des colonnes pour afficher les métriques qui vous intéressent et supprimer celles que vous ne voulez pas afficher. Les entrées ainsi affichées possèdent également le point d'interrogation sur lequel vous pouvez placer votre pointeur pour voir une description de celle-ci.
Dans le coin supérieur droit de la présentation, sélectionnez une période pour les valeurs de métriques de la table à l'aide de l'outil de sélection de périodes. Cette sélection s'applique aux graphiques ainsi qu'au tableau.
Journaux
Lorsque vous repérez un problème dans les métriques, accédez à la page Explorateur de journaux dans la consoleGoogle Cloud pour consulter les journaux des requêtes et des réponses de l'API.
Pour afficher les journaux par méthode de l'API, cliquez sur Afficher les journaux dans le tableau.
Pour afficher les journaux de toutes les méthodes de l'API, cliquez sur Afficher tous les journaux dans le coin inférieur droit.
Pour localiser les journaux Endpoints directement depuis la page de l'explorateur de journaux, procédez comme suit :
Dans la console Google Cloud , accédez à la page Stackdriver > Logging :
Créez des requêtes pour spécifier l'ensemble des entrées de journal à afficher, par exemple pour obtenir toutes les requêtes dont la latence est supérieure à 300 millisecondes.
Configurer et gérer les récepteurs pour acheminer vos journaux vers les destinations compatibles : vous pouvez ainsi transférer les journaux vers BigQuery pour les analyser plus en détail, enregistrer les journaux bruts dans Cloud Storage, ou les envoyer aux sujets de messagerie Pub/Sub.
Filtrer selon un projet client spécifique
Pour afficher les métriques d'un projet client spécifique, les utilisateurs d'API doivent envoyer une clé API lorsqu'ils effectuent une requête. Comme Endpoints utilise la clé API pour identifier le projet auquel l'application appelante est associée, la clé API doit avoir été créée dans le projetGoogle Cloud du client de l'API. Pour savoir comment restreindre l'accès à votre API à l'aide d'une clé API, consultez la page Restreindre l'accès à l'API avec des clés API.
Pour filtrer les métriques pour un projet client spécifique, procédez comme suit :
Obtenez le numéro du projet du client utilisant l'API. Si vous n'êtes pas autorisé à accéder au projet du client de l'API, demandez à une personne disposant des autorisations nécessaires d'obtenir le numéro de projet pour vous.
Dans la console Google Cloud , accédez à la page Endpoints > Services de votre projet.
Dans l'angle supérieur gauche de la page Présentation, saisissez le numéro du projet dans le champ Filtrer par numéro de projet.
Cliquez sur Filtrer.
Les métriques de la page sont mises à jour pour correspondre au trafic provenant uniquement du projet indiqué.
Alertes
Les métriques collectées par Endpoints sont également disponibles dans Cloud Monitoring, lequel vous permet de configurer des alertes sur la latence, le trafic et les erreurs. La saturation est le seul signal clé pour lequel vous ne pouvez pas configurer une alerte à l'aide des métriques Endpoints. Les métriques pour lesquelles vous avez besoin de surveiller la saturation dépendent de votre application. Consultez la liste des métriques disponibles dans Cloud Monitoring pour savoir quelles métriques vous pouvez utiliser pour configurer les alertes de saturation.
Pour configurer les alertes, procédez comme suit :
Dans la console Google Cloud , sélectionnez le Google Cloud projet contenant l'API Endpoints surveillée qui est associé au compte.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eThis page outlines how to monitor the health of your APIs using Cloud Endpoints, which automatically logs request/response information and tracks latency, traffic, and errors.\u003c/p\u003e\n"],["\u003cp\u003eYou can monitor your API's health through the "Endpoints > Services" page in the Google Cloud console, which displays graphs and a table of metrics for each method, allowing for detailed analysis.\u003c/p\u003e\n"],["\u003cp\u003eThe Logs Explorer page allows you to view logs for individual methods or all methods, offering options to build queries and manage log exports to destinations like BigQuery, Cloud Storage, or Pub/Sub.\u003c/p\u003e\n"],["\u003cp\u003eYou can filter metrics to reflect traffic from a specific consumer project by entering the project number in the "Filter by Project Number" field on the "Endpoints > Services" page.\u003c/p\u003e\n"],["\u003cp\u003eCloud Monitoring can be used to create alerts for the golden signals of latency, traffic, and errors using Endpoints metrics, helping to proactively manage API performance and availability.\u003c/p\u003e\n"]]],[],null,["# Monitoring your API\n\n[OpenAPI](/endpoints/docs/openapi/monitoring-your-api \"View this page for the Cloud Endpoints OpenAPI docs\") \\| gRPC\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/grpc/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\n[Restricting API access with API keys](/endpoints/docs/grpc/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/grpc/ref-endpoints-logs)\n- [Endpoints metrics](/monitoring/api/metrics_gcp_p_z#gcp-serviceruntime)"]]