logstash安装 window版

  • 1.首先下载logstash window版

官网最新版本:https://artifacts.elastic.co/downloads/logstash/logstash-7.5.1.zip

  • 2.解压
  • 3.配置问价

新建一个my-link的文件夹

下载下面的驱动放到该目录下

链接:https://pan.baidu.com/s/1Epgbk53Gbgba8g066hHzQw

提取码:4gec

在新建一个sqlserver-es.conf文件,文件内容如下,根据自己的实际情况来改变

input {
    jdbc {
        jdbc_driver_library => "E:/logstash/logstash-6.8.3/my-link/sqljdbc4.jar"
        jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
        jdbc_connection_string => "jdbc:sqlserver://192.168.1.211:1433;databaseName=zljdpt-xfp;"
        jdbc_user => "sa"
        jdbc_password => "zcy123456.."
        jdbc_default_timezone => "Asia/Shanghai"
		jdbc_paging_enabled => "true"
		record_last_run => true
		use_column_value => true
		tracking_column => "xgsj"
		tracking_column_type => "timestamp"
		last_run_metadata_path => "E:/logstash/logstash-6.8.3/my-link/consumer_statistics_xgsj"
		clean_run => false
		statement => "SELECT * FROM v_test WHERE xgsj>:sql_last_value and xgsj "*/5 * * * * *"
    }
}
filter {
	if ![shzt]{ruby{code =>'event.set("shzt","")'}}
	if ![xfbj]{ruby{code =>'event.set("xfbj","")'}}
	if ![jb]{ruby{code =>'event.set("jb","")'}}
	if ![tjjb]{ruby{code =>'event.set("tjjb","")'}}
	if "," in [jyfsdm]{
		ruby{
			code =>
			'
				jyfsdm=event.get("jyfsdm")
				jyfsdmSplit=jyfsdm.split(",")
				jyfsdmUniq=jyfsdmSplit.uniq
				jyfsdmLength=jyfsdmUniq.length
				jyfsdmLengthFinaly=jyfsdmLength-1
				jyfsdmFinaly=""
				for i in 0..jyfsdmLengthFinaly
					jyfsdmFinaly=jyfsdmFinaly+jyfsdmUniq[i]+" "
				end
				event.set("jyfsdm",jyfsdmFinaly)	
			'
		}
	}
	if "," in [cpdm]{
		ruby{
			code =>
			'
				cpdm=event.get("cpdm")
				cpdmSplit=cpdm.split(",")
				cpdmUniq=cpdmSplit.uniq
				cpdmLength=cpdmUniq.length
				cpdmLengthFinaly=cpdmLength-1
				cpdmFinaly=""
				for i in 0..cpdmLengthFinaly
					cpdmFinaly=cpdmFinaly+cpdmUniq[i]+" "
				end
				event.set("cpdm",cpdmFinaly)	
			'
		}
	}	
	mutate{
		convert => { "entid" => "integer" }
		remove_field => ["@timestamp"]
		remove_field => ["@version"]
	}
}
output {
		elasticsearch {
			hosts => ["192.168.1.211:9200"]
			index => "consumer_statistics"
			document_id => "%{entid}"
			document_type => "consumer_statistics"
			template_name => "consumer_statistics"
		}
}
  • 4. 然后在在桌面新建一个txt文件

内容如下:

E:
cd E:\logstash\logstash-6.8.3\bin
logstash.bat -f E:\logstash\logstash-6.8.3\my-link\sqlserver-es.conf

到这里logstash就安装完成了,启动之前先启动es数据库,搞定

  • 5 浏览器访问:http://localhost:9600/

你可能感兴趣的:(logstash)