Support Questions

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

How do I create the folder name with current timestamp in HDFS using NiFi ?

avatar
Contributor

I am trying to create the directory with current timestamp as the name of the folder in hdfs

what should I use to get the desire output ?


Right now my flow is : ListHDFS -----> Updateattribute ----->PutHDFS.




any suggestions please ?

1 REPLY 1

avatar
Master Guru

@Veerendra Nath Jasthi

In UpdateAttribute add new attribute as

ts

value as

${now():format("yyyy_MM_dd_HH_mm_ss_SSS")}

Example:

ts attribute will have value as 2019_06_12_20_42_26_762

Then in PutHDFS processor configure directory as

/<path>/${ts}

(or)

You can skip UpdateAttribute processor and directly use directory name as

/<path>/${now():format("yyyy_MM_dd_HH_mm_ss_SSS")}

In PutHDFS processor.

This will create a directory in HDFS with current timestamp value.

You can change the format of the timestamp using NiFi expression language.