Home Explore Blog CI



kubernetes

10th chunk of `content/en/blog/_posts/2015-06-00-Cluster-Level-Logging-With-Kubernetes.md`
cf8b519c562a2a47ce6df731b4e3291b978d53761adeed000000000100000998
This log collection pod has a specification which looks something like this [fluentd-gcp.yaml](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/cluster/saltbase/salt/fluentd-gcp/fluentd-gcp.yaml):

```
apiVersion: v1

kind: Pod

metadata:

  name: fluentd-cloud-logging

spec:

  containers:

  - name: fluentd-cloud-logging

    image: gcr.io/google\_containers/fluentd-gcp:1.6

    env:

    - name: FLUENTD\_ARGS

      value: -qq

    volumeMounts:

    - name: containers

      mountPath: /var/lib/docker/containers

  volumes:

  - name: containers

    hostPath:

      path: /var/lib/docker/containers
  ```

This pod specification maps the directory on the host containing the Docker log files, /var/lib/docker/containers, to a directory inside the container which has the same path. The pod runs one image, gcr.io/google\_containers/fluentd-gcp:1.6, which is configured to collect the Docker log files from the logs directory and ingest them into Google Cloud Logging. One instance of this pod runs on each node of the cluster. Kubernetes will notice if this pod fails and automatically restart it.


We can click on the Logs item under the Monitoring section of the Google Developer Console and select the logs for the counter container, which will be called kubernetes.counter\_default\_count.  This identifies the name of the pod (counter), the namespace (default) and the name of the container (count) for which the log collection occurred. Using this name we can select just the logs for our counter container from the drop down menu:



_(image-counter-new-logs.png)_  

When we view the logs in the Developer Console we observe the logs for both invocations of the container.  

_(image-screenshot-2015-06-02)_


Note the first container counted to 108 and then it was terminated. When the next container image restarted the counting process resumed from 0. Similarly if we deleted the pod and restarted it we would capture the logs for all instances of the containers in the pod whenever the pod was running.  



Logs ingested into Google Cloud Logging may be exported to various other destinations including [Google Cloud Storage](https://cloud.google.com/storage/) buckets and [BigQuery](https://cloud.google.com/bigquery/). Use the Exports tab in the Cloud Logging console to specify where logs should be streamed to (or follow this link to the [settings tab](https://pantheon.corp.google.com/project/_/logs/settings)).

Title: Viewing and Exporting Logs in Google Cloud Logging
Summary
This section elaborates on how to view the collected logs in Google Cloud Logging via the Google Developer Console, specifically focusing on the logs for the 'counter' container. It emphasizes that logs from all invocations of the container, even after restarts, are preserved. The section concludes by mentioning the ability to export these logs to other destinations like Google Cloud Storage and BigQuery using the Cloud Logging console.