Collect additional GKE node metrics using collectd with Cloud Monitoring
Contributed by Google employees.
Only a few metrics are available by default on GKE nodes. You can deploy a Cloud Monitoring agent to expose additional metrics for added visibility into the health of your GKE nodes.
Expose additional host metrics using the Cloud Monitoring agent on GKE nodes.
Host metrics available by default:
- CPU usage
- Disk I/O
- Network traffic
Metrics added with the Cloud Monitoring agent:
- CPU load
- CPU steal
- Memory usage
- Swap usage
- Disk usage
- Open TCP connections
For details about the metrics exposed by the Cloud Monitoring agent, see Agent metrics.
Even more metrics can be added by customizing
collectd.conf to meet your
Before you begin
- Create a Google Cloud project and GKE cluster, as shown in this quickstart tutorial.
- Install the Google Cloud SDK.
Clone this repository:
git clone https://github.com/GoogleCloudPlatform/community.git
The files for this tutorial are in the
Build the container iamge
cloudbuild.yamlby replacing the following values:
[PROJECT_ID]is your Google Cloud project ID.
[IMAGE_NAME]is the name of the container image.
Build the container image with Cloud Build:
gcloud builds submit --config cloudbuild.yaml .
When the build finishes, the image will be published to Container Registry.
Deploy the daemonset
agent.yamlby replacing the following values:
[PROJECT_ID]is your Google Cloud project ID
[IMAGE_NAME]is the name of the container image that you used when building the container image.
kubectl apply -f agent.yaml
Check that the daemonset deployed and is ready:
kubectl get ds
The output should be similar to the following, where [IMAGE_NAME] is the name of your container image:
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE [IMAGE_NAME] 1 1 1 1 1 <none> 29s
(optional) Customize the Cloud Monitoring agent
collectd.confto expose additional metrics.
- Add any new dependencies required for metric collection.
- Rebuild the container image and redeploy the daemonset.
Viewing the metrics
After deploying the daemonset, the additional metrics should begin to flow to Cloud Monitoring automatically. To view the metrics, go to the Monitoring page in the Cloud Console.
One way of examining metrics is using the Metrics Explorer. Because the new metrics being
collected are GKE node metrics, they are visible for the Compute Engine VM instance resource type with the metric names beginning with
If you take a detailed look at the node itself within Cloud Monitoring, you can see the additional metrics graphed within the VM instance dashboard agent tab. Go to the Dashboards page, and then click VM Instances and the instance you're interested in viewing metrics for.
Delete the daemonset:
kubectl delete ds [IMAGE_NAME]
Delete the cluster you created in the Before you begin section:
gcloud container clusters delete [CLUSTER_NAME]