Blueprints

Getting started with Kestra — a Microservices and APIs workflow example

About this blueprint

API Getting Started Notifications Schedule

This flow is a simple example of a microservices and APIs use case. It checks the health of a server and sends a Slack alert if the server is down.

The flow has two tasks:

  1. The first task checks the health of a server.
  2. The second task sends a Slack alert if the server is down.

The flow also has a trigger that runs the flow daily at 9:00 AM to check the server's health regularly.

yaml
id: microservices_and_apis
namespace: tutorial

inputs:
  - id: server_uri
    type: URI
    defaults: https://kestra.io

  - id: slack_webhook_uri
    type: URI
    defaults: https://reqres.in/api/slack

tasks:
  - id: http_status_check
    type: io.kestra.core.tasks.flows.AllowFailure
    tasks:
      - id: http_request
        type: io.kestra.plugin.fs.http.Request
        uri: "{{ inputs.server_uri }}"

      - id: check_status
        type: io.kestra.core.tasks.flows.If
        condition: "{{ outputs.http_request.code != 200 }}"
        then:
          - id: unhealthy
            type: io.kestra.core.tasks.log.Log
            message: "Server is unhealthy! Response {{ outputs.http_request.body }}"
          - id: send_slack_alert
            type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
            url: "{{ inputs.slack_webhook_uri }}"
            payload: |
              {
                "channel": "#alerts",
                "text": "The server {{ inputs.server_uri }} is down!"
              }
        else:
          - id: healthy
            type: io.kestra.core.tasks.log.Log
            message: Everything is fine!
    errors:
      - id: server_unreachable
        type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
        url: "{{ inputs.slack_webhook_uri }}"
        payload: |
          {
            "channel": "#alerts",
            "text": "The server {{ inputs.server_uri }} is unreachable!"
          }

triggers:
  - id: daily
    type: io.kestra.core.models.triggers.types.Schedule
    cron: "0 9 * * *"

Allow Failure

Request

If

Log

Slack Incoming Webhook

Schedule

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra