Source
yaml
id: microservices-and-apis
namespace: tutorial
description: Microservices and APIs
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.plugin.core.flow.AllowFailure
tasks:
- id: http_request
type: io.kestra.plugin.core.http.Request
uri: "{{ inputs.server_uri }}"
- id: check_status
type: io.kestra.plugin.core.flow.If
condition: "{{ outputs.http_request.code != 200 }}"
then:
- id: unhealthy
type: io.kestra.plugin.core.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.plugin.core.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.plugin.core.trigger.Schedule
disabled: true
cron: 0 9 * * *
About this blueprint
Getting Started Trigger DevOps Schedule API Notifications
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.