elasticsearch - 如何使用logstash在elasticsearch中上传csv文件?
问题描述
这是我的 logstash.conf 文件数据
input {
file {
path => "/home/niteshb/*.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
csv {
separator => ","
columns => ["tenant_id","hierarchy_name","attribute_name","item_pk"]
}
}
output {
elasticsearch {
hosts => "http://localhost:9200"
index => "plan_record"
}
stdout {}
}
并运行它我正在使用
bin/logstash -f logstash.conf
运行后遇到异常,异常是
] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of [A-Za-z0-9_-], [ \\t\\r\\n], \"#\", \"=>\" at line 9, column 6 (byte 138) after input {\n file {\n path => \"/home/niteshb/*.csv\"\n start_position => \"beginning\"\n sincedb_path => \"dev/NULL\"\n }\n\n filter {\n csv", :backtrace=>["/home/niteshb/Music/logstash-7.12.0/logstash-core/lib/logstash/compiler.rb:32:in `compile_imperative'", "org/logstash/execution/AbstractPipelineExt.java:184:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:69:in `initialize'", "/home/niteshb/Music/logstash-7.12.0/logstash-core/lib/logstash/java_pipeline.rb:47:in `initialize'", "/home/niteshb/Music/logstash-7.12.0/logstash-core/lib/logstash/pipeline_action/create.rb:52:in `execute'", "/home/niteshb/Music/logstash-7.12.0/logstash-core/lib/logstash/agent.rb:389:in `block in converge_state'"]}
[2021-04-26T18:15:40,601][INFO ][logstash.runner ] Logstash shut down.
[2021-04-26T18:15:40,611][FATAL][org.logstash.Logstash ] Logstash stopped processing because of an error: (SystemExit) exit
org.jruby.exceptions.SystemExit: (SystemExit) exit
有人可以帮我解决这个问题吗?我正在使用 linux 系统,但我不知道出了什么问题?
解决方案
正确格式化配置文件总是有帮助的。input
您只是在andfilter
部分的末尾缺少一个右花括号:
input {
file {
path => "/home/niteshb/*.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
} <--- add this
filter {
csv {
separator => ","
columns => ["tenant_id","hierarchy_name","attribute_name","item_pk"]
}
} <--- add this
output {
elasticsearch {
hosts => "http://localhost:9200"
index => "plan_record"
}
stdout {}
}
推荐阅读
- typescript - 使用 Realm、MongoDB (Atlas) 和 React Native 在用户之间共享和同步数据
- spring-boot - 如何在docker中为maven插件添加Jasypt解密密钥
- python - 使用字典方法搜索字符串格式中包含的值 - Python
- excel - 如何在 Excel 64 位中使用 VBA 连接到 IBM DB2 数据源
- mysql - MySQL 标签系统(3 个表) - 如何选择最后 10 个发布的帖子以及与每个帖子关联的所有标签?
- javascript - 带有 php 的 HTML5 Canvas API
- asp.net-core - 与 ASP.NET Core 中的 Cookie 回退进行协商
- python - 如何定义仅超类的方法?
- ios - 如何添加暂存/测试 Apple 服务器通知 url 以在应用程序信息中进行测试?
- c# - 类不是 AvaloniaProperty