【问题标题】:Stackdriver Logging - Log severity levels not reported/received when sent via syslogStackdriver 日志记录 - 通过 syslog 发送时未报告/接收的日志严重级别
【发布时间】:2017-05-21 10:26:55
【问题描述】:
日志严重性似乎没有通过 fluentd 代理传递到 Google Cloud Logging 平台,您可以尝试重现:
重击:
logger -p user.crit "My log"
或 PHP:
php -r "syslog(LOG_CRIT,'My log');"
或 Python:
import syslog
syslog.syslog(syslog.LOG_ERR, 'My log')
以下内容正在传递给 Google 日志查看器:
但是严重性没有被发送出去,任何想法为什么会这样?
【问题讨论】:
标签:
google-cloud-platform
syslog
rsyslog
google-cloud-logging
google-cloud-stackdriver
【解决方案1】:
好的,已经找到解决方案了,开始吧:
-
将/etc/rsyslog.conf 下的系统日志输出格式更新为以下内容:
$template googlelogger,"%syslogseverity-text% %timegenerated% %HOSTNAME% %syslogtag% %msg%\n"
$ActionFileDefaultTemplate googlelogger
-
然后更新/etc/google-fluentd/config.d/syslog.conf模板格式:
format /^(?<severity>[a-zA-Z]*) (?<time>[^ ]*\s*[^ ]* [^ ]*) (?<host>[^ ]*) (?<service>[a-zA-Z0-9_\/\.\-]*): *(?<message>.*)$/
time_format %b %d %H:%M:%S
确保在将严重性发送到 Google Cloud Logging 之后重新启动 rsyslog 和 google-fluentd