[英]Logstash adding multiple configs for delta and fulltruth indexing from oracle database
我能夠使用以下 logstash.conf 從 oracle 數據庫創建一個 elasticsearch 索引
input {
jdbc
{
jdbc_driver_library => "<path>/ojdbc10.jar"
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
jdbc_connection_string => "connection string"
jdbc_user => <username>
jdbc_password => <pwd>
statement => "SELECT * FROM my table name WHERE last_modified_date >= :sql_last_value"
schedule => "* * * * *"
"
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "test2"
document_id => "%{col1}-%{col2}-%{col3}"
action => "update"
doc_as_upsert => true
document_id => "%{col1}-%{col2}-%{col3}"
}
但這將始終是一個完整的事實。 我現在正在嘗試運行它,因為增量可能是每小時一次,而完整的真相是一夜之間,這樣我每天都會有干凈的數據。 我也不希望這兩個處決相互沖突。 所以我創建了兩個配置文件如下:
增量配置文件
input {
jdbc
{
jdbc_driver_library => "<path>/ojdbc10.jar"
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
jdbc_connection_string => "connection string"
jdbc_user => <username>
jdbc_password => <pwd>
statement => "SELECT * FROM my table name WHERE last_modified_date >= :sql_last_value"
schedule => "*/15 * * * *"
"
}
filter {
if !("$FULL_IMPORT_RUNNING" in [tags])
{
}
else {
drop {}
}
}
}
output
{
if !("$FULL_IMPORT_RUNNING" in [tags])
{
elasticsearch
{
hosts => ["http://localhost:9200"]
index => "test2"
document_id => "%{col1}-%{col2}-%{col3}"
action => "update"
doc_as_upsert => true
document_id => "%{col1}-%{col2}-%{col3}"
}
}
}
完整配置文件:
input {
jdbc
{
jdbc_driver_library => "<path>/ojdbc10.jar"
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
jdbc_connection_string => "connection string"
jdbc_user => <username>
jdbc_password => <pwd>
statement => "SELECT * FROM my table name"
schedule => "0 0 * * *"
"
}
filter {
mutate {
add_tag => ["$FULL_IMPORT_RUNNING"]
}
}
}
output
{
elasticsearch
{
hosts => ["http://localhost:9200"]
index => "test2"
document_id => "%{col1}-%{col2}-%{col3}"
action => "update"
doc_as_upsert => true
document_id => "%{col1}-%{col2}-%{col3}"
}
}
我正在使用以下命令啟動我的 logstash:
./logstash -f../config/delta.conf -f../config/full.conf
我看到 logstash 正在啟動,但之后沒有任何反應。 如果我只使用一個配置文件啟動 logstash,我會看到它的工作。 我在這里做錯了什么嗎?
您不能使用-f
命令行標志使用兩個配置文件運行 Logstash。 你有兩個選擇。
選項 A:使用多個管道並在pipelines.yml
文件中同時指定它們。
- pipeline.id: full
path.config: "/etc/path/to/full.conf"
- pipeline.id: delta
path.config: "/etc/path/to/delta.conf"
選項 B:將兩個配置合並到一個配置文件中,並根據標簽添加對事件的條件處理。 然后用-f
運行配置
input {
# Full processing
jdbc {
...
tags => ["FULL_IMPORT_RUNNING"]
}
# Delta processing
jdbc {
...
tags => ["DELTA_IMPORT_RUNNING"]
}
}
filter {
if "FULL_IMPORT_RUNNING" in [tags] {
...
}
if "DELTA_IMPORT_RUNNING" in [tags] {
...
}
}
output {
if "FULL_IMPORT_RUNNING" in [tags] {
...
}
if "DELTA_IMPORT_RUNNING" in [tags] {
...
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.