[英]How to upload csv file in elasticsearch using logstash?
這是我的 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
和filter
部分的末尾缺少一個右花括號:
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 {}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.