Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input{
- jdbc {
- jdbc_driver_library => "/home/user/logstash/mysql-connector-java-5.1.17-bin.jar"
- jdbc_driver_class => "com.mysql.jdbc.Driver"
- jdbc_connection_string => "jdbc:mysql://[remotehostipnumber]/databasename"
- jdbc_validate_connection => true
- jdbc_user => "username"
- jdbc_password => "password"
- schedule => "* * * * *"
- statement => "select * from table"
- }
- }
- output
- {
- elasticsearch
- {
- index => "tables"
- document_type => "table"
- document_id => "%{table_id}"
- hosts => "localhost:9200"
- }stdout { codec => json_lines }
- }
- sudo /opt/logstash/bin/logstash --configtest -f /home/user/logstash/logstash.conf
- Settings: Default filter workers: 1
- Logstash startup completed
- curl -XGET 'localhost:9200/tables/table/_search?pretty=true'
- {
- "error" : {
- "root_cause" : [ {
- "type" : "index_not_found_exception",
- "reason" : "no such index",
- "resource.type" : "index_or_alias",
- "resource.id" : "tables",
- "index" : "table"
- } ],
- "type" : "index_not_found_exception",
- "reason" : "no such index",
- "resource.type" : "index_or_alias",
- "resource.id" : "tables",
- "index" : "tables"
- },
- "status" : 404
- }
- echo '{
- "type":"jdbc",
- "jdbc":{
- "url":"jdbc:mysql://localhost:3306/your_database_name",
- "user":"your_database_username",
- "password":"your_database_password",
- "useSSL":"false",
- "sql":"SELECT * FROM table1",
- "index":"Index_name",
- "type":"Index_type",
- "poll" : "6s",
- "autocommit":"true",
- "metrics": {
- "enabled" : true
- },
- "elasticsearch" : {
- "cluster" : "clustername",
- "host" : "localhost",
- "port" : 9300
- }
- }
- }' | 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