Skip to main content
VJ_0082
Silver ⭐️⭐️
August 5, 2022
Question

Put error message in PutEmail message body

Hi All,

I want to put the error message or want to attach the log file from local location to the nifi flow.

 

My flow is as below:

Getfile -> EvaluateJSON -> ExecuteStreamCommand->RouteAttribute-> PutEmail.

 

Please help me for this.

 

Thank you in advance!!

8 replies

MattWho
Titanium ⭐️⭐️⭐️
Titanium ⭐️⭐️⭐️
August 5, 2022

@VJ_0082 
Your use case is not very clear.  What exactly are you trying to accomplish via your existing dataflow and what issues are you having?

 

Thanks,

Matt

Translate
VJ_0082
VJ_0082Author
Silver ⭐️⭐️
August 5, 2022

Hi @MattWho,

 

I want to get the mails after the failure of flow with the error message in the mail.

Translate
MattWho
Titanium ⭐️⭐️⭐️
Titanium ⭐️⭐️⭐️
August 8, 2022

@VJ_0082 
When a NiFi processor errors it will produce a bulletin.  NiFi has a SiteToSiteBulletin  reporting task.  This reporting task can send these produced bulletins to a remote input port on either the same NiFi or a completely different NiFi.  You can construct a dataflow from that remote input port to route these FlowFiles to your putEmail processor.   Constructing a dataflow like this avoids needing to deal with non error related log output or ingesting same log lines over and over by re-reading the app.log.

By default processors have their bulletin level set to ERROR, but you can change that on each processor if so desired.  

If you found this response assisted with your query, please take a moment to login and click on "Accept as Solution" below this post.

Thank you,

Matt

Translate
MattWho
Titanium ⭐️⭐️⭐️
Titanium ⭐️⭐️⭐️
August 11, 2022

@VJ_0082 
I apologize if I am still not clear about your Script being executed by ExecuteStream command.

The Script is writing to some log file on disk where (locally on the NiFi node host or some external server where NiFi is not located) when it fails/errors?

I assume your flow is passing the "original" FlowFile with a new FlowFile Attribute "execution.error" with your exception/error in it?   Does this attribute contain the details you want to send in your email?

Then you are routing based on what attribute from Original FlowFile (execution.status)?

How is your PutEmail processor configured.  It can be configured to send either a FlowFiIe  attribute or FlowFile content.

If the content you to sent via PutEmail is not in the Content of the FlowFile and is also Not in a FlowFile Attribute on the FlowFile, but rather written to some location on disk, you would need a separate dataflow that watches that log file on disk for new entries ingesting them into a FlowFile that feeds a putEmial processor.  This could be accomplished using the TailFile processor.  If that content is being written out a log file on remote system that becomes a different challenge.

If you found this response assisted with your query, please take a moment to login and click on "Accept as Solution" below this post.

Thank you,

Matt

Translate