Skip to main content

Logstash 命令行查询工具,有点像 Logstash/ElasticSearch 的 tail

项目描述

派皮 文件状态 特拉维斯 CI Python 版本 执照

从 ElasticSearch 查询日志事件的命令行工具,有点像 Logstash/ElasticSearch 的 tail。

Lstail 在 ElasticSearch 中查询日志事件并将其显示在终端上。Kibana 中保存的搜索可用于快速访问过滤器和准备好的列配置。有关更多详细信息和使用示例,请参阅https://lstail.org/上的文档。

特征

  • 跟随模式,如tail -f
  • CSV 输出/导出
  • 可以从 ElasticSearch 读取保存的搜索并使用它们的过滤器和列设置
  • 列、颜色和填充的灵活可配置输出
  • 如果不能直接 ElasticSearch 连接,则可以通过 Kibana 代理
  • 适用于 ElasticSearch 2.x - 7.x
  • 用 Python 和爱制作

lstail 使用演示

安装

Lstail 需要 Python 3.5 或更高版本。最简单的方法是使用 pip 直接从 pypi 安装:

pip install lstail

如果您愿意,可以下载 lstail 并直接从源代码安装:

python setup.py install

获取源

源代码可在https://github.com/eht16/lstail/获得。

设置

在使用 Lstail 之前,您需要创建一个名为lstail.conf. Lstail 将在以下位置搜索lstail.conf(按此顺序):

  • /etc/lstail.conf
  • ~/.config/lstail.conf
  • lstail.conf(在当前工作目录中)

--config或者,您可以使用命令行参数指定要读取的配置文件的名称。

示例配置文件可以在源代码中找到,也可以在https://raw.githubusercontent.com/eht16/lstail/master/lstail-example.conf在线找到。在配置文件中修改的重要部分是server必须编辑的部分,以指向您的 ElasticSearch 实例以从中查询数据。

有关所有配置选项的详细信息,请参阅文档: https ://lstail.org/ 。

用法

显示十分钟后的事件(来自配置的索引模式):

lstail -r 10m

显示最后 20 个事件(来自配置的索引模式):

lstail -n 20

显示与给定查询匹配的所有事件:

lstail -q 'host: google.com'

列出来自 Kibana 的已保存搜索:

lstail -l

使用保存的搜索“Syslog”显示和跟踪事件(使用 Ctrl-C 中断):

lstail -s Syslog -f

覆盖已保存搜索“Syslog”的搜索查询(即忽略存储在已保存搜索中的查询,但使用配置的列):

lstail -s Syslog -q program:cron

命令行选项

usage: lstail [-h] [-V] [-d] [-v] [-c FILE] [-f] [-l] [-H] [--csv]
              [-n NUM] [-q QUERY] [-r RANGE] [-s NAME] [--select-saved-search]

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show version and exit (default: False)
  -d, --debug           enable tracebacks (default: False)
  -v, --verbose         Show own log messages (default: False)
  -c FILE, --config FILE
                        configuration file path (default: None)
  -f, --follow          Constantly fetch new data from ElasticSearch (default: False)
  -l, --list-saved-searches
                        List all saved searches from Kibana (default: False)
  -H, --no-header       Do not print header line before the output (default: False)
  --csv                 Use CSV (comma separated) output (default: False)
  -n NUM, --lines NUM   Output the last NUM lines, instead of the last 10 (default: None)
  -q QUERY, --query QUERY
                        Set/Overwrite the search query (use Lucene query syntax) (default: None)
  -r RANGE, --range RANGE
                        Query events from the last RANGE minutes(m)/hours(h)/days(d) (default: None)
  -s NAME, --saved-search NAME
                        Saved search title as stored in Kibana ("-" to select from a list) (default: None)
  --select-saved-search
                        Interactively select a saved search from a list (default: False)

贡献

发现错误或收到功能请求?请在 https://github.com/eht16/lstail/issues报告。

作者

Enrico Tröger enrico.troeger@uvena.de

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

lstail-1.1.0.tar.gz (34.1 kB 查看哈希

已上传 source

内置分布

lstail-1.1.0-py3-none-any.whl (40.0 kB 查看哈希

已上传 py3