【发布时间】:2021-05-17 09:42:01
【问题描述】:
我正在学习如何使用 logstash,但在使用不断更新的 logstash 读取文件时遇到了一些问题。这是我的测试:
- logstash.conf
input {
file {
path => ["/usr/share/logs_data/first_log_test.log"]
start_position => "beginning"
}
}
filter {
grok {
match => ["message", "(?<execution_date>\d{4}-\d{2}-\d{2}) (?<execution_time>\d{2}:\d{2}:\d{2})%{GREEDYDATA}ParaBrutos/configs/pipelines/(?<crawler_category>([^/])+)/(?<crawler_subcategory>([^-])+)-(?<crawler_name>([^.])+).json"]
}
}
output {
elasticsearch {
hosts => "elasticsearch:9200"
user => "elastic"
password => "changeme"
ecs_compatibility => disabled
index => "logs_second"
}
}
首先,我使用this repo 的代码,以 dockerized 方式安装 ELK 堆栈。
我从这个空的测试日志文件开始,然后在文本编辑器中一一添加几行匹配该模式的行,同时在 kibana 更新中查看索引模式。但是,我在此测试日志中添加的每一行都不是单独添加的,而且我在 kibana 索引模式中看到了旧条目的命中。
会发生什么?
-
可能与在创建索引模式时不选择时间过滤器有关吗?
-
或与
since_db设置相关的内容?但是什么?因为默认情况下,不应该保存文件的最后读取位置吗? -
或与
start_position相关的东西?即使通过插件documentation,它应该只有在文件的第一次读取完成时才生效?
我有点迷茫,尝试了很多东西,但仍然不能很好地理解正在发生的事情。你能帮帮我吗?
【问题讨论】:
标签: elasticsearch logstash kibana elk kibana-7