Source
yaml
id: microservices-and-apis
namespace: tutorial
labels:
name: Microservices and APIs
inputs:
- id: server_uri
type: URI
defaults: https://kestra.io
- id: slack_webhook_uri
type: URI
defaults: https://kestra.io/api/mock
tasks:
- id: http_request
type: io.kestra.plugin.core.http.Request
description: Check the target server endpoint for an HTTP response.
uri: "{{ inputs.server_uri }}"
options:
allowFailed: true
- id: check_status
type: io.kestra.plugin.core.flow.If
description: Branch based on the HTTP status to alert or confirm health.
condition: "{{ outputs.http_request.code != 200 }}"
then:
- id: server_unreachable_alert
type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
description: Send a Slack alert if the server cannot be reached.
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
description: Log that the server is responding normally.
message: Everything is fine!
triggers:
- id: daily
type: io.kestra.plugin.core.trigger.Schedule
disabled: true
cron: 0 9 * * *
description: |
# Flow Description
**Use case:** Simple microservice health check with conditional alerting.
**Highlights:**
- Probe the target server and capture the HTTP response code.
- Branch on non-200 results to send a Slack webhook alert; otherwise log success.
- Parameterize the target URL and webhook for easy reuse across environments.
**Schedule:** Disabled daily run at 09:00 to show how to automate recurring checks.
About this blueprint
Getting Started Notifications API DevOps Kestra
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 also has a trigger that runs the flow daily at 9:00 AM to check the server's health regularly.