Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Logging Executed SQL Commands

avatar
Contributor

Hello! 

 

Attached below is a flow I have created to perform a simple sorting task with a given CSV file 화면 캡처 2022-07-13 170027.png

1. Getfile processor brings the target CSV file into the flow 

2. QueryRecord processor executes SQL commands and send the flowfile two ways

3. Each flow file is saved into Postgresql database with PutDatabaseRecord processors. 

 

What I am trying to do is. 

1. Keep a log of all SQL commands that are executed on Queryrecord processor and keep timestamp (When they were executed) of them 

2. Save the log into a Postgresql table named 'validation_log" that has 3 columns. (CSV file name, SQL command, Timestamp)

 

How can I make this work? 

1 ACCEPTED SOLUTION

avatar
Super Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
8 REPLIES 8

avatar

Hi,

If I understood you correctly you want to log some information when the QueryRecord is executed, in this case you can use the Original relationship coming out of the QueryRecord where you can log the information like filename,timestamp...etc.

avatar
Contributor

Thank you for the reply !. Can you suggest a processor that will perform the task you mentioned? Would LogAttribute do ?

avatar
Super Guru

@Lewis_King ,

 

Keep a log of all SQL commands...

 

What do you mean by the above? The QueryRecord processor always executes the same SQL query, which you configure in the processor as a relationship. The SQL query doesn't change; what changes are the flowfiles that go through the processor.

 

Cheers,

André

 

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.

avatar
Contributor

Oh I guess I didnt make my question clear here.

for example , when I have 2 SQL queries (a, b) set on my Queryrecord Processor,

I want to find out if I can keep a log like 

 

SQL query     |      Timestamp (Time of the query execution)

a                    |        20220714, 12:00

b                    |        20220714 , 12:00

avatar
Super Guru

@Lewis_King ,

 

Do you want to append one row for each flowfile or one row for each processed record to this log?

 

André

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.

avatar
Contributor

One row for each flowfile would do ! 

avatar
Contributor

Actually can you show me both methods ? Thank you so much for help !

avatar
Super Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login