Guest User

Untitled

a guest
May 24th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. input{
  2.  
  3. jdbc {
  4. jdbc_driver_library => "/home/user/logstash/mysql-connector-java-5.1.17-bin.jar"
  5.  
  6. jdbc_driver_class => "com.mysql.jdbc.Driver"
  7.  
  8. jdbc_connection_string => "jdbc:mysql://[remotehostipnumber]/databasename"
  9.  
  10. jdbc_validate_connection => true
  11.  
  12. jdbc_user => "username"
  13.  
  14. jdbc_password => "password"
  15.  
  16. schedule => "* * * * *"
  17.  
  18. statement => "select * from table"
  19.  
  20. }
  21.  
  22. }
  23.  
  24. output
  25.  
  26. {
  27. elasticsearch
  28. {
  29.  
  30. index => "tables"
  31. document_type => "table"
  32. document_id => "%{table_id}"
  33. hosts => "localhost:9200"
  34. }stdout { codec => json_lines }
  35. }
  36.  
  37. sudo /opt/logstash/bin/logstash --configtest -f /home/user/logstash/logstash.conf
  38.  
  39. Settings: Default filter workers: 1
  40. Logstash startup completed
  41.  
  42. curl -XGET 'localhost:9200/tables/table/_search?pretty=true'
  43.  
  44. {
  45. "error" : {
  46. "root_cause" : [ {
  47. "type" : "index_not_found_exception",
  48. "reason" : "no such index",
  49. "resource.type" : "index_or_alias",
  50. "resource.id" : "tables",
  51. "index" : "table"
  52. } ],
  53. "type" : "index_not_found_exception",
  54. "reason" : "no such index",
  55. "resource.type" : "index_or_alias",
  56. "resource.id" : "tables",
  57. "index" : "tables"
  58. },
  59. "status" : 404
  60. }
  61.  
  62. echo '{
  63. "type":"jdbc",
  64. "jdbc":{
  65.  
  66. "url":"jdbc:mysql://localhost:3306/your_database_name",
  67. "user":"your_database_username",
  68. "password":"your_database_password",
  69. "useSSL":"false",
  70. "sql":"SELECT * FROM table1",
  71. "index":"Index_name",
  72. "type":"Index_type",
  73. "poll" : "6s",
  74. "autocommit":"true",
  75. "metrics": {
  76. "enabled" : true
  77. },
  78. "elasticsearch" : {
  79. "cluster" : "clustername",
  80. "host" : "localhost",
  81. "port" : 9300
  82. }
  83. }
  84. }' | java -cp "/etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/lib/*" -"Dlog4j.configurationFile=file:////etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/bin/log4j2.xml" "org.xbib.tools.Runner" "org.xbib.tools.JDBCImporter"
Add Comment
Please, Sign In to add comment