Google Kubernetes Engine (GKE) Cluster Log Integration with Stackdriver Logging

Configure Log Integration for Third-Party Containerized Application

Question

You have a set of applications running on a Google Kubernetes Engine (GKE) cluster, and you are using Stackdriver Kubernetes Engine Monitoring.

You are bringing a new containerized application required by your company into production.

This application is written by a third party and cannot be modified or reconfigured.

The application writes its log information to /var/log/app_messages.log, and you want to send these log entries to Stackdriver Logging.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

B.

https://cloud.google.com/solutions/customizing-stackdriver-logs-fluentd

The correct answer for this scenario is B. Deploy a Fluentd daemonset to GKE.

Fluentd is an open-source data collector designed to unify the data collection and consumption process. It has a pluggable architecture that allows it to handle various data sources and destinations. Fluentd can collect log data from various sources, including files, Syslog, and TCP/UDP sockets, and send them to various destinations, including Elasticsearch, Amazon S3, and Google Cloud Storage.

In this scenario, the application writes its log information to a file located at /var/log/app_messages.log within the container. To forward these log entries to Stackdriver Logging, we need to use a tool that can read the log file and send the log entries to Stackdriver Logging. Fluentd is one such tool that can accomplish this task.

The recommended solution is to deploy a Fluentd daemonset to the GKE cluster. A daemonset ensures that one instance of the Fluentd pod runs on each node in the cluster. This approach ensures that Fluentd can collect log data from all the pods running on the cluster and forward it to Stackdriver Logging.

The deployment process for Fluentd is as follows:

  1. Deploy the Fluentd daemonset to the GKE cluster: To deploy a Fluentd daemonset, you can create a YAML configuration file that specifies the Fluentd container and its configuration settings. This file is then used to create the daemonset using the kubectl command.

  2. Configure Fluentd to collect log data from the application: Once Fluentd is deployed, you need to configure it to collect log data from the /var/log/app_messages.log file within the application container. This configuration can be done using a Fluentd configuration file, which can be mounted as a ConfigMap within the Fluentd container.

  3. Configure Fluentd to forward log data to Stackdriver Logging: After collecting log data, Fluentd needs to forward it to Stackdriver Logging. This can be done using the Google Cloud plugin for Fluentd, which provides a fluent-plugin-google-cloud component. This component allows Fluentd to send log data to Stackdriver Logging using the Google Cloud Logging API.

In summary, to send log entries from a new containerized application to Stackdriver Logging, we need to deploy a Fluentd daemonset to the GKE cluster, configure Fluentd to collect log data from the application, and configure Fluentd to forward log data to Stackdriver Logging using the Google Cloud plugin for Fluentd.