I have the ELK stack installed and all three are communicating correctly. I'm trying to get logstash to query a 'mysql' database. My query contains joins from multiple tables. Can we used joins using “statement” or “statement_filepath”?
If I have written my sql join query in one of the .sql file and provides that filepath to “statement_filepath”, will this work?
select
b.transaction_date as transaction_timestamp,
a.*,
b.*
from
dict a
left join transactions b on a.name = b.name
where
b.transaction_date > :sql_last_value
This is the place where logstash stores timestamp/numeric value, used in next run of the pipeline as a reference in place of :sql_last_value. So in your case file .oracle_query will store transaction_timestamp from last row of it's previous run.
More info can be found here: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#_state
I think the path (/usr/share/logstash/last_run_metadata/) needs to exist, but the file itself (.oracle_query) is created automatically upon first pipieline run.
Make sure that /last_run_metadata/ is owned by logstash user.
So file path ( /usr/share/logstash/last_run_metadata/) was not there. I have now manually created that and it is not giving me any error.
But now I am getting an error while executing sql query. Kindly look at below query I have created and passed “ :sql_last_value” as mentioned.
So for “:sql_last_value”, we have to specify any number or pass the same value?
select b.*, a.External_link_Name as ext_link from externallinks a, externallinkdetails b where b.externalsysid= a.externalsystemid and a.status = 1 and b.status =1 and rownum < 99999999999999999999999999 > :sql_last_value
and rownum < 99999999999999999999999999 > :sql_last_value
Not only it has a wrong syntax, as you are using two comparison operators (< and >) within one but also does not make much sense. Rownum depends on current data set, and there's no point using it for :sql_last_value.
But if you want to give it a shot anyways, alter the last line to:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.