Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

prefix or suffix in NIFI tailFile Processor

Solved Go to solution

prefix or suffix in NIFI tailFile Processor

New 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

Accepted Solutions

Re: prefix or suffix in NIFI tailFile Processor

Rising Star

@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
2 REPLIES 2

Re: prefix or suffix in NIFI tailFile Processor

Rising Star

@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
Highlighted

Re: prefix or suffix in NIFI tailFile Processor

New Contributor

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

Don't have an account?
Coming from Hortonworks? Activate your account here