未使用日志存储创建索引

zfciruhq  于 2021-06-15  发布在  ElasticSearch
关注(0)|答案(0)|浏览(240)

我使用elasticsearch和logstash[version:7.9.0]来可视化kibana的数据集。
我正在windows10上执行此任务。
日志存储配置文件-

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","reason":"no such index [cities]","resource.type":"index_or_alias","resource.id":"cities","index_uuid":"_na_","index":"cities"},"status":404}

另外,对于get请求到url:http://localhost:9200/\u目录/索引?v&P
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,
       "@version" => "1",
     "@timestamp" => 2020-08-26T04:58:01.231Z,
           "name" => "Kabul",
    "countrycode" => "IDN",
       "district" => "Uhjhgjh",
             "id" => 4082
}

但还是没有索引!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题