Support Questions

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

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

avatar
Contributor

@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

avatar
Super Guru

@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

View solution in original post

avatar
Super Guru

@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.

View solution in original post

avatar
Super Guru

@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... 

View solution in original post

7 REPLIES 7

avatar
Super Guru

@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

avatar
Contributor

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

avatar
Super Guru

@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.

avatar
Contributor

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

avatar
Super Guru

@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... 

avatar
Contributor

big thank you to you @stevenmatison  

avatar
Contributor

@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