logstash jdbc mssql output
ELK/logstash2020. 7. 4. 06:31
input {
elasticsearch {
hosts => "localhost:9200"
index => "server_kimjh"
query => '{ "query": { "match_all": {} } }'
size => 100
scroll => "2m"
}
}
output {
stdout { codec => rubydebug }
jdbc {
connection_string => "jdbc:sqlserver://localhost:1433;databaseName=server_kimjh;user=kimjh;password=P@ssw0rd!"
driver_jar_path => "C:/Users/EZFARM/Desktop/jar_/sqljdbc/sqljdbc4.jar"
driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
unsafe_statement => true
statement => ["INSERT INTO stu_info (stu_name, stu_age) VALUES(?,?)", "%{stu_name}", "%{stu_age}"]
}
}
input 에 의해서 내려오는 결과값은 한개씩 output 으로 던진다.
input 부분
>curl -XGET localhost:9200/server_kimjh/_mapping?pretty { "server_kimjh" : { "mappings" : { "_doc" : { "properties" : { "stu_age" : { "type" : "long" }, "stu_name" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } } } } } } } |
stu_age 의 field 타입은 long
stu_name 의 field 타입은 text
elasticsearch plugin
=> hosts : 노드의 개수에 따라 array로 표현하면 된다. ["https://xxx.xxx.xxx.xxx:9200", "https://xxx.xxx.xxx.xxx:9200","https://xxx.xxx.xxx.xxx:9200"]
=> query : 개인적으로 아쉬운 부분이긴한데 inline의 형태로 string 으로 입력되어야 한다.
=> size : fetch count
=> scroll : 얘는 정확히 아직 모르겠다. (pagination 처리시 필요한 것으로 일단은 파악)
output 부분
jdbc output 플러그인 사용
'ELK > logstash' 카테고리의 다른 글
특정 필드의 값 변경 (0) | 2020.11.30 |
---|---|
logstash ruby 활용법 (0) | 2020.07.07 |
logstash eve_odd (0) | 2020.06.17 |
logstash file json absolute path (0) | 2020.06.17 |
logstash input-plugin (elasticsearch) (0) | 2020.05.12 |