Support Questions

Find answers, ask questions, and share your expertise

prefix or suffix in NIFI tailFile Processor

avatar
Contributor

Hi ,

In my project I am using Nifi to read log file from tomcat and process those data in a spark application , after that insert those process data in DB.

But my problem is that , at app server level , I have 4 tomcat cluster(4 different log file) in 2 different box and I have mark out which data is from which cluster at spark level. In my present set up I have 2 tailFile processor in Nifi which pointing to single outport , in per box but not able to identify which data is from which cluster at spark level.

Is there any option in tailFile processor to add some suffix or prefix or file name(or any attribute) in each record ? so that I can identify each record is coming from which cluster and persist in db in that way?

Any help will be highly appreciated ....

Thanks in advance

1 ACCEPTED SOLUTION

avatar
Expert Contributor

@Biswajit Chakraborty

A simple way to do this is to use a ReplaceText processor after the TailFile.

ReplaceText gives you the option to configure which Replacement Strategy to use. Using 'Prepend' will insert the replacement value at the start of each file or line (depending on what you've configured 'Evaluation Mode' to be):

39465-nifi-replace-text-strategy.png

So a ReplaceText with the following configs will give you what you need:

  • Replacement Value: <set your hostname or filename>
  • Replacement Strategy: Prepend
  • Evaluation Mode: Line-by-Line

View solution in original post

2 REPLIES 2

avatar
Expert Contributor

@Biswajit Chakraborty

A simple way to do this is to use a ReplaceText processor after the TailFile.

ReplaceText gives you the option to configure which Replacement Strategy to use. Using 'Prepend' will insert the replacement value at the start of each file or line (depending on what you've configured 'Evaluation Mode' to be):

39465-nifi-replace-text-strategy.png

So a ReplaceText with the following configs will give you what you need:

  • Replacement Value: <set your hostname or filename>
  • Replacement Strategy: Prepend
  • Evaluation Mode: Line-by-Line

avatar
Contributor

Thanks a lot for your help , you saved my day ... thanks again .....