Logstash解析进度条 [英] Logstash parsing progress bar

查看:217
本文介绍了Logstash解析进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Logstash的新手,并且将其用于解析特定目录中的500MB日志文件,目前,当我启动Logstash时,它不显示任何进度条来说明已完成解析的百分比日志文件.有什么方法可以查看日志解析的进度吗?

I'm a newbie to Logstash and I'm using it for parsing 500MB of logfiles in a particular directory, currently when i'm start logstash it doen't show any progress bar for how much % it has completed parsing the log file. Is there any way to see the progress of log parsing done?

推荐答案

否,Logstash没有内置进度条功能.在大多数情况下,这没有任何意义,因为Logstash旨在连续处理不断增长的日志,因此实际上没有任何完成".

No, Logstash has no built-in progress bar feature. Most of the time this wouldn't make any sense since Logstash is meant to process ever growing logs continuously, and then there isn't really any "done".

您可以做的是将sincedb文件的内容与相应文件的文件大小相关联. sincedb文件是Logstash将当前偏移量存储在文件中的位置.在文件输入的文档,但是您主要必须关心第一列和最后一列.第一列是索引节点号,也可以在文件的ls -li输出中找到该索引号,最后一列是当前偏移量.示例:

What you could do is correlate the contents of the sincedb file with the file size of the corresponding file. The sincedb file is where Logstash stores the current offset in a file. An exact description of the file format is found in the file input's documentation, but you mainly have to care about the first and last columns. The first column is the inode number, which can be also be found in the ls -li output for a file, and the last column is the current offset. Example:

393309 0 64773 437

在这里,对于具有inode 393309的文件,Logstash的偏移量为437.

Here, Logstash is at offset 437 for the file with inode 393309.

join命令可用于将文件与ls -li输出连接(文件的inode号在第一列中):

The join command can be used to join this file with the ls -li output (where the file's inode number is in the first column):

$ join /var/lib/logstash/.sincedb_f5fdf6ea0ea92860c6a6b2b354bfcbbc <(ls -li /var/log/syslog)
393309 0 64773 437 -rw-r----- 1 root adm 437 Oct 15 12:47 /var/log/syslog

最后,awk可用于清理输出并产生百分比完成的数字:

Finally, awk can be used to clean up the output and produce a percent-completed number:

$ join /var/lib/logstash/.sincedb_f5fdf6ea0ea92860c6a6b2b354bfcbbc <(ls -li /var/log/syslog) | awk '{ printf "%-30s%.1f%\n", $13, 100 * $4 / $9 }'
/var/log/syslog               100.0%

这篇关于Logstash解析进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆