New Alarm based trigger events for IBM Cloud Functions

5 min read

By: Carlos Santana

New Alarm based trigger events for IBM Cloud Functions

IBM Cloud Functions offers great flexibility when it comes to using events to invoke your Actions.

Scheduled events are cloud native events you can programmatically control when they need to fire to run your serverless apps, instead of allocating an idle server just to schedule a job, you can use IBM Cloud Functions to orchestrate your applications using these type of triggers.

We recently enhanced the Alarm-based triggers, which fire a trigger at a specified frequency. There are now 3 types of alarms that you can take advantage of to schedule the invocations of your Actions: interval based triggers, fire-once based triggers, and CRON based triggers.

Interval-based triggers

We heard from developers that they want to schedule their actions based on a simple interval. This can be useful in Continuous Deployment and Operations such as monitoring and health tests. With the Interval based trigger from the alarms package, you can configure an action to run every set amount of minutes.

Here is an example of creating a trigger that fires an event every 42 minutes using the CLI:

<br>
bx wsk trigger create intervalTrigger --feed /whisk.system/alarms/interval -p minutes 42<br>

Then you can use your trigger to create a rule:

<br>
bx wsk rule create intervalRule intervalTrigger monitorAction<br>

You can learn more about firing a trigger event periodically on an interval-based schedule, including options such as start and stop parameters, in the Cloud Functions documentation.

Fire-once based triggers

In some cases, actions are meant to run once. These actions are usually created programmatically from your serverless apps to continue with a task or invoke a final Action at some point in the future. Or perhaps you just want to send a personalized social message to every family members at exactly midnight on New Year’s Eve!

Here is an example of creating a trigger that fires at New Year’s Eve using the CLI:

<br>
bx wsk trigger create onceTrigger --feed /whisk.system/alarms/once -p date "2019-01-01T00:00:00-05:00"<br>

Then you can use your trigger to create a rule:

<br>
bx wsk rule create onceRule onceTrigger sendMessageAction<br>

You can learn more about firing a trigger once on a specific date, including options to delete the trigger and the rule afterward, in the Cloud Functions documentation.

CRON-based triggers

The CRON-based trigger event was the first trigger available when we first introduced the periodic event-based Actions. We heard from developers that they want more control on when the trigger starts to fire and when it stops. This type of trigger was recently enhanced with two new options to handle start and stop dates. You can learn more about how to use these two new options in the Cloud Functions documentation.

Note: These enhancements are available only via the Cloud Functions CLI plug-in. This blog post will be updated when the ability to create these triggers via the Cloud Functions UI is available.

Be the first to hear about news, product updates, and innovation from IBM Cloud