elasticsearch - 如何在两个单独的服务器之间使用 Logstash 将日志从文件发送到 Elasticsearch?
问题描述
我尝试logs.csv
使用 Logstash 将日志从文件发送到 elasticsearch。在 Elasticsearch 中,我有类型为 log 的索引日志。此刻我logstash.conf
是这样看的:
input {
file {
path => "/run/shm/elastic/logstash/logs.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
csv {
columns => ["logs"]
}
}
output {
elasticsearch {
hosts => "hostaddress:9200"
index => "logs"
document_type => "log"
user => "elastic"
password => "elastic"
}
stdout {}
}
Logstash 似乎配置正确,因为例如sudo ./logstash -e 'input { stdin { } } output { stdout {} }'
可以正常工作。但是我得到如下所示的错误。有任何想法吗?
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
[WARN ] 2018-07-11 10:48:27.473 [LogStash::Runner] multilocal - Ignoring the 'pipelines.yml' file because modules or command line options are specified
[FATAL] 2018-07-11 10:48:27.510 [LogStash::Runner] runner - Logstash could not be started because there is already another instance using the configured data directory. If you wish to run multiple instances, you must change the "path.data" setting.
[ERROR] 2018-07-11 10:48:27.522 [LogStash::Runner] Logstash - java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit
解决方案
发生此错误是因为 Logstash 的另一个实例仍在运行。您应该在 Linux 中将 Logstash 作为服务启动,而不是直接启动它,例如在 RHEL 上您应该开始使用:
service logstash start
并停止
service logstash stop
您可以在此链接下找到其他系统的命令。
但有时 Logstash 会停滞不前,您必须手动将其杀死
ps aux | grep logstash
找到 Logstash 的 PID 并杀死它:
kill -9 LOGSTASH_PID
大多数情况下,Logstash 无法以标准方式停止,因为它正在处理一些数据,但您可以通过添加服务启动文件来强制 Logstash 停止,您可以在此处--pipeline.unsafe_shutdown
阅读更多相关信息。
推荐阅读
- android - 安卓 | 科特林 | PreferenceFragmentCompat 与 BottomNavigationView 重叠
- r - 替换有0行,数据有1400?
- outlook - 防止 Outlook 2016 Windows 调整表格单元格的大小
- python - 如何在同一个 Pandas DataFrame 中切换列值
- model - 如何使用 Fairlearn 指标来决定一项功能是否有偏见?
- amazon-web-services - AWS IoT 1 单击项目 SAM - 400 InvalidRequestException 错误
- google-sheets - 单个 Google 表格过滤器视图可以同时在多列中显示 OR 条件吗?
- machine-learning - 将 pytorch 模型转换为 nn.Module 以导出到镜头工作室的 onnx
- android - 使用导航组件导航出 ViewPager 选项卡
- excel - VBA:搜索第一个字符串实例的列并分配给新数组或字符串