我怎样才能告诉 logstash 通过 ssh 读取文件
How can I tell logstash to read file over ssh
使用 ELK 堆栈,我必须解析一些文件,但它们是远程的。
我的解决方案
- rsync 通过 ssh 在本地获取远程文件
我担心的是我的 elasticsearch 索引呈指数增长(超过 130MB),而日志文件只有 25MB。
是否有可能每个 rsync cron (*/5 mn) 导致 logstash 再次读取整个文件而不使用 sincedb 东西?
感谢您的帮助:)
上下文,我使用 acquia 作为 drupal 站点的主机,因此我无法控制如何访问日志文件
纪尧姆·雷纳德
Logstash 通过 inode 编号和文件内的位置(偏移量)跟踪文件。 运行 rsync 一次,检查 inode,运行 再检查一次,然后再检查。
ls -i logfile.txt
如果它们有相同的 inode 编号,logstash 应该没问题。
因为我想查看 acquia 的日志,所以我尝试了另一种方法,使用日志流 (https://github.com/acquia/logstream) and supervisord (http://supervisord.org/introduction.html),它节省了我的时间。
...
[program:logstream_artecinema_drupal-watchdog]
command=logstream tail prod:artetv prod --no-color --types=drupal-watchdog
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/logstream/artecinema_drupal-watchdog.log
stdout_logfile_maxbytes=20MB
stdout_logfile_backups=7
environment=HOME="/root"
...
我的 logstash 读取日志文件
file {
path => "/var/log/logstream/artecinema_drupal-watchdog.log"
start_position => "beginning"
type => "drupal-watchdog"
add_field => { "platform" => "cinema" }
}
为 rsync 命令添加选项:
--append
它在末尾添加了新行。它还暗示 --inplace
保留 inode。
使用 ELK 堆栈,我必须解析一些文件,但它们是远程的。 我的解决方案
- rsync 通过 ssh 在本地获取远程文件
我担心的是我的 elasticsearch 索引呈指数增长(超过 130MB),而日志文件只有 25MB。 是否有可能每个 rsync cron (*/5 mn) 导致 logstash 再次读取整个文件而不使用 sincedb 东西?
感谢您的帮助:)
上下文,我使用 acquia 作为 drupal 站点的主机,因此我无法控制如何访问日志文件
纪尧姆·雷纳德
Logstash 通过 inode 编号和文件内的位置(偏移量)跟踪文件。 运行 rsync 一次,检查 inode,运行 再检查一次,然后再检查。
ls -i logfile.txt
如果它们有相同的 inode 编号,logstash 应该没问题。
因为我想查看 acquia 的日志,所以我尝试了另一种方法,使用日志流 (https://github.com/acquia/logstream) and supervisord (http://supervisord.org/introduction.html),它节省了我的时间。
...
[program:logstream_artecinema_drupal-watchdog]
command=logstream tail prod:artetv prod --no-color --types=drupal-watchdog
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/logstream/artecinema_drupal-watchdog.log
stdout_logfile_maxbytes=20MB
stdout_logfile_backups=7
environment=HOME="/root"
...
我的 logstash 读取日志文件
file {
path => "/var/log/logstream/artecinema_drupal-watchdog.log"
start_position => "beginning"
type => "drupal-watchdog"
add_field => { "platform" => "cinema" }
}
为 rsync 命令添加选项:
--append
它在末尾添加了新行。它还暗示 --inplace
保留 inode。