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.

Nifi Now() Format

Solved Go to solution
Highlighted

Nifi Now() Format

Contributor

According to the docs ${now()} should yeild

"current date and time as the number of milliseconds since Midnight GMT on January 1, 1970."

Which sounds like a Unix epoch style timestamp in miliseconds

but what I actually receive is Fri Oct 30 02:36:08 UTC 2015

Does now() have options I am missing?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Nifi Now() Format

Wade, this is a documentation bug. The now() statement returns a Date object, not a long epoch, one more step required. E.g. consider this expression which gets 'yesterday':

${now():toNumber():minus(86400000):format('yyyy-MM-dd')} 

You can follow https://issues.apache.org/jira/browse/NIFI-1078

View solution in original post

4 REPLIES 4
Highlighted

Re: Nifi Now() Format

Wade, this is a documentation bug. The now() statement returns a Date object, not a long epoch, one more step required. E.g. consider this expression which gets 'yesterday':

${now():toNumber():minus(86400000):format('yyyy-MM-dd')} 

You can follow https://issues.apache.org/jira/browse/NIFI-1078

View solution in original post

Highlighted

Re: Nifi Now() Format

Contributor

Thanks Andrew ${now();toNumber():Divide(1000)} got me what I needed.

Highlighted

Re: Nifi Now() Format

New Contributor

Hello all, I'm new here.

 

wondered if any of you could help me. I am trying to create a flow in Nifi to stop any incorrect timestamps getting out of Nifi (i.e. to HDFS or Splunk).

 

I want to capture any epoch timestamp 24hours in the future or 7 days in the past. I have created a processor that takes all timestamp formats back to epoch (as attribute named 'timestamp'. I then want to minus the timestamp from 'now' then use the 'gt' and 'lt' functions to return a true/false against another attribute I have made called ,valid_timestamp'.

 

first of all, can anyone help me minus my timestamp (value) from 'now'?

${now():toNumber():minus(timestamp(attibute value))
 

I spent the whole day yesterday trying to get this to work.. I'm sure there is a more straight forward way to achieve what I am after, any advice would be much appreciated.

 

ts.png

 

Andy

Re: Nifi Now() Format

Master Guru

@Griggsy 

 

I'd strongly encourage you to start a new question rather then asking for help on an existing question with an already accepted solution.  You'll get better traction and visibility that way.

Matt

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