Build a workflow to remediate web service failures
Build a workflow that detects when an NGINX web service fails, uses a task agent to analyze the failure, requests approval from the on-call team, and restarts the service through an Ansible Automation Platform job template.
This process uses a specific scenario: Prometheus Alertmanager detects HTTP 5xx errors from an NGINX service and forwards the alert through Event-Driven Ansible to automation orchestrator.
Prerequisites
Before you build the web service remediation workflow, verify that the following services and credentials are configured.
- An Ansible Automation Platform credential is configured in automation orchestrator. Navigate to Credentials to verify or create one.
- An LLM provider credential is configured in automation orchestrator.
- An Event-Driven Ansible controller instance is connected to your Ansible Automation Platform deployment.
- Prometheus Alertmanager is configured to detect NGINX service failures and send webhook alerts to Event-Driven Ansible. For more information, see the Event-Driven Ansible documentation.
- A remediation job template exists in Ansible Automation Platform that restarts the NGINX service on target hosts. For example, a playbook that runs
systemctl restart nginxorpodman restart nginx-container. - A project is available to contain your workflow.
Add an Event-Driven Ansible trigger
Add an Event-Driven Ansible trigger to start the workflow when a webhook receives an alert payload.
Procedure
Add a task agent step to analyze the failure
Add a task agent step that uses a large language model (LLM) to analyze the failure details from the trigger payload. The step produces a structured summary for the approver.
Procedure
Add an approval step for production remediation
Add an approval step that pauses the workflow and notifies on-call engineers to review the task agent analysis before the remediation job runs.
Procedure
Add an Ansible Automation Platform job template step to restart the service
Add an Ansible Automation Platform job template step that runs a playbook to restart the failed NGINX service.
Procedure
Connect and test the workflow
Connect the workflow steps on the canvas and run a test to verify the end-to-end flow.
Procedure
Configure the Event-Driven Ansible controller
Configure the Event-Driven Ansible controller to forward Prometheus alerts to the automation orchestrator webhook.
Procedure
- In your Event-Driven Ansible controller, create or update a rulebook activation to forward matching Prometheus alerts to the webhook URL you copied when you added the Event-Driven Ansible trigger.
- Ensure the rulebook includes a rule that matches the NGINX alert name and sends the payload with the fields defined in the input schema:
host,severity,service_name,alert_name, andlog_snippet.
Verify and publish the workflow
Test the completed workflow with a simulated alert, then publish it for production use.