使用rails弹性beanstalk配置rsyslog

时间:2022-06-26 04:27:58

I config remote loging for rails application with elastic beanstalk. I want to get logs from /var/log/puma/puma.log but only get some kernel and system informations. This is my config .ebextensions/papertrail.config

我使用弹性beanstalk为rails应用程序配置远程登录。我想从/var/log/puma/puma.log获取日志,但只获取一些内核和系统信息。这是我的配置.ebextensions / papertrail.config

packages:
  yum:
    rsyslog: []
    rsyslog-gnutls: []
files:
  "/etc/rsyslog.d/01-udp.conf":
    mode: "000640"
    owner: root
    group: root
    content: |
      $ModLoad imudp
      $UDPServerRun 514
  "/etc/rsyslog.d/02-papertrail-tls.conf":
    mode: "000640"
    owner: root
    group: root
    content: |
      $DefaultNetstreamDriverCAFile /etc/papertrail-bundle.pem # trust these CAs
      $ActionSendStreamDriver gtls # use gtls netstream driver
      $ActionSendStreamDriverMode 1 # require TLS
      $ActionSendStreamDriverAuthMode x509/name # authenticate by hostname
      $ActionSendStreamDriverPermittedPeer *.papertrailapp.com
  "/etc/rsyslog.d/03-logfile-config.conf":
    mode: "000640"
    owner: root
    group: root
    content: |
      $ModLoad imfile
      $InputFileName /var/log/puma/puma.log
      $InputFileTag api
      $InputFileStateFile api-staging
      $InputFileSeverity error
      $InputFileFacility local3
      $InputRunFileMonitor
  "/etc/rsyslog.d/04-papertrail.conf":
    mode: "000640"
    owner: root
    group: root
    content: |
      $LocalHostName api-staging

container_commands:
  01_copy_ca_certs:
    command: 'cp ./.ebextensions/papertrail-bundle.pem /etc/papertrail-bundle.pem'
  02_install_rsyslog_config:
    command: '/bin/echo "*.* @${SYSLOG_HOST}" >> /etc/rsyslog.d/04-papertrail.conf'
  03_restart_rsyslog:
    command: 'sudo service rsyslog restart'

But I only get some info on papertrail like these:

但我只得到关于papertrail的一些信息,如下:

Nov 03 21:28:00 api-staging kernel:  imklog 5.8.10, log source = /proc/kmsg started.
Nov 03 21:28:00 api-staging rsyslogd:  [origin software="rsyslogd" swVersion="5.8.10" x-pid="32340" x-info="http://www.rsyslog.com"] start
Nov 03 23:50:41 api-staging kernel:  Kernel logging (proc) stopped.
Nov 03 23:50:41 api-staging rsyslogd:  [origin software="rsyslogd" swVersion="5.8.10" x-pid="32340" x-info="http://www.rsyslog.com"] exiting on signal 15.
Nov 04 00:51:56 api-staging kernel:  imklog 5.8.10, log source = /proc/kmsg started.
Nov 04 00:51:56 api-staging rsyslogd:  [origin software="rsyslogd" swVersion="5.8.10" x-pid="15883" x-info="http://www.rsyslog.com"] start
Nov 04 00:53:42 api-staging kernel:  Kernel logging (proc) stopped.

Please help me if you have experience for this issue. Thank you!

如果您有此问题的经验,请帮助我。谢谢!

1 个解决方案

#1


1  

There are a number of potential problems you could be encountering, too many to enumerate here. Your approach is complicated significantly by the inclusion of file access in the logging system. Simply trying to scrape a log file (puma.log) is fragile at best and depending on your deployment environment could result in many possible obscure failures.

您可能会遇到许多潜在的问题,这里列举的内容太多了。通过在日志记录系统中包含文件访问,您的方法非常复杂。简单地尝试刮取日志文件(puma.log)最多是脆弱的,并且取决于您的部署环境可能会导致许多可能的模糊失败。

My suspicion is that the logging data is not being delivered to the logging daemon at all, therefore never getting delivered to PaperTrail.

我怀疑日志数据根本没有传递给日志记录守护程序,因此永远不会传递给PaperTrail。

I suggest you reconfigure your application to communicate directly with the logging daemon via UDP as explained here:

我建议你重新配置你的应用程序,通过UDP直接与日志记录守护进程通信,如下所述:

https://www.thoughtworks.com/mingle/infrastructure/2015/06/10/simple-solution-for-papertrail-on-elasticbeanstalk.html

https://www.thoughtworks.com/mingle/infrastructure/2015/06/10/simple-solution-for-papertrail-on-elasticbeanstalk.html

Once you have made this change I suspect your problem will resolve. At the very least it will be come easier to troubleshoot, and will be more reliable in the future.

一旦你做了这个改变,我怀疑你的问题会解决。至少可以更容易地进行故障排除,并且将来会更加可靠。

#1


1  

There are a number of potential problems you could be encountering, too many to enumerate here. Your approach is complicated significantly by the inclusion of file access in the logging system. Simply trying to scrape a log file (puma.log) is fragile at best and depending on your deployment environment could result in many possible obscure failures.

您可能会遇到许多潜在的问题,这里列举的内容太多了。通过在日志记录系统中包含文件访问,您的方法非常复杂。简单地尝试刮取日志文件(puma.log)最多是脆弱的,并且取决于您的部署环境可能会导致许多可能的模糊失败。

My suspicion is that the logging data is not being delivered to the logging daemon at all, therefore never getting delivered to PaperTrail.

我怀疑日志数据根本没有传递给日志记录守护程序,因此永远不会传递给PaperTrail。

I suggest you reconfigure your application to communicate directly with the logging daemon via UDP as explained here:

我建议你重新配置你的应用程序,通过UDP直接与日志记录守护进程通信,如下所述:

https://www.thoughtworks.com/mingle/infrastructure/2015/06/10/simple-solution-for-papertrail-on-elasticbeanstalk.html

https://www.thoughtworks.com/mingle/infrastructure/2015/06/10/simple-solution-for-papertrail-on-elasticbeanstalk.html

Once you have made this change I suspect your problem will resolve. At the very least it will be come easier to troubleshoot, and will be more reliable in the future.

一旦你做了这个改变,我怀疑你的问题会解决。至少可以更容易地进行故障排除,并且将来会更加可靠。