How to export GKE's cluster autoscaler logs to an external logging service?

12/10/2019

I'd like to export the cluster autoscaler logs to something like elasticsearch. However due to the fact that the cluster autoscaler is running "internally" on GKE - means I don't have access to the node that would be running it (https://github.com/kubernetes/autoscaler/issues/972).

I can get the "events" from the Kubernetes API / kubectl get events... However this out isn't really in a friendly "log format".

How can I export these events to elasticsearch, or how can I get access to the GKE cluster autoscaler's logs?

-- Chris Stryczynski
google-kubernetes-engine
kubernetes

1 Answer

12/10/2019

For the reason that you pointed out (google-managed master), there is currently no way to get access to Cluster Autoscaler logs in Google Kubernetes Engine (GKE). However, if you have Stackdriver Logging enabled, then the Event Explorer can retrieve Cluster Autoscaler event logs. Please see the Stackdriver Filter below.

Note that, as of present, those event logs will only show actions that were taken and not why an action was not taken.

As for exporting these logs to Elasticsearch, the following two links 1 & 2 may be useful to you for exporting logs from Logging to an Elasticsearch cluster.

Stackdriver Filter:

resource.type="gke_cluster"
jsonPayload.source.component="cluster-autoscaler"
logName="projects/[project]/logs/events"
resource.labels.cluster_name="[cluster name]"
-- Vivak P
Source: StackOverflow