Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Nifi date filename

avatar
New Member

I'm constantly moving logs for storage and was looking for a way to change the filenames in a given nifi flow. for example, if i'm getting a load of files from say /var/log*, is there a way in my flow that i'm using to adjust the filename and add on to it so i have the date?So for example if i have webapp.log, i would like to move it and have the file name changed to webapp.log(todaysdate). Is there a processor in NiFi that will do this?

1 ACCEPTED SOLUTION

avatar
Rising Star

@David Parkins

Your best option for doing this is going to be using the UpdateAttribute processor and then using a little NiFi Expression Language to append the date onto your file. From there you should be able to configure. I created a sample flow and used the following config and achieved the following results:

/var/log/log1.log

New filename: log1.log.2016-12-26 15:10:25.966Z

10810-updateattributedate.png

This is the config on the updateAttribute processor:

10822-processorconfig.png

This is just a sample, you could do a lot better using append/prepend with NiFi Expression Language. There is more info here: https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html

View solution in original post

1 REPLY 1

avatar
Rising Star

@David Parkins

Your best option for doing this is going to be using the UpdateAttribute processor and then using a little NiFi Expression Language to append the date onto your file. From there you should be able to configure. I created a sample flow and used the following config and achieved the following results:

/var/log/log1.log

New filename: log1.log.2016-12-26 15:10:25.966Z

10810-updateattributedate.png

This is the config on the updateAttribute processor:

10822-processorconfig.png

This is just a sample, you could do a lot better using append/prepend with NiFi Expression Language. There is more info here: https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html