问题描述
我正在使用带logstash的elasticsearch [版本:7.9.0]来显示带有kibana的数据集。
我正在Windows10上执行此任务。
Logstash配置文件-
input {
jdbc {
jdbc_driver_library => "$PATH\mysql-connector-java-5.1.46.jar"
jdbc_driver_class => "com.MysqL.jdbc.Driver"
jdbc_connection_string => "jdbc:MysqL://localhost:3306/world?autoReconnect=true&useSSL=false"
jdbc_user => root
jdbc_password => herculus
parameters => { "names" => "Kabul" }
statement => "SELECT count(*) FROM world.city where name = :names;"
schedule => " * * * * * *"
}
}
output {
elasticsearch {
document_id => "%{id}"
document_type => city
index => cities
hosts => ["http://localhost:9200"]
}
stdout{
codec => rubydebug
}
}
响应curl命令,
logstash-7.9.0\bin>curl -X GET "localhost:9200/cities/_search"
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [cities]","resource.type":"index_or_alias","resource.id":"cities","index_uuid":"_na_","index":"cities"}],"type":"index_not_found_exception","index":"cities"},"status":404}
此外,要获取对URL的请求: http:// localhost:9200 / _cat / indices?v&pretty
O / P-
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
当我将logstash.conf更新为时,
input {
jdbc {
jdbc_driver_library => "$PATH\mysql-connector-java-5.1.46.jar"
jdbc_driver_class => "com.MysqL.jdbc.Driver"
jdbc_connection_string => "jdbc:MysqL://localhost:3306/world?autoReconnect=true&useSSL=false"
jdbc_user => root
jdbc_password => herculus
parameters => { "names" => "Kabul" }
statement => "SELECT * FROM world.city where name = :names;"
schedule => " * * * * * *"
}
}
output {
if "world.city" in [tags] {
elasticsearch {
# document_id => "%{id}"
# document_type => city
index => "cities"
hosts => ["http://localhost:9200"]
}
}
stdout{
codec => rubydebug
}
}
我得到回应
[2020-08-26T10:28:01,229][INFO ][logstash.inputs.jdbc ][main][3b01a5ef336ad85c3946fe6866ca42078069f817e05ec92d17e8ab77baa85416] (0.002075s) SELECT * FROM world.city where name = 'Kabul';
{
"population" => 100000,"@version" => "1","@timestamp" => 2020-08-26T04:58:01.231Z,"name" => "Kabul","countrycode" => "IDN","district" => "Yasjdasjk","id" => 4081
}
{
"population" => 10000,"district" => "Uhjhgjh","id" => 4082
}
但是仍然没有索引!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)