Webhook icon
Script icon
Script icon
Post icon
SlackExecution icon

Webhook to PowerShell Healthcheck to ServiceNow Incident

Kestra flow that validates a webhook payload in Python, runs a PowerShell VM healthcheck, creates a ServiceNow incident with the results, and escalates failures.

Categories
Business

Give edge and retail operations teams a self-service healthcheck endpoint that always ends in a ticket. This Kestra blueprint exposes a secured webhook: callers POST a small JSON request describing a VM and the checks they want, Python validates and enriches the payload, PowerShell collects disk capacity metrics, and the results land as a properly categorized ServiceNow incident assigned back to the requester. If anything in the pipeline breaks, the errors branch opens a priority 1 incident and notifies Slack, so a failed healthcheck can never disappear silently.

How it works

  1. The webhook trigger (io.kestra.plugin.core.trigger.Webhook) accepts a POST secured by HEALTHCHECK_WEBHOOK_KEY. Manual executions fall back to inputs.defaultWebhookPayload so you can test without a caller.
  2. The validate_payload task (io.kestra.plugin.scripts.python.Script) enforces required fields, whitelists the requested checks, maps priority to a ServiceNow severity via PRIORITY_TO_SEV, sanity-checks the requester email, stamps receivedAt, and publishes everything with Kestra.outputs().
  3. The run_powershell_commands task (io.kestra.plugin.scripts.powershell.Script) reads the validated payload, enumerates fixed drives with System.IO.DriveInfo (works on Windows and Linux), computes size, free space, and percent free per volume, derives an advice string when any volume drops under 15 percent free, and writes healthcheck_report.json as an output file.
  4. The create_servicenow_incident task (io.kestra.plugin.servicenow.Post) files an incident on the incident table with the VM name, store id, request id, advice, the requester as caller_id, and the mapped priority.
  5. Two errors tasks handle failure: create_servicenow_incident_on_error (io.kestra.plugin.servicenow.Post) opens a priority 1 incident with errorLogs() and a deep link to the execution, and send_slack_notification_on_error (io.kestra.plugin.slack.SlackExecution) pings the on-call channel with allowFailure: true so a Slack outage never masks the original error.

What you get

  • A secured, self-service HTTP endpoint for on-demand VM healthchecks.
  • Strict payload validation so garbage requests fail fast with a clear reason.
  • A machine-readable healthcheck_report.json artifact stored with the execution.
  • Every healthcheck and every failure recorded as a ServiceNow incident with correct priority mapping.

Who it's for

  • IT operations teams running fleets of edge or branch VMs behind ServiceNow.
  • Windows-heavy shops that want PowerShell diagnostics orchestrated, not scattered in scheduled tasks.
  • Service desk owners who need requester-attributed tickets from automated tooling.

Why orchestrate this with Kestra

Wiring a webhook receiver, a script host, and the ServiceNow API together normally means custom middleware with its own auth, logging, and failure handling. Kestra collapses that into one declarative flow: the webhook trigger handles ingress with a secret key, Python and PowerShell run as first-class script tasks with dependency management and output files, and the errors branch gives you guaranteed escalation. Every request is an execution with full logs, so when a store manager asks what happened to their healthcheck, the answer is one click away.

Prerequisites

  • A ServiceNow instance with API access to create records on the incident table.
  • A Kestra worker with Python and PowerShell script execution available.
  • Set the serviceNowInstance variable to your instance name.
  • A Slack incoming webhook for error notifications.

Secrets

  • HEALTHCHECK_WEBHOOK_KEY: shared secret guarding the Webhook trigger.
  • SERVICENOW_USERNAME, SERVICENOW_PASSWORD: credentials used by both Post tasks.
  • SLACK_WEBHOOK: Slack incoming webhook URL for the on-error notification.

Quick start

  1. Add the four secrets to your Kestra namespace and set serviceNowInstance.
  2. Deploy the flow and run it manually; the default payload exercises the whole pipeline.
  3. Check ServiceNow for the created incident and the execution for healthcheck_report.json.
  4. POST a real payload to the webhook URL with your key to go live.
  5. Point your monitoring tool, portal, or chatbot at the webhook.

How to extend

  • Add more checks (memory, services, certificates) to ALLOWED_CHECKS and the PowerShell script.
  • Attach healthcheck_report.json to the incident or store it in S3 for trend analysis.
  • Auto-close the incident when all metrics are healthy and only leave low-disk tickets open.
  • Fan out to many VMs with io.kestra.plugin.core.flow.ForEach over a CMDB query.
  • Swap ServiceNow for Jira with io.kestra.plugin.jira.issues.CreateIssue.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.