Support Questions

Find answers, ask questions, and share your expertise

Change the filename after putHDFS processor to a more user friendly name

avatar
Expert Contributor

Hi All,

I am merging the events from log source using a merge Content processor, and putting it to PutHDFS. PutHDFS writes using the filename uuid_date0901417, I need to change this filename to a more user friendly name.

I researched a little bit I found this link

http://apache-nifi.1125220.n5.nabble.com/Best-way-to-generate-a-new-filename-td8835.html

But refering this link I could change only the directory structure according to date.

I am not able to use the Updateattribute processor correctly to change the filename. How do I proceed, create a property in updateAttribute procesor and the give an expression language containing userfriendlyname_datetime. How will this EL look like?

Thanks

Dhiren

1 ACCEPTED SOLUTION

avatar
Master Guru

@dhieru singh

in update attribute processor add new property by clicking + sign

Name of property:-

filename

value of the property:-

<what ever name you want to keep for file>

39839-change-filename.png

If you want to append with timestamp then use EL

<new-file-name>_${now():format("yyyyMMddHHmmss")}

Example:-

if my input filename is

foo 

and i want to change the filename to bar_timestamp

then my UpdateAttribute processor new property would be

filename

bar_${now():format("yyyyMMddHHmmss")}

output filename would be

bar_20171017132115

View solution in original post

2 REPLIES 2

avatar
Master Guru

@dhieru singh

in update attribute processor add new property by clicking + sign

Name of property:-

filename

value of the property:-

<what ever name you want to keep for file>

39839-change-filename.png

If you want to append with timestamp then use EL

<new-file-name>_${now():format("yyyyMMddHHmmss")}

Example:-

if my input filename is

foo 

and i want to change the filename to bar_timestamp

then my UpdateAttribute processor new property would be

filename

bar_${now():format("yyyyMMddHHmmss")}

output filename would be

bar_20171017132115

avatar
Expert Contributor

@Shu Thanks a lot for quick reply. Much appreciated.

This solved the issue. The problem was once I set the expression language for creating directory structure. The putFile was looking for the directory structure hence the error. So I had to delete the PutFile processor and the use your EL and it worked like a charm. Thanks again