4

I want to setup an export for logs generated in a Container-Optimized OS using Stackdriver Exports.

In case of Linux VM instance, I know that the logName is taken from the file like /etc/google-fluentd/config.d/[APPLICATION_NAME].conf. For example:
Below is the how /etc/google-fluentd/config.d/syslog.conf looks in a Linux VM:

<source>
  @type tail

  # Parse the timestamp, but still collect the entire line as 'message'
  format syslog

  path /var/log/syslog
  pos_file /var/lib/google-fluentd/pos/syslog.pos
  read_from_head true
  tag some-log-name
</source>

According to the above conf file the logName in StackDriver logs will be "projects/[PROJECT-NAME]/logs/some-log-name". Here is the resource which explains the configuration of Logging Agent, in case where the agent is installed manually.

Now, in the case of CONTAINER-OPTIMIZED OS, there is no folder named /etc/google-fluentd, and I am not able to find out the conf file where I change the logName to reflect in the StackDriver Log Viewer. As of now here is an example of log generated by this VM:

{
   insertId:  "some-random-id"  
   jsonPayload: {…}  
   logName:  "projects/[PROJECT-NAME]/logs/gcplogs-docker-driver"  
   receiveTimestamp:  "2019-03-28T13:10:31.609437487Z"
   resource: {…}  
   timestamp:  "2019-03-28T13:10:30.588317266Z"
}

In the above log, I don't know where gcplogs-docker-driver is coming from in the logName. I am looking for a way to change that.

(P.S. Changing the log name is important for me because, the sinks created to export logs in a google cloud bucket creates a directory whose name is identical to the logName tag (for logName: "projects/[PROJECT-NAME]/logs/gcplogs-docker-driver, a directory called gcplogs-docker-driver will be created.)

4

1 回答 1

3

现在,在 CONTAINER-OPTIMIZED OS 的情况下,没有名为 /etc/google-fluentd 的文件夹,并且我无法找到我更改 logName 以反映在 StackDriver 日志查看器中的 conf 文件。

/etc/google-fluentd文件夹用于存储 Stackdriver Logging 代理的配置文件(文档代码)。

在 Container-optimized OS 上,代理由stackdriver-logging.service容器化和管理,配置文件存储在/etc/stackdriver/logging.config.d.

您将需要运行sudo systemctl start stackdriver-logging以启动代理。

我不知道 gcplogs-docker-driver 在 logName 中来自哪里。我正在寻找一种方法来改变它。

这些日志实际上来自完全不同的来源。它们来自 Docker 日志记录驱动程序:Google Cloud Logging driver。查看文档,显然他们没有提供任何配置日志名称的方法。

并且查看他们的源代码,显然这个日志名称是硬编码在 Docker 的源代码中的。所以怕是没有好办法给gcplogs Docker日志驱动配置日志名。

于 2019-11-06T03:46:40.413 回答