【发布时间】:2021-01-15 14:15:11
【问题描述】:
问题陈述:Logstash 没有正确地将数据库中的所有记录加载到 elasticsearch 中,并且每次我点击相同的 api 时都会得到不同的结果(但有时是正确的,但每次点击都会发生变化,并且仅在称呼嵌套字段下显示记录的子集)。 logstash 机制看起来是零星的,加载结果并不一致,尤其是在一对多的情况下。 http://localhost:9200/staffsalutation/_search 我观察到 logstash logstash-7.8.0 的奇怪行为,同时从 2 个表中加载记录,查询和配置如下
查询:
选择 s.update_time, s.staff_id 作为 staff_id,birth_date,first_name,last_name,gender,hire_date,
st.title AS title_nm, st.from_date AS title_frm_dt, st.to_date AS title_to_dt
来自员工
LEFT JOIN 称呼 st ON s.staff_id = st.staff_id
按 s.update_time 排序
input {
jdbc {
jdbc_connection_string => "jdbc:postgresql://localhost:5432/postgres"
jdbc_driver_library => "C:\\Users\\NS\\.m2\\repository\\org\\postgresql\\postgresql\\42.2.11\\postgresql-42.2.11.jar"
jdbc_user => "postgres"
jdbc_password => "postgres"
jdbc_driver_class => "org.postgresql.Driver"
schedule => "* * * * *"
statement => "select e.update_time, e.emp_no as staff_id, birth_date, first_name, last_name, gender, hire_date, t.title AS title_nm, t.from_date AS title_frm_dt, t.to_date AS title_to_dt
from employees e
LEFT JOIN titles t
ON e.emp_no = t.emp_no
order by e.update_time"
add_field => { "doctype" => "employee" }
tracking_column_type => "timestamp"
use_column_value =>true
tracking_column => update_time
jdbc_fetch_size => "50000"
}
}
filter {
aggregate {
task_id => "%{staff_id}"
code => "
map['staff_id'] = event.get('staff_id')
map['birth_date'] = event.get('birth_date')
map['first_name'] = event.get('first_name')
map['last_name'] = event.get('last_name')
map['gender'] = event.get('gender')
map['hire_date'] = event.get('hire_date')
map['salutations'] ||= []
map['salutations'] << {
'title_nm' => event.get('title_nm'),'title_frm_dt' => event.get('title_frm_dt'),
'title_to_dt' => event.get('title_to_dt')
}
event.cancel()
"
push_previous_map_as_event => true
timeout => 30
}
}
output {
elasticsearch {
document_id => "%{staff_id}"
index => "staffsalutation"
}
file {
path => "test.log"
codec => line
}
}
【问题讨论】:
标签: elasticsearch logstash logstash-jdbc