1. Checkly Scheduled Checks for AI System Cron Jobs


    To schedule checks for AI system cron jobs using Checkly, you'd typically create checks that perform health checks or other assertions on endpoints or API responses at regular intervals. The idea is to ensure that your scheduled jobs are running as expected and that any APIs or services your AI system relies on are available and responsive.

    In this example, we will use Pulumi with the Checkly Pulumi integration to create a check. These checks will periodically verify that a hypothetical AI service's REST endpoint is functioning correctly. We will use the checkly.Check resource for this purpose. This resource allows you to define a check that monitors URLs, API endpoints, or key browser flows.

    Here's a step-by-step Pulumi program written in Python that sets up a Checkly check to monitor an API endpoint that your AI system cron job might use:

    1. Setting up the Checkly SDK in Pulumi: We'll start by importing the necessary Checkly module and setting up any required imports.
    2. Creating a Checkly Check: We will configure a check with attributes such as the name, activated status, frequency, request settings, and assertion conditions.
    3. Deploying the Check: By running pulumi up, Pulumi will communicate with Checkly to set up the monitoring check with the provided configuration.
    import pulumi import pulumi_checkly as checkly # Define a Checkly check for an AI system cron job. api_check = checkly.Check("ai-system-api-check", # The name of your check as it will appear in Checkly. name="AI System Health Check", # The type of check; 'API' for API endpoint checks. type="API", # Whether the check is active and should be scheduled. activated=True, # How often the check should run in minutes. frequency=5, # This would run the check every 5 minutes. # The locations from which the check will be run. locations=["us-west-1"], # The specific details of the HTTP request to be made. request=checkly.CheckRequestArgs( # URL of the API endpoint to check. url="https://api.ai-system.example/v1/health", # HTTP method to use. method="GET" ), # Define what a successful check should include. assertions=[ # An example of asserting the HTTP status code is 200 OK. checkly.CheckAssertionArgs( source="response_status_code", comparison="EQUALS", target=200 ), # You can also check for response time, content, and JSON values. ], # Alert settings define how you are notified for failed checks. alert_settings=checkly.CheckAlertSettingsArgs( escalation_type="RUN_BASED", reminders=[ checkly.CheckAlertSettingsReminderArgs(amount=1, interval=5) ], run_based_escalations=[ checkly.CheckAlertSettingsRunBasedEscalationArgs(failed_run_threshold=3) ] ) ) # Export the URL of the check to be used in dashboards or alerts. pulumi.export("checkUrl", api_check.request.apply(lambda request: request.url))

    In this program, we've set up a Checkly check configured to monitor an AI system's endpoint URL. The check will execute an HTTP GET request to the given URL every 5 minutes. The assertions ensure that the response status code is 200, which indicates the service is operational. If the check fails three times in a row, you will get a notification according to the alert settings.

    Please ensure you have the correct parameters for the specific checks you want to create, such as the correct URL and expected response conditions. You can add as many assertions as needed to verify the health and behavior of your AI system's endpoints.

    If you want to see the result of the scheduled checks and potentially react to their status, you can also use other Checkly resources like checkly.MaintenanceWindow or checkly.TriggerCheck to modify and trigger checks dynamically. For more detailed configuration options and adjustments, please refer to the Checkly Check documentation.

    To run the Pulumi program, make sure you have Pulumi installed, and your Checkly provider configured. Then, run pulumi up to deploy the check using the Pulumi CLI.