#a Sample Logstash configuration for creating a simple
# Beats -> Logstash -> Elasticsearch pipeline.

input {
 	 jdbc {
		type => "pub_active"
		jdbc_connection_string => "jdbc:mysql://10.0.0.14:3309/tczh_core?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
       	jdbc_password => "mysql@teetron.com.cn"
        jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
        jdbc_driver_class => "com.mysql.jdbc.Driver"
		jdbc_paging_enabled => "true"
		jdbc_page_size => "1000"
		statement_filepath => "/usr/local/logstash-7.6.2/config/ls/pub_active.sql"
        schedule => "*/5 * * * * *"
		record_last_run => "true"
		use_column_value => "true"
		tracking_column => "update_date"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/pub_active_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
	jdbc {
		type => "pub_course"
		jdbc_connection_string => "jdbc:mysql://10.0.0.14:3309/tczh_core?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
        jdbc_password => "mysql@teetron.com.cn"
        jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
        jdbc_driver_class => "com.mysql.jdbc.Driver"
        jdbc_paging_enabled => "true"
        jdbc_page_size => "1000"
        statement_filepath => "/usr/local/logstash-7.6.2/config/ls/pub_course.sql"
        schedule => "*/5 * * * * *"
        record_last_run => "true"
		use_column_value => "true"
		tracking_column => "update_date"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/pub_course_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
	jdbc {
		type => "pub_course_teacher"
		jdbc_connection_string => "jdbc:mysql://10.0.0.14:3309/tczh_core?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
		jdbc_password => "mysql@teetron.com.cn"
		jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
		jdbc_driver_class => "com.mysql.jdbc.Driver"
		jdbc_paging_enabled => "true"
		jdbc_page_size => "1000"
		statement_filepath => "/usr/local/logstash-7.6.2/config/ls/pub_course_teacher.sql"
		schedule => "*/5 * * * * *"
		record_last_run => "true"
		use_column_value => "true"
		tracking_column => "update_date"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/pub_course_teacher_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
	jdbc {
		type => "pub_culture"
		jdbc_connection_string => "jdbc:mysql://10.0.0.14:3309/tczh_core?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
		jdbc_password => "mysql@teetron.com.cn"
		jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
		jdbc_driver_class => "com.mysql.jdbc.Driver"
		jdbc_paging_enabled => "true"
		jdbc_page_size => "1000"
		statement_filepath => "/usr/local/logstash-7.6.2/config/ls/pub_culture.sql"
		schedule => "*/5 * * * * *"
		record_last_run => "true"
		use_column_value => "true"
		tracking_column => "update_date"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/pub_culture_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
	jdbc {
		type => "pub_news"
		jdbc_connection_string => "jdbc:mysql://10.0.0.14:3309/tczh_core?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
		jdbc_password => "mysql@teetron.com.cn"
		jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
		jdbc_driver_class => "com.mysql.jdbc.Driver"
		jdbc_paging_enabled => "true"
		jdbc_page_size => "1000"
		statement_filepath => "/usr/local/logstash-7.6.2/config/ls/pub_news.sql"
		schedule => "*/5 * * * * *"
		record_last_run => "true"
		use_column_value => "true"
		tracking_column => "update_date"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/pub_news_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
	jdbc {
		type => "pub_place"
		jdbc_connection_string => "jdbc:mysql://10.0.0.14:3309/tczh_core?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
		jdbc_password => "mysql@teetron.com.cn"
		jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
		jdbc_driver_class => "com.mysql.jdbc.Driver"
		jdbc_paging_enabled => "true"
		jdbc_page_size => "1000"
		statement_filepath => "/usr/local/logstash-7.6.2/config/ls/pub_place.sql"
		schedule => "*/5 * * * * *"
		record_last_run => "true"
		use_column_value => "true"
		tracking_column => "update_time"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/pub_place_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
	jdbc {
		type => "pub_resource"
		jdbc_connection_string => "jdbc:mysql://10.0.0.14:3309/tczh_core?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
		jdbc_password => "mysql@teetron.com.cn"
		jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
		jdbc_driver_class => "com.mysql.jdbc.Driver"
		jdbc_paging_enabled => "true"
		jdbc_page_size => "1000"
		statement_filepath => "/usr/local/logstash-7.6.2/config/ls/pub_resource.sql"
		schedule => "*/5 * * * * *"
		record_last_run => "true"
		use_column_value => "true"
		tracking_column => "update_date"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/pub_resource_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
	jdbc {
		type => "pub_venue"
		jdbc_connection_string => "jdbc:mysql://10.0.0.14:3309/tczh_core?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
		jdbc_password => "mysql@teetron.com.cn"
		jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
		jdbc_driver_class => "com.mysql.jdbc.Driver"
		jdbc_paging_enabled => "true"
		jdbc_page_size => "1000"
		statement_filepath => "/usr/local/logstash-7.6.2/config/ls/pub_venue.sql"
		schedule => "*/5 * * * * *"
		record_last_run => "true"
		use_column_value => "true"
		tracking_column => "last_update_time"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/pub_venue_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
	jdbc {
		type => "vol_team"
		jdbc_connection_string => "jdbc:mysql://10.0.0.14:3309/tczh_core?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
		jdbc_password => "mysql@teetron.com.cn"
		jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
		jdbc_driver_class => "com.mysql.jdbc.Driver"
		jdbc_paging_enabled => "true"
		jdbc_page_size => "1000"
		statement_filepath => "/usr/local/logstash-7.6.2/config/ls/vol_team.sql"
		schedule => "*/5 * * * * *"
		record_last_run => "true"
		use_column_value => "true"
		tracking_column => "update_date"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/vol_team_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
	jdbc {
		type => "bus_live"
		jdbc_connection_string => "jdbc:mysql://10.0.0.19:3309/bus_cloud?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
		jdbc_password => "mysql@teetron.com.cn"
		jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
		jdbc_driver_class => "com.mysql.jdbc.Driver"
		jdbc_paging_enabled => "true"
		jdbc_page_size => "1000"
		statement_filepath => "/usr/local/logstash-7.6.2/config/ls/bus_live.sql"
		schedule => "*/5 * * * * *"
		record_last_run => "true"
		use_column_value => "true"
		tracking_column => "update_time"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/bus_live_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
	jdbc {
		type => "bus_raise"
		jdbc_connection_string => "jdbc:mysql://10.0.0.19:3309/bus_cloud?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false"
		jdbc_user => "root"
		jdbc_password => "mysql@teetron.com.cn"
		jdbc_driver_library => "/usr/local/logstash-7.6.2/config/mysql-connector-java-8.0.23.jar"
		jdbc_driver_class => "com.mysql.jdbc.Driver"
		jdbc_paging_enabled => "true"
		jdbc_page_size => "1000"
		statement_filepath => "/usr/local/logstash-7.6.2/config/ls/bus_raise.sql"
		schedule => "*/5 * * * * *"
		record_last_run => "true"
		use_column_value => "true"
		tracking_column => "update_date"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "/usr/local/logstash-7.6.2/config/ls/bus_raise_update_time"
		clean_run => false
		jdbc_default_timezone => "UTC" 
	}
}


filter {
	json {  
		source => "message"  
        	remove_field => ["message"]  
	}  
	
} 

output {
	if [type] == "pub_active" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"  
			action => "update"
			doc_as_upsert => true
		}
	}
	if [type] == "pub_course" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"
			action => "update"
			doc_as_upsert => true
		}
	}
	if [type] == "pub_course_teacher" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"
			action => "update"
			doc_as_upsert => true
		}
	}
	if [type] == "pub_culture" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"
			action => "update"
			doc_as_upsert => true
		}
	}
	if [type] == "pub_news" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"
			action => "update"
			doc_as_upsert => true
		}
	}
	if [type] == "pub_place" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"
			action => "update"
			doc_as_upsert => true
		}
	}
	if [type] == "pub_resource" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"
			action => "update"
			doc_as_upsert => true
		}
	}
	if [type] == "pub_venue" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"
			action => "update"
			doc_as_upsert => true
		}
	}
	if [type] == "vol_team" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"
			action => "update"
			doc_as_upsert => true
		}
	}
	if [type] == "bus_live" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"
			action => "update"
			doc_as_upsert => true
		}
	}
	if [type] == "bus_raise" {
		elasticsearch {
			hosts => ["10.0.0.14:9200"]
			index => "pub_spool_index_data"
			document_id => "%{bus_code}"
			action => "update"
			doc_as_upsert => true
		}
	}

	stdout {
        	codec => json_lines
        }
}
