ROB-834 Add workflow trigger action to fire Robusta platform workflows - #2133
Conversation
…an alert New alert-triggered playbook action that POSTs the entire alert payload (labels, annotations, status, timestamps, generatorURL, fingerprint) plus the cluster name to the Robusta platform /webhooks endpoint with one or more workflow_id params, starting a Triggered Workflow run — typically a Holmes investigation. Optional route_to_alert_cluster targets the workflow at the cluster the alert fired in via the cluster URL param. Tested with a real HTTP capture server against a KubeNodeUnschedulable (node cordoned) alert; the request contract is mirrored end-to-end in relay's tests/test_workflow_trigger_alert_e2e.py. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SSJqTBghtypCiZUwDDvP7a
The triggered workflow now runs against the cluster the alert fired in by default; set route_to_alert_cluster: false to keep the workflow definition's configured cluster. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SSJqTBghtypCiZUwDDvP7a
WalkthroughAdds the ChangesWorkflow webhook trigger
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PrometheusKubernetesAlert
participant trigger_workflow
participant RobustaPlatformWebhooks
PrometheusKubernetesAlert->>trigger_workflow: provide alert and parameters
trigger_workflow->>trigger_workflow: build payload and routing parameters
trigger_workflow->>RobustaPlatformWebhooks: send authenticated POST request
RobustaPlatformWebhooks-->>trigger_workflow: return HTTP response
trigger_workflow-->>PrometheusKubernetesAlert: log success or raise ActionException
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Docker image ready for
Use this tag to pull the image for testing. 📋 Copy commandsgcloud auth configure-docker us-central1-docker.pkg.dev
docker pull us-central1-docker.pkg.dev/robusta-development/temporary-builds/robusta-runner:ec4f2c3
docker tag us-central1-docker.pkg.dev/robusta-development/temporary-builds/robusta-runner:ec4f2c3 me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:ec4f2c3
docker push me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:ec4f2c3Patch Helm values in one line: helm upgrade --install robusta robusta/robusta \
--reuse-values \
--set runner.image=me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:ec4f2c3 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@playbooks/robusta_playbooks/workflow_trigger.py`:
- Line 54: Update the timeout field validation in the workflow trigger
parameters to accept only positive values, using Pydantic V1 validation such as
PositiveInt or an equivalent constraint. Add coverage for zero and negative
timeout inputs, ensuring both are rejected during parameter validation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1fa94bc6-63fa-4f0b-99cd-b09c09025fb9
📒 Files selected for processing (2)
playbooks/robusta_playbooks/workflow_trigger.pytests/test_workflow_trigger.py
Summary
This PR adds a new
trigger_workflowaction that enables Robusta playbooks to trigger platform Triggered Workflows (such as Holmes investigations) in response to Prometheus alerts. The action sends the complete alert payload and cluster context to the platform's webhooks endpoint.Key Changes
New action module (
playbooks/robusta_playbooks/workflow_trigger.py):TriggerWorkflowParams: Configuration class supporting single or multiple workflow IDs, API authentication, optional cluster routing, and request timeout settingsbuild_workflow_trigger_payload(): Constructs webhook body containing the full alert payload (labels, annotations, status, timestamps, etc.) plus cluster nametrigger_workflow(): Main action that POSTs to the platform webhooks endpoint with proper query parameters and authorization headersComprehensive test suite (
tests/test_workflow_trigger.py):Notable Implementation Details
SecretStrfor API keyshttps://claude.ai/code/session_01SSJqTBghtypCiZUwDDvP7a