You can save time and effort configuring and maintaining monitoring applications running on Google Kubernetes Engine (GKE) by enabling automatic application monitoring for supported workloads.
How automatic application monitoring worksWhen you enable automatic application monitoring, GKE detects deployed instances of supported workloads and deploys PodMonitoring
resources for each detected workload instance.
Automatic application monitoring also installs out-of-the-box dashboards for monitoring applications. The metrics are collected by Google Cloud Managed Service for Prometheus.
Supported workloadsAutomatic application monitoring supports the following workloads:
The metrics scraping interval for AI model servers is 15s. For non-AI workloads, the scraping interval is 30s.
For more information about other out-of-the-box observability solutions that you can configure manually, see Introduction to exporter configuration in the Google Cloud Observability documentation.
Before you beginBefore you start, make sure that you have performed the following tasks:
gcloud components update
. Note: For existing gcloud CLI installations, make sure to set the compute/region
property. If you use primarily zonal clusters, set the compute/zone
instead. By setting a default location, you can avoid errors in the gcloud CLI like the following: One of [--zone, --region] must be supplied: Please specify location
. You might need to specify the location in certain commands if the location of your cluster differs from the default that you set.To enable automatic application monitoring, your GKE cluster must meet the following requirements:
You can enable automatic application monitoring for new or existing GKE clusters using the Google Cloud console, the Google Cloud CLI or the GKE API.
Metrics scraping takes up to 10 minutes to start for supported workloads after you deploy a new workload or after you enable automatic application monitoring for a cluster.
ConsoleTo enable automatic application monitoring for a new cluster, do the following:
In the Google Cloud console, go to the Create an Autopilot cluster page.
Go to Create an Autopilot cluster
You can also complete this task by creating a Standard cluster.
For an Autopilot mode cluster, click Advanced settings. For a Standard mode cluster, click Features.
In the Operations section, select Enable automatic application monitoring.
Click Create.
You can also enable automatic application monitoring for an existing cluster by updating the Enable automatic application monitoring field in the Operations section of the Cluster Details tab.
gcloudTo enable automatic application monitoring for a new cluster, use the option --auto-monitoring-scope=ALL
:
gcloud container clusters create-auto CLUSTER_NAME \
--location=COMPUTE_LOCATION \
--auto-monitoring-scope=ALL
Replace the following:
CLUSTER_NAME
: the name of the new cluster.COMPUTE_LOCATION
: the Compute Engine location for the cluster.You can also update an existing cluster using the command gcloud container clusters update
.
To enable automatic application monitoring for a new cluster, make a POST
request to the method clusters.create
:
POST https://container.googleapis.com/v1/projects/PROJECT_ID/locations/COMPUTE_LOCATION/clusters
{
"cluster": {
"name": "CLUSTER_NAME",
"initialNodeCount": 1,
"monitoringConfig": {
"managedPrometheusConfig": {
"enabled": true,
"autoMonitoringConfig": {
"scope": "ALL"
}
}
}
}
}
Replace the following:
PROJECT_ID
: your Google Cloud project ID.CLUSTER_NAME
: the name of the new cluster.COMPUTE_LOCATION
: the Compute Engine location for the cluster.You can determine if automatic application monitoring is enabled or disabled for a cluster using the Google Cloud console, the gcloud CLI, or the GKE API.
ConsoleDo the following:
Go to the Google Kubernetes Engine page in the Google Cloud console:
In the cluster list, click the name of the cluster.
In the Features section, the Automatic application monitoring field indicates if automatic application monitoring is enabled or disabled.
Describe the cluster:
gcloud container clusters describe CLUSTER_NAME \
--location=COMPUTE_LOCATION \
--format='value(monitoringConfig.managedPrometheusConfig.autoMonitoringConfig.scope)'
Replace the following:
CLUSTER_NAME
: the name of the cluster.COMPUTE_LOCATION
: the Compute Engine location for the cluster.The output is similar to the following:
autoMonitoringConfig.scope: ALL
In the output, if the value of autoMonitoringConfig.scope
field is ALL
, automatic application monitoring is enabled. Otherwise, automatic application monitoring is disabled.
Make a GET
request to the method clusters.get
:
GET https://container.googleapis.com/v1/projects/PROJECT_ID/locations/COMPUTE_LOCATION/clusters/CLUSTER_NAME
Replace the following:
PROJECT_ID
: your Google Cloud project ID.CLUSTER_NAME
: the name of the cluster.COMPUTE_LOCATION
: the Compute Engine location for the cluster.The output is similar to the following:
autoMonitoringConfig.scope: ALL
In the output, if the value of autoMonitoringConfig.scope
field is ALL
, automatic application monitoring is enabled. Otherwise, automatic application monitoring is disabled.
When you enable automatic application monitoring, GKE installs out-of-the-box dashboards for monitoring applications for supported workloads that are deployed to your cluster. You won't see dashboards for supported workloads that have never run on a cluster.
To view the dashboards with telemetry from automatically monitored workloads in the Google Kubernetes Engine page, do the following:
Go to the Google Kubernetes Engine page in the Google Cloud console:
Click the name of the cluster where you want to view dashboards for automatically monitored workloads.
Click the Observability tab. The Integrations section shows configured dashboards for supported workloads running on the cluster.
To view the dashboards with telemetry from automatically monitored workloads in the Cloud Monitoring page, do the following:
Go to the Dashboards page.
Click the Dashboard List tab.
Select the Integrations category.
Click the name of the dashboard. For example, RabbitMQ Prometheus Overview.
If you disable automatic application monitoring on a cluster, the PodMonitoring
resources that GKE created remain intact and GKE continues to monitor existing supported workloads. GKE stops automatically monitoring new instances of supported workloads that you deploy to the cluster. To stop monitoring existing supported workloads, you must delete the PodMonitoring
resources that GKE created. If you re-enable automatic application monitoring for a cluster, GKE detects and reconciles the PodMonitoring
resources that it previously created.
You can disable automatic application monitoring for a cluster using the Google Cloud console, the gcloud CLI, or the GKE API.
ConsoleGo to the Google Kubernetes Engine page in the Google Cloud console:
Click the name of the cluster.
In the Features list, find the Automatic application monitoring field.
Click editEdit.
Deselect Enable automatic application monitoring.
Click Save.
Update the cluster using the option --auto-monitoring-scope=NONE
:
gcloud container clusters update CLUSTER_NAME \
--location=COMPUTE_LOCATION \
--auto-monitoring-scope=NONE
Replace the following:
CLUSTER_NAME
: the name of the cluster.COMPUTE_LOCATION
: the Compute Engine location for the cluster.Make a PUT
request to the method clusters.update
:
PUT https://container.googleapis.com/v1/projects/PROJECT_ID/locations/COMPUTE_LOCATION/clusters/CLUSTER_NAME
{
"update": {
"desiredMonitoringConfig": {
"managedPrometheusConfig": {
"autoMonitoringConfig": {
"scope": "NONE"
}
}
}
}
}
Replace the following:
PROJECT_ID
: your Google Cloud project ID.CLUSTER_NAME
: the name of the cluster.COMPUTE_LOCATION
: the Compute Engine location for the cluster.You can customize the monitoring configuration for individual instances of supported workloads or opt out of monitoring individual instances of supported workloads.
To customize the PodMonitoring
resource for a deployed instance of a supported workload without impacting the automatic application monitoring of other workloads, you must exclude the instance from automatic application monitoring and then update the configuration or replace the PodMonitoring
resource associated with the target workload instance.
If you update or delete a PodMonitoring
resource that GKE created without excluding the associated workload, GKE restores the PodMonitoring
resource to ensure continuity while monitoring other supported workloads.
PodMonitoring
resource for a supported workload while automatic application monitoring is enabled, the PodMonitoring
resource scrapes and exports metrics in parallel with the PodMonitoring
resource that GKE creates. This results in duplicative telemetry collection for the workload. To avoid this duplication when using automatic application monitoring, either delete the PodMonitoring
resources that you created for the supported workloads, or exclude the workloads and manually delete the PodMonitoring
resources that GKE created. Find the PodMonitoring
resource for a workload
You can identify the PodMonitoring
resource that GKE created for a workload using the Google Cloud console:
Go to the Object browser page.
In the Cluster field, enter the name of the cluster.
In the Namespace field, enter the name of the namespace.
In the Object Kinds filter, select PodMonitoring.
Under monitoring.googleapis.com, select PodMonitoring.
Click an object name to inspect the object. The metadata label source:gke-auto-monitoring
indicates that GKE created the PodMonitoring
resource.
If you don't want to monitor a deployed instance of a supported workload, or if you want to customize the monitoring configuration of a workload, you can exclude the workload from automatic application monitoring.
To exclude a workload, you must add the metadata label allow-gke-auto-monitoring: false
to the target workload configuration. For example, the following manifest describes a RabbitMQ StatefulSet that is not monitored by automatic application monitoring:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: rabbitmq
labels:
allow-gke-auto-monitoring: "false"
spec:
serviceName: rabbitmq
replicas: 3
After you exclude a workload instance, you can delete the PodMonitoring
resource that GKE created for the workload. GKE does not attempt to restore the PodMonitoring
resource if you delete or modify it. If you deploy a new workload with the metadata label allow-gke-auto-monitoring: false
, GKE does not create a PodMonitoring
resource for the workload.
If you want to stop monitoring a workload or if you want to deploy your own customized PodMonitoring
resource for a workload, you can delete the monitoring configuration.
To delete the automatic application monitoring configuration of an individual workload, do the following:
PodMonitoring
resource that GKE created for the workload.Delete the PodMonitoring
resource:
kubectl delete podmonitoring POD_MONITORING_NAME -n NAMESPACE
Replace the following:
POD_MONITORING_NAME
: the name of the PodMonitoring
resource.NAMESPACE
: the namespace of the PodMonitoring
resource.To delete the automatic application monitoring configuration of all workloads in a cluster, do the following:
Delete all PodMonitoring
resources in the cluster with the metadata label source:gke-auto-monitoring
:
kubectl delete podmonitorings -l source=gke-auto-monitoring --all-namespaces
The automatic application monitoring configuration and installation of out-of-the-box dashboards for supported workloads by automatic application monitoring is available at no additional charge. However, Monitoring charges for the ingestion of metrics by Google Cloud Managed Service for Prometheus according to Monitoring pricing.
What's nextRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4