id: forgejo-forge-health-and-repository-sentinel
namespace: devops.git
labels:
env: production
system: forgejo
category: gitops
inputs:
- id: forgejo_url
type: STRING
displayName: Forgejo Instance URL
description: Base URL of the Forgejo Git forge instance.
defaults: http://localhost:3000
- id: forgejo_token
type: STRING
displayName: Forgejo API Token
description: Personal access token if the instance requires authentication for
read endpoints.
defaults: ""
- id: slack_webhook_url
type: STRING
displayName: Slack Webhook URL
description: Slack incoming webhook URL for incident alerting.
defaults: ""
- id: latency_threshold_ms
type: INT
displayName: Latency Threshold (ms)
description: Maximum acceptable response latency in milliseconds before marking
the service as degraded.
defaults: 2000
- id: alert_on_warning
type: BOOL
displayName: Alert on Degraded Warning
description: Whether to send Slack alerts when status is DEGRADED in addition to
CRITICAL.
defaults: true
triggers:
- id: periodic_sentinel_schedule
type: io.kestra.plugin.core.trigger.Schedule
cron: "*/15 * * * *"
tasks:
- id: probe_healthz
type: io.kestra.plugin.core.http.Request
description: Probe Forgejo system health and database connection pooling readiness.
uri: "{{ inputs.forgejo_url }}/api/healthz"
method: GET
timeout: PT10S
retry:
type: constant
interval: PT2S
maxAttempts: 2
options:
allowFailed: true
- id: probe_version
type: io.kestra.plugin.core.http.Request
description: Probe Forgejo API version and service responsiveness.
uri: "{{ inputs.forgejo_url }}/api/v1/version"
method: GET
timeout: PT10S
headers: "{{ inputs.forgejo_token != '' ? {'Authorization': 'token ' ~
inputs.forgejo_token} : {} }}"
options:
allowFailed: true
- id: probe_nodeinfo
type: io.kestra.plugin.core.http.Request
description: Inspect Forgejo node software metadata and runtime capabilities.
uri: "{{ inputs.forgejo_url }}/api/v1/node/info"
method: GET
timeout: PT10S
headers: "{{ inputs.forgejo_token != '' ? {'Authorization': 'token ' ~
inputs.forgejo_token} : {} }}"
options:
allowFailed: true
- id: probe_repository_engine
type: io.kestra.plugin.core.http.Request
description: Test repository search engine and Git indexer responsiveness.
uri: "{{ inputs.forgejo_url }}/api/v1/repos/search?limit=5"
method: GET
timeout: PT10S
headers: "{{ inputs.forgejo_token != '' ? {'Authorization': 'token ' ~
inputs.forgejo_token} : {} }}"
options:
allowFailed: true
- id: classify_sentinel_status
type: io.kestra.plugin.core.log.Log
description: Evaluate service response codes and classify cluster operational status.
message: |
Forgejo Sentinel Probe Evaluation:
- Healthz Status Code: {{ outputs.probe_healthz.statusCode }}
- Version Status Code: {{ outputs.probe_version.statusCode }}
- NodeInfo Status Code: {{ outputs.probe_nodeinfo.statusCode }}
- Repo Engine Status Code: {{ outputs.probe_repository_engine.statusCode }}
- id: route_operational_status
type: io.kestra.plugin.core.flow.Switch
description: Branch execution based on Forgejo service health classification.
value: "{{ outputs.probe_healthz.statusCode == 200 and
outputs.probe_version.statusCode == 200 and
outputs.probe_repository_engine.statusCode == 200 ? 'OPERATIONAL' :
(outputs.probe_healthz.statusCode == 200 ? 'DEGRADED' : 'CRITICAL') }}"
cases:
CRITICAL:
- id: log_critical_incident
type: io.kestra.plugin.core.log.Log
level: ERROR
message: "CRITICAL: Forgejo instance at {{ inputs.forgejo_url }} is DOWN or
database connection pool failed! Status Code: {{
outputs.probe_healthz.statusCode }}."
- id: alert_slack_critical
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Dispatch high-priority alert to Slack when Forgejo is failing.
url: "{{ inputs.slack_webhook_url != '' ? inputs.slack_webhook_url :
secret('SLACK_WEBHOOK_URL') }}"
runIf: "{{ (inputs.slack_webhook_url != '' or secret('SLACK_WEBHOOK_URL') !=
null) }}"
payload: |
{
"text": "CRITICAL INCIDENT: Forgejo Git Forge at {{ inputs.forgejo_url }} is unreachable or failing health checks!",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Forgejo Sentinel Alert: Service CRITICAL",
"emoji": false
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Instance:* {{ inputs.forgejo_url }}"
},
{
"type": "mrkdwn",
"text": "*Healthz Code:* {{ outputs.probe_healthz.statusCode }}"
},
{
"type": "mrkdwn",
"text": "*Version Code:* {{ outputs.probe_version.statusCode }}"
},
{
"type": "mrkdwn",
"text": "*Repo Search Code:* {{ outputs.probe_repository_engine.statusCode }}"
}
]
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Execution ID: {{ execution.id }} | Namespace: {{ flow.namespace }}"
}
]
}
]
}
DEGRADED:
- id: log_degraded_warning
type: io.kestra.plugin.core.log.Log
level: WARN
message: "WARNING: Forgejo instance at {{ inputs.forgejo_url }} is DEGRADED.
Repository engine or API returned non-200 while healthz passed."
- id: alert_slack_degraded
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Dispatch warning alert to Slack when Forgejo repository search is
degraded.
url: "{{ inputs.slack_webhook_url != '' ? inputs.slack_webhook_url :
secret('SLACK_WEBHOOK_URL') }}"
runIf: "{{ inputs.alert_on_warning and (inputs.slack_webhook_url != '' or
secret('SLACK_WEBHOOK_URL') != null) }}"
payload: |
{
"text": "WARNING: Forgejo Git Forge at {{ inputs.forgejo_url }} is reporting DEGRADED sub-services.",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Forgejo Sentinel Warning: Sub-system Degraded",
"emoji": false
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Instance:* {{ inputs.forgejo_url }}"
},
{
"type": "mrkdwn",
"text": "*Repository Indexer Status:* {{ outputs.probe_repository_engine.statusCode }}"
}
]
}
]
}
defaults:
- id: log_operational_confirmation
type: io.kestra.plugin.core.log.Log
message: "SUCCESS: Forgejo instance at {{ inputs.forgejo_url }} is fully
OPERATIONAL. Health checks and repository search indices are healthy."
- id: record_sentinel_audit_telemetry
type: io.kestra.plugin.core.output.OutputValues
description: Record structured sentinel health telemetry for audit history and
downstream dashboards.
values:
instance_url: "{{ inputs.forgejo_url }}"
status: "{{ outputs.probe_healthz.statusCode == 200 and
outputs.probe_version.statusCode == 200 and
outputs.probe_repository_engine.statusCode == 200 ? 'OPERATIONAL' :
(outputs.probe_healthz.statusCode == 200 ? 'DEGRADED' : 'CRITICAL') }}"
healthz_status_code: "{{ outputs.probe_healthz.statusCode }}"
version_status_code: "{{ outputs.probe_version.statusCode }}"
nodeinfo_status_code: "{{ outputs.probe_nodeinfo.statusCode }}"
repository_search_status_code: "{{ outputs.probe_repository_engine.statusCode }}"
errors:
- id: handle_sentinel_failure
type: io.kestra.plugin.core.log.Log
level: ERROR
message: "SENTINEL UNEXPECTED FAILURE: Could not connect to Forgejo at {{
inputs.forgejo_url }}. Please verify network route and container state."
- id: alert_sentinel_fatal_exception
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Dispatch notification when probe encounters fatal network error.
url: "{{ inputs.slack_webhook_url != '' ? inputs.slack_webhook_url :
secret('SLACK_WEBHOOK_URL') }}"
runIf: "{{ (inputs.slack_webhook_url != '' or secret('SLACK_WEBHOOK_URL') !=
null) }}"
payload: |
{
"text": "FATAL INCIDENT: Forgejo sentinel flow execution {{ execution.id }} failed with network exception or unhandled error!"
}