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 works
When 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 workloads
Automatic application monitoring supports the following workloads:
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 begin
Before you start, make sure you have performed the following tasks:
- Enable the Google Kubernetes Engine API. Enable Google Kubernetes Engine API
- If you want to use the Google Cloud CLI for this task,
install and then
initialize the
gcloud CLI. If you previously installed the gcloud CLI, get the latest
version by running
gcloud components update
.
- Enable the Cloud Monitoring API.
Requirements for automatic application monitoring
To enable automatic application monitoring, your GKE cluster must meet the following requirements:
- Your cluster must be running GKE version 1.28 or later.
- You must have gcloud CLI version 492.0.0 or later.
- Your cluster must have Google Cloud Managed Service for Prometheus managed collection enabled. Google Cloud Managed Service for Prometheus managed collection is enabled by default for new clusters.
Enable automatic application monitoring
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.
Console
To enable automatic application monitoring for a new cluster, do the following:
Go to the Google Kubernetes Engine page in the Google Cloud console.
Click
Create then in the Standard or Autopilot section, click Configure.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.
gcloud
To enable automatic application monitoring for a new cluster, use the option
--auto-monitoring-scope=ALL
:
gcloud beta 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 beta container clusters update
.
API
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.
Determine if automatic application monitoring is enabled
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.
Console
Do 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.
gcloud
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.
API
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.
View dashboard
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.
Disable automatic application monitoring
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.
Console
Go 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.
gcloud
Update the cluster using the option --auto-monitoring-scope=NONE
:
gcloud beta 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.
API
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.
Customize automatic monitoring of supported workloads
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.
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 thePodMonitoring
resource.
Exclude deployed instances from automatic monitoring
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
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.
Delete the monitoring configuration for a 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:
- Exclude the workload from automatic application monitoring.
- Identify the
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 thePodMonitoring
resource.NAMESPACE
: the namespace of thePodMonitoring
resource.
To delete the automatic application monitoring configuration of all workloads in a cluster, do the following:
- Disable automatic application monitoring.
Delete all
PodMonitoring
resources in the cluster with the metadata labelsource:gke-auto-monitoring
:kubectl delete podmonitorings -l source=gke-auto-monitoring --all-namespaces
Pricing
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 next
- Learn how to View observability metrics.