Support Questions

Find answers, ask questions, and share your expertise

Nifi date filename

avatar
New Contributor

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