Les métriques et les journaux de Cloud Endpoints ne sont pas affichés
Si vous pouvez envoyer des requêtes à votre API, mais que les métriques et les journaux ne s'affichent pas sur la page Endpoints > Services de la consoleGoogle Cloud , procédez comme suit:
Si vous devez accéder aux journaux d'Extensible Service Proxy (ESP) pour diagnostiquer les problèmes, utilisez kubectl comme suit :
Récupérez le nom du pod :
kubectl get pod
NAME READY STATUS RESTARTS AGE
esp-echo-174578890-x09gl 2/2 Running 2 21s
Le nom du pod est esp-echo-174578890-x09gl. Il comporte deux conteneurs : esp et echo.
Pour afficher les journaux dans un pod, utilisez kubectl logs :
kubectl logs POD_NAME -c CONTAINER_NAME
Où POD_NAME et CONTAINER_NAME sont les valeurs renvoyées par la commande kubectl get pod à l'étape précédente. Exemple :
kubectl logs esp-echo-174578890-x09gl -c esp
Vérifier le nom du service
Si vous rencontrez le message d'erreur Fetching service config failed, vérifiez que le nom du service que vous avez spécifié dans le champ --service de votre fichier manifeste de déploiement (appelé deployment.yaml) correspond au nom spécifié dans la propriété host de votre document OpenAPI (appelé openapi.yaml).
Si le nom incorrect se trouve dans le fichier deployment.yaml :
Ouvrez le fichier deployment.yaml, puis allez à la section configurée pour le conteneur ESP. Exemple :
Modifiez SERVICE_NAME afin qu'il corresponde au nom d'hôte spécifié dans le champ host du fichier openapi.yaml, puis enregistrez le fichier deployment.yaml.
Démarrez le service Kubernetes :
kubectl create -f deployment.yaml
Si le fichier openapi.yaml comporte un nom incorrect :
Remplacez SERVICE_NAME par le nom récupéré à l'étape précédente. Il faut 30 jours pour que le service soit supprimé deGoogle Cloud. Vous ne pourrez pas réutiliser le nom du service pendant ce laps de temps.
Ouvrez openapi.yaml et corrigez le nom figurant dans la propriété host, puis enregistrez le fichier.
Déployez la configuration de service mise à jour :
gcloud endpoints services deploy openapi.yaml
Attendez que la configuration du service soit déployée avec succès.
Démarrez le service Kubernetes :
kubectl create -f deployment.yaml
Vérifier les fichiers de configuration
Utilisez ssh pour vous connecter au pod à l'aide de kubectl :
kubectl exec -ti -c CONTAINER_NAMEPOD_NAME bash
Remplacez CONTAINER_NAME par le nom de votre conteneur et POD_NAME par celui de votre pod.
Dans le répertoire etc/nginx/endpoints/, recherchez des erreurs dans les fichiers de configuration suivants :
nginx.conf : fichier de configuration nginx avec les directives ESP
service.jso : fichier de configuration du service
Accéder à la page d'état de Cloud Endpoints
Si vous avez défini rollout_strategy sur managed lorsque vous avez démarré ESP et que vous recherchez l'ID de configuration utilisé par une instance ESP, vous devez consulter la page d'état de Cloud 'Endpoints.
Pour accéder à la page d'état de Cloud Endpoints :
Utilisez ssh pour vous connecter au pod à l'aide de kubectl :
kubectl exec -ti -c CONTAINER_NAMEPOD_NAME bash
Remplacez CONTAINER_NAME par le nom de votre conteneur et POD_NAME par celui de votre pod.
La valeur de rolloutId est l'ID de configuration de service utilisé par ESP. Pour vous assurer qu'ESP utilise la même configuration que Cloud Endpoints, consultez la page Obtenir le nom du service et l'ID de configuration.
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 document provides troubleshooting steps for issues encountered when deploying Endpoints on Google Kubernetes Engine (GKE) and Kubernetes.\u003c/p\u003e\n"],["\u003cp\u003eIf the error \u003ccode\u003eFailed in kubectl create -f gke.yaml\u003c/code\u003e occurs, you will need to authorize \u003ccode\u003egcloud\u003c/code\u003e, create a cluster, and make cluster credentials available to \u003ccode\u003ekubectl\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eTo resolve missing metrics or logs in the Google Cloud console, verify that all required services are enabled and that all required permissions are granted.\u003c/p\u003e\n"],["\u003cp\u003eTo check if the service name is correct, ensure that the \u003ccode\u003e--service\u003c/code\u003e field in your \u003ccode\u003edeployment.yaml\u003c/code\u003e file matches the \u003ccode\u003ehost\u003c/code\u003e field in your \u003ccode\u003eopenapi.yaml\u003c/code\u003e file, correcting either one if they are mismatched.\u003c/p\u003e\n"],["\u003cp\u003eTo diagnose issues with the Extensible Service Proxy (ESP), you can view the logs using \u003ccode\u003ekubectl logs\u003c/code\u003e, check configuration files in the \u003ccode\u003eetc/nginx/endpoints/\u003c/code\u003e directory, or access the Endpoints status page for configuration ID details.\u003c/p\u003e\n"]]],[],null,["# Troubleshooting Cloud Endpoints in GKE\n\nOpenAPI \\| [gRPC](/endpoints/docs/grpc/troubleshoot-gke-deployment \"View this page for the Cloud Endpoints gRPC docs\")\n\n\u003cbr /\u003e\n\nThis document presents troubleshooting techniques for Endpoints\ndeployments on Google Kubernetes Engine (GKE) and Kubernetes.\n\nFailed in `kubectl create -f gke.yaml`\n--------------------------------------\n\nIf you see the `Failed in kubectl create -f gke.yaml` error message, take the\nfollowing steps:\n\n1. Authorize `gcloud`:\n\n gcloud auth login\n gcloud auth application-default login\n\n2. Create a cluster. You can either use the following `gcloud`command, or create\n a cluster using\n [Google Cloud console](https://console.cloud.google.com/kubernetes).\n\n ```\n gcloud container clusters create CLUSTER_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e with your cluster's name.\n3. Get credentials for your cluster and make them available to `kubectl`:\n\n ```\n gcloud container clusters get-credentials CLUSTER_NAME\n ```\n\nEndpoints metrics and logs aren't displayed\n-------------------------------------------\n\nIf you can successfully send requests to your API, but you don't see any\nmetrics or logs on the **Endpoints** \\\u003e **Services** page in the\nGoogle Cloud console, take the following steps:\n\n1. Check all the [required services](/endpoints/docs/openapi/get-started-kubernetes-engine#checking_required_services) are enabled.\n2. Check all the [required permissions](/endpoints/docs/openapi/get-started-kubernetes-engine#checking_required_permissions) are granted.\n\nAccessing logs from Extensible Service Proxy\n--------------------------------------------\n\nIf you need to access the Extensible Service Proxy (ESP) logs to diagnose\nproblems, use `kubectl` as follows:\n\n1. Get the name of the pod:\n\n kubectl get pod\n\n NAME READY STATUS RESTARTS AGE\n esp-echo-174578890-x09gl 2/2 Running 2 21s\n\n The pod name is `esp-echo-174578890-x09gl` and it has two containers: `esp`\n and `echo`.\n2. To view the logs in a pod use `kubectl logs`:\n\n ```\n kubectl logs POD_NAME -c CONTAINER_NAME\n ```\n\n Where `POD_NAME` and\n `CONTAINER_NAME` are returned from the\n `kubectl get pod`\n command, in the previous step. For example: \n\n kubectl logs esp-echo-174578890-x09gl -c esp\n\nVerifying the service name\n--------------------------\n\nIf you see the error message `Fetching service config failed`, verify that the service name that you specified in the `--service` field in your Deployment manifest file (referred to as the `deployment.yaml` file) matches the name in the `host` field in your OpenAPI document (referred to as the `openapi.yaml` file).\n\n\u003cbr /\u003e\n\n**If the incorrect name is in the `deployment.yaml` file**:\n\n1. Open the `deployment.yaml` file and go to the section configured for the\n ESP container. For example:\n\n ```\n containers:\n - name: esp\n image: gcr.io/endpoints-release/endpoints-runtime:1\n args: [\n \"--http_port=8081\",\n \"--backend=127.0.0.1:8080\",\n \"--service=SERVICE_NAME\",\n \"--rollout_strategy=managed\"\n ]\n ```\n\n Change \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e so that it matches the name in\n the `host` field in the `openapi.yaml` and save the `deployment.yaml` file.\n2. Start the Kubernetes service:\n\n kubectl create -f deployment.yaml\n\n**If the incorrect name is in the `openapi.yaml` file**:\n\n1. [Get the service name](/endpoints/docs/openapi/get-service-name-config-id)\n that Endpoints was configured to use.\n\n2. Delete the service:\n\n ```\n gcloud endpoints services delete SERVICE_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e with the name from the\n previous step. It takes 30 days for the service to be deleted from\n Google Cloud. You aren't able to reuse the service name during this time.\n3. Open the `openapi.yaml` file and correct the name in the `host` field and save\n the file.\n\n4. Deploy the updated service configuration:\n\n gcloud endpoints services deploy openapi.yaml\n\n5. Wait for the service configuration to be successfully deployed.\n\n6. Start the Kubernetes service:\n\n kubectl create -f deployment.yaml\n\nChecking configuration files\n----------------------------\n\n1. Use `ssh` to connect to the pod using `kubectl`:\n\n ```\n kubectl exec -ti -c CONTAINER_NAME POD_NAME bash\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e with the name of your\n container and \u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e with the name of your pod.\n2. In the `etc/nginx/endpoints/` directory, check the following configuration\n files for errors:\n\n - `nginx.conf`- The `nginx` config file with ESP directives\n - `service.jso` - The service configuration file\n\nAccessing the Endpoints status page\n-----------------------------------\n\nIf you set `rollout_strategy` to `managed` when you started ESP,\nand you need to find out the configuration ID that an instance of\nESP is using, the Endpoints status page has the information.\n\nTo access the Endpoints status page:\n\n1. Use `ssh` to connect to the pod using `kubectl`:\n\n ```\n kubectl exec -ti -c CONTAINER_NAME POD_NAME bash\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e with the name of your\n container and \u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e with the name of your pod.\n2. Install [`curl`](https://curl.haxx.se/download.html).\n\n3. Enter the following:\n\n curl http://localhost:8090/endpoints_status\n\n It displays something similar the following: \n\n \"serviceConfigRollouts\": {\n \"rolloutId\": \"2017-08-09r27\",\n \"percentages\": {\n \"2017-08-09r26\": \"100\"\n }\n }\n\nThe value in the `rolloutId` is the service configuration ID that\nESP is using. To make sure that ESP is using the\nsame configuration as Endpoints,\nsee\n[Getting the service name and configuration ID](/endpoints/docs/openapi/get-service-name-config-id)."]]