This documentation and the Cisco Observability Platform functionalities it describes are subject to change. Data saved on the platform may disappear and APIs may change without notice.


Define a Cron

You can define a cron or multiple crons that periodically invoke a custom function you've defined through Solution Services, similar to a Unix cron. Before you define a cron, you must first define the custom function. Crons send cloud events, so the functions which receive them have to be able to handle cloud events.

There are two types of crons:

  • Solution-level crons run in the context of a solution. You define these crons with objects of type zodiac:solutionCron in your solution. Since these objects are not associated with a specific Tenant, they can be used for generic tasks which are Tenant-agnostic. The Cisco Observability Platform creates crons for these objects at solution installation time.
  • Subscription-level crons run in the context of a subscription. You define these crons with objects of type zodiac:subscriptionCronConfig in your solution. However, the Cisco Observability Platform doesn't create them immediately because it doesn't know which Tenant(s) they are supposed to be created for. Instead, the Cisco Observability Platform only creates the crons for the specific Tenants that subscribe to your solution.

A Tenant cron sends the tenantId as a parameter (in the HTTP request body) to the function it invokes; a solution cron does not.

Limitations

  • You cannot get updates to a cron. To receive updates, unsubscribe to and re-subscribe to the cron.

To define a zodiac:solutionCron or zodiac:subscriptionCronConfig in your solution, follow these steps.

  1. Log into fsoc with your developer credentials (which should already be in ~/.fsoc):

    fsoc login
    
  2. In <your-solution-directory>/manifest.json, add a directory to the objects array as the location of all zodiac:solutionCron or zodiac:subscriptionCronConfig configurations, if it isn't there already. For example:

    {
      "objects": [
        {
          "type": "zodiac:function",
          "objectsDir": "zodiac/objects/functions"
        },
        {
          "type": "zodiac:solutionCron",
          "objectsDir": "zodiac/objects/solution-crons"
        },
        {
          "type": "zodiac:subscriptionCronConfig",
          "objectsDir": "zodiac/objects/subscription-cron-configs"
        }
      ]
    }
    
  3. If you're creating a solution-level cron, create a file named <your-solution-directory>/zodiac/objects/solution-crons/<cron-name>.json and put the definition of your zodiac:solutionCron into it. For example:

    {
      "name": "my-solution-cron",
      "function": "my-func",
      "schedule": "* * * * *",
      "data": "my-data"
    }
    
  4. Similarly, if you're creating a subscription-level cron, create a file named <your-solution-directory>/zodiac/objects/subscription-cron-configs/<cron-name>.json and put the definition of your zodiac:subscriptionCronConfig into it. For example:

    {
      "name": "my-subscription-cron",
      "function": "my-func",
      "schedule": "* * * * *",
      "data": "my-data"
    }
    
  5. Each time you modify your solution:

    a. Increment solutionVersion in manifest.json.

    b. Check your solution with the fsoc solution check command.

    c. Run the fsoc solution validate command to catch errors that would cause fsoc solution push to fail.

    d. Republish your solution with the fsoc solution push command.