Blueprints

Monitor availability of an HTTP endpoint and send a Slack alert if a service is unhealthy

About this blueprint

API Notifications

This flow will check if a given URI is healthy or not. If the response code is not 200, it will send a Slack notification to the #alerts channel. Otherwise, it will log that everything is fine. The flow is scheduled to run daily at 9:00 AM.

yaml
id: http_check
namespace: dev

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

tasks:
  - id: api
    type: io.kestra.plugin.fs.http.Request
    uri: "{{ inputs.uri }}"

  - id: check_status
    type: io.kestra.core.tasks.flows.If
    condition: "{{ outputs.api.code != 200 }}"
    then:
      - id: unhealthy
        type: io.kestra.core.tasks.log.Log
        message: Server unhealthy!!! Response {{ outputs.api.body }}
      - id: send_slack_alert
        type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
        url: "{{ secret('SLACK_WEBHOOK') }}"
        payload: |
          {
            "channel": "#alerts",
            "text": "The server {{ inputs.uri }} is down!"
          }
    else:
      - id: healthy
        type: io.kestra.core.tasks.log.Log
        message: Everything is fine!

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

Request

If

Log

Slack Incoming Webhook

Schedule

More Related Blueprints

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra