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.

i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

Solved Go to solution
Highlighted

i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

Explorer

@stevenmatison 

hi to everyone ...i want to pass the attribute in http invoked processor but the attribute which contain the date and time like 2020-06-01T09:47:59.946Z format....i want to subtract the present time with 10 min.-------

this expression i have seen in this community 

${now():toNumber():minus(???):format('???')} 

what i have to put in the place of question mark for 10 min minus ...60000?? and for

format  2020-06-01T09:47:59.946Z(+%FT%T.%3NZ  if i use this i'll get error in format )  ..... and what processor i have to use...currently i m using updateAttribute for date format   

 

thanks in advance 

3 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted

Re: i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

@renuu    Good morning,  the Expression Language you are looking for to create an ISO format timestamp for 10 minutes ago is:

 

${now():minus(600000):format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "GMT")}

 

Processor Configuration:

Processor ConfigurationProcessor Configuration


FlowFile Output:

FlowFile OutputFlowFile Output

 

 

 

If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  

 

Thanks,


Steven @ DFHZ

 


 


If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  


 


Thanks,



Steven

View solution in original post

Highlighted

Re: i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

@renuu this should be the correct format for a $_GET request to the service:

 

https://localhost:8080/api/alarm?sort-by=from-date=${lastTime}

However, are you sure this is the correct Remote Url?  I see maybe an issue with sort-by=from-date=... Maybe this should be sort-by=SomeValue&from-date=${lastTime}.  I also suspect the dashes (-) in the variable names as this is not a good practice in variable naming.

 

What is the service you are trying to get the alarm from?  If its private can you PM me the details.

 

 

There are 4 ways to pass data from NiFi to InvokeHttp:

 

  1. In the Remote Url as $_GET like above using format: ?value1=1&value2=2
  2. In the body of the flowfile content, for example $_POST of json
  3. In Cookie using "Attributes to send" (pick an existing attribute).
  4. In Cookie using + (Add) property 


Based on the service's requirements, you will need to handle invokeHttp to suit the requirements.

 


 


If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  


 


Thanks,



Steven

View solution in original post

Highlighted

Re: i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

@renuu just add more S.... 

 

${now():minus(600000):format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "GMT")}

 

I have updated the original snippet as well... 

 


 


If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  


 


Thanks,



Steven

View solution in original post

7 REPLIES 7
Highlighted

Re: i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

@renuu    Good morning,  the Expression Language you are looking for to create an ISO format timestamp for 10 minutes ago is:

 

${now():minus(600000):format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "GMT")}

 

Processor Configuration:

Processor ConfigurationProcessor Configuration


FlowFile Output:

FlowFile OutputFlowFile Output

 

 

 

If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  

 

Thanks,


Steven @ DFHZ

 


 


If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  


 


Thanks,



Steven

View solution in original post

Re: i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

Explorer

hi @stevenmatison 

thanks for reply ....actually we want to send this timestamp in http processor to get all the alarm which came from this timestamp...can you please suggest how to pass this timestamp in http invoked processor end point....

renuu_0-1591016082651.png

 

 here i have attached the snap ...i have first used generate flowfile processor after that in upadteAttribute processor i have calculate timestamp which you provide 

lastTime= ${now():minus(600000):format("yyyy-MM-dd'T'HH:mm:ss'Z'", "GMT")}

 and thanks this is working ...but now i want to pass this timestamp in http processor for get request ...i have used attributtojson that convert updateAttribut processor output i have used this bec when i connected updateAttribute to evaluatejsonpath processor this processor will give error ....that why i have to used this AtrributeTOjson then i have use evaluatejsonpath to extract timestamp as an attribute bec i have to send the http get request https://localhost:8080/api/alarm?sort-by=from-date=${lastTime} using this timestamp ...but i didn't get appropriate output ..i'll getting all alram   up.PNGev.PNG

Highlighted

Re: i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

@renuu this should be the correct format for a $_GET request to the service:

 

https://localhost:8080/api/alarm?sort-by=from-date=${lastTime}

However, are you sure this is the correct Remote Url?  I see maybe an issue with sort-by=from-date=... Maybe this should be sort-by=SomeValue&from-date=${lastTime}.  I also suspect the dashes (-) in the variable names as this is not a good practice in variable naming.

 

What is the service you are trying to get the alarm from?  If its private can you PM me the details.

 

 

There are 4 ways to pass data from NiFi to InvokeHttp:

 

  1. In the Remote Url as $_GET like above using format: ?value1=1&value2=2
  2. In the body of the flowfile content, for example $_POST of json
  3. In Cookie using "Attributes to send" (pick an existing attribute).
  4. In Cookie using + (Add) property 


Based on the service's requirements, you will need to handle invokeHttp to suit the requirements.

 


 


If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  


 


Thanks,



Steven

View solution in original post

Highlighted

Re: i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

Explorer

yes i got it ...i found it ....the problem in the date time format..could you please see on my further reply 

Highlighted

Re: i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

@renuu just add more S.... 

 

${now():minus(600000):format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "GMT")}

 

I have updated the original snippet as well... 

 


 


If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  


 


Thanks,



Steven

View solution in original post

Highlighted

Re: i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

Explorer

big thank you to you @stevenmatison  

Highlighted

Re: i want to subtract the time with 10 minutes and want the format like this 2020-06-01T09:47:59.946Z

Explorer

@stevenmatison the solution which you provide that give "lastTime":"2020-06-01T12:39:13Z"

but i want the format like this 2020-06-01T13:17:13.474Z

please see on yellow shed  

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