Instalar o Cloud Monitoring em clusters anexados em conformidade com a CNCF
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Nesta página, explicamos como configurar a coleta de dados gerenciados com o
Google Cloud Serviço gerenciado para Prometheus para
clusters anexados ao GKE. Esse recurso está disponível em clusters Google Cloud
que executam a versão 1.25 ou mais recente do Kubernetes. Ele também é compatível com
clusters do Kubernetes na versão 1.24 para clientes que já se inscreveram
para uma prévia desse recurso nessa versão.
Com esse recurso, é possível usar um recurso do PodMonitoring para escolher as métricas que quer ingerir no Cloud Monitoring. É possível conferir essas
métricas no console Google Cloud .
Limitações
Este recurso não está disponível nos clusters do Kubernetes anteriores à versão 1.24.
Este recurso requer uma carga de trabalho do Linux.
Configurar a coleta de dados gerenciados
Para configurar a coleta de dados gerenciados com o Managed Service para Prometheus, siga estas etapas:
Autorize a gravação das métricas pelas
contas de serviço gmp-system/collector e gmp-system/rule-evaluator:
Substitua GOOGLE_PROJECT_ID pelo ID do projeto Google Cloud.
A adição dessa vinculação do IAM falhará a menos que pelo menos um
cluster tenha sido criado no projeto Google Cloud . Isso ocorre porque o
pool de Identidade da carga de trabalho a que ele se refere
(GOOGLE_PROJECT_ID.svc.id.goog) não é provisionado até
a criação do cluster.
Para configurar quais métricas de carga de trabalho você quer ingerir, configure um
recurso do
PodMonitoring. Por exemplo, consulte
Configurar um recurso do PodMonitoring
na coleta de dados gerenciados com o Managed Service para Prometheus.
Depois de ativar a coleta de dados gerenciados com o Managed Service para Prometheus, os clusters anexados do GKE criam o
namespace gmp-system. Não modifique nem implante nada nesse namespace.
Os clusters anexados do GKE também criam o namespace gmp-public. O Managed Service
para Prometheus usa o namespace gmp-public para implantar o
recurso
OperatorConfig.
Atualizar a configuração do Prometheus
Para desativar ou reativar a coleta de dados do Prometheus, use o
comando gcloud container attached clusters update. Ao atualizar o cluster, inclua
as flags opcionais --disable-managed-prometheus ou --enable-managed-prometheus.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-07-31 UTC."],[],[],null,["This page explains how you can set up managed data collection with\n[Google Cloud Managed Service for Prometheus](/stackdriver/docs/managed-prometheus) for\nGKE attached clusters. This feature is available on Google Cloud clusters\nrunning Kubernetes version 1.25 or later. It is also supported on Kubernetes\nclusters at version 1.24 for customers who had earlier signed up for a\npreview of this feature on that version.\n\nWith this feature, you can use a PodMonitoring resource to choose the metrics\nthat you want to ingest into Cloud Monitoring. You can then view these\nmetrics in the Google Cloud console.\n\nLimitations\n\n- This feature is not available on Kubernetes clusters earlier than version 1.24.\n\n\u003c!-- --\u003e\n\n- This feature requires a Linux workload.\n\nSet up managed data collection\n\nTo set up managed data collection with Managed Service for Prometheus, complete the following steps:\n| **Note:** Starting with Kubernetes version 1.28, manual policy binding to authorize service accounts for data collection is no longer necessary. The required permissions are now automatically granted to this service account. You can therefore disregard step 1 in this section.\n\n1. Authorize the `gmp-system/collector` and `gmp-system/rule-evaluator` service\n accounts to write your metrics:\n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003eGOOGLE_PROJECT_ID\u003c/var\u003e \\\n --member=\"serviceAccount:\u003cvar translate=\"no\"\u003eGOOGLE_PROJECT_ID\u003c/var\u003e.svc.id.goog[gmp-system/collector]\" \\\n --role=roles/monitoring.metricWriter\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003eGOOGLE_PROJECT_ID\u003c/var\u003e \\\n --member=\"serviceAccount:\u003cvar translate=\"no\"\u003eGOOGLE_PROJECT_ID\u003c/var\u003e.svc.id.goog[gmp-system/rule-evaluator]\" \\\n --role=roles/monitoring.viewer\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003eGOOGLE_PROJECT_ID\u003c/var\u003e \\\n --member=\"serviceAccount:\u003cvar translate=\"no\"\u003eGOOGLE_PROJECT_ID\u003c/var\u003e.svc.id.goog[gmp-system/rule-evaluator]\" \\\n --role=roles/monitoring.metricWriter\n\n Replace \u003cvar translate=\"no\"\u003eGOOGLE_PROJECT_ID\u003c/var\u003e with your Google Cloud\n project ID.\n\n Adding this IAM binding fails unless at least one\n cluster has been created in your Google Cloud project. This is because the\n workload identity pool it refers to\n (\u003cvar translate=\"no\"\u003eGOOGLE_PROJECT_ID\u003c/var\u003e`.svc.id.goog`) isn't provisioned until\n cluster creation.\n2. Use the\n [`gcloud container attached clusters register` command](/sdk/gcloud/reference/container/attached/clusters/register)\n to register the cluster, and include the optional\n `--enable-managed-prometheus` flag.\n\n3. To configure which workload metrics you want to ingest, set up a\n [PodMonitoring](https://github.com/GoogleCloudPlatform/prometheus-engine/blob/v0.4.3-gke.0/doc/api.md#podmonitoring)\n resource. For an example, see\n [Configure a PodMonitoring resource](/stackdriver/docs/managed-prometheus/setup-managed#gmp-pod-monitoring)\n in the managed data collection with Managed Service for Prometheus documentation.\n\nAfter you enable managed data collection with Managed Service for Prometheus, GKE attached clusters creates the\n`gmp-system` namespace. Don't modify or deploy anything in this namespace.\nGKE attached clusters also creates the `gmp-public` namespace. Managed Service\nfor Prometheus uses the `gmp-public` namespace to deploy the\n[OperatorConfig](https://github.com/GoogleCloudPlatform/prometheus-engine/blob/v0.4.3-gke.0/doc/api.md#operatorconfig)\nresource.\n\nUpdate your Prometheus configuration\n\nTo disable or re-enable Prometheus data collection, use the\n[`gcloud container attached clusters update` command](/sdk/gcloud/reference/container/attached/clusters/update). When updating the cluster, include either the\n`--disable-managed-prometheus` or `--enable-managed-prometheus` optional flag.\n\nWhat's next\n\n- Discover how to [Configure a query user interface](/stackdriver/docs/managed-prometheus/query) in the managed data collection with Managed Service for Prometheus documentation.\n- Learn about [Managed rule evaluation and alerting](/stackdriver/docs/managed-prometheus/rules-managed) in the Google Cloud Managed Service for Prometheus documentation."]]