Support Questions

Find answers, ask questions, and share your expertise
Announcements
Now Live: Explore expert insights and technical deep dives on the new Cloudera Community BlogsRead the Announcement

NiFi EnvokeHTTP - putting current date on HTTP URL property

avatar
New Member

I need to pull data from pager duty that needs a date in the url.  This is an example:

https://api.pagerduty.com/oncalls?include%5B%5D=users&schedule_ids%5B%5D=AAAAAA&schedule_ids%5B%5D=B...

The two parameters are since and until.  The intent is this runs once a day and a new date value set for each day.  Something tells me it may look like this:


https://api.pagerduty.com/oncalls?include%5B%5D=users&schedule_ids%5B%5D=AAAAAA&schedule_ids%5B%5D=B...

 

but the how I don't know.  I'll continue searching, but if anyone has a solution I will be thankful.

1 ACCEPTED SOLUTION

avatar
Master Mentor

@Justinh_klik 

Welcome to the community!

Unfortunately, both the url you shared are truncated and I am unable to see what you are attempting.

My initial thought would be to use a GenerateFlowFile processor sceduled based on a cron to run daily.   You can use NiFi Expression Language (NEL) to dynamically define Attributes on the FlowFile each time GenerateFlowFile is scheduled to execute for "since" and "until"  date strings you need to use in the URL used by the InvokeHTTP processor.

The GenerateFlowFile  processor passes this daily generated FlowFile to the InvokeHTTP processor trigger its daily execution.   The "HTTP URL" property in the InvokeHTTP processor also support NEL.   Something like the following:

https://api.pagerduty.com/oncalls?since=${since}&until=${until}&users&Schedule_ids...

${since} and ${until} within above URL would get replaced with the values assigned to the FlowFile attributes "since" and "until" that exist in the FlowFile being passed to the InvokeHTTP processor.

 

Please help our community grow. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

View solution in original post

2 REPLIES 2

avatar
Master Mentor

@Justinh_klik 

Welcome to the community!

Unfortunately, both the url you shared are truncated and I am unable to see what you are attempting.

My initial thought would be to use a GenerateFlowFile processor sceduled based on a cron to run daily.   You can use NiFi Expression Language (NEL) to dynamically define Attributes on the FlowFile each time GenerateFlowFile is scheduled to execute for "since" and "until"  date strings you need to use in the URL used by the InvokeHTTP processor.

The GenerateFlowFile  processor passes this daily generated FlowFile to the InvokeHTTP processor trigger its daily execution.   The "HTTP URL" property in the InvokeHTTP processor also support NEL.   Something like the following:

https://api.pagerduty.com/oncalls?since=${since}&until=${until}&users&Schedule_ids...

${since} and ${until} within above URL would get replaced with the values assigned to the FlowFile attributes "since" and "until" that exist in the FlowFile being passed to the InvokeHTTP processor.

 

Please help our community grow. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

avatar
New Member

Matt,

After some digging I found that I could use an updateattribute processor.  In it I create two custom attributes:

since_date
${now():format("yyyy-MM-dd")}

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

Then later in the InvokeHTTP processor I can use the custom attributes in the url line:

... &since=${since_date}&until=${until_date}&earliest=true

Even later I then learned those attributes can be created in the GenerateFlowfile processor or used directly in the url as the formula:

${now():format("yyyy-MM-dd")}

which is along the lines of what you posted.  Thank you for the response.