A Mule 4 Process API that turns an operations alert into an actionable incident. POST /api/incidents pulls the last 30 minutes of service logs from Axiom, asks Azure OpenAI for a probable root cause and three recommended actions, opens a prioritised Jira ticket (P1/P2 as Incident, P3/P4 as Task), and optionally texts the field responder through Infobip. Severity stays under human/alert-source control; the model only advises. Includes the RAML contract, secure-property handling, and the hardening a delivery team needs: validation, de-duplication, timeouts, and partial-failure handling. Framed for energy and oil and gas operations.
Tags: energy, oil-and-gas, incident-response, aiops, azure-openai, axiom, jira, sms, infobip, process-api, api-led, root-cause-analysis, operations, mule-4
AI Incident Responder: Log-Grounded Triage, Jira Ticketing, and Field SMS
Deliverable: A single Mule 4 application exposing POST /api/incidents that takes an operations alert, pulls the last 30 minutes of logs for the affected system, gets an LLM root-cause analysis, opens a prioritised Jira ticket, and texts the on-call field team, all in one synchronous call.
Objective: In energy and oil & gas operations, an alert on an integration or control-adjacent system (for example an inbound B2B feed for nominations or field data) typically reaches a human who then has to open the log tool, guess at a cause, hand-write a ticket, and phone someone. At 2 a.m. that is slow and inconsistent, and the ticket rarely carries evidence. This blueprint turns every alert into a ticket that already contains a log-grounded probable cause and three recommended actions, and pushes a short SMS to the field responder, while keeping humans in the loop: the model advises, it never changes severity or remediates anything.
What's Getting Built
- /api/incidents (Process API, orchestrates four upstream systems) — receives an alert, enriches with logs, analyses, tickets, and notifies ·
POST /api/incidents
- Axiom (outbound connection, log store) — recent logs for the affected service ·
POST /v1/datasets/{dataset}/query
- Azure OpenAI (outbound, root-cause analysis) — chat completion on a deployed model ·
POST /openai/deployments/{deployment}/chat/completions
- Jira Cloud (outbound, ticketing) — creates the incident ticket ·
POST /rest/api/3/issue
- Infobip (outbound, SMS) — conditional field notification ·
POST /sms/2/text/advanced
Contract (RAML 1.0, ai-incident-responder-api): request fields alertId, severity (enum P1-P4), system, description (all required), notifyPhone (optional, E.164). Responses: 200, 400, 502.
Prerequisites
- Anypoint Platform org with a sandbox environment, Secrets Manager (or equivalent secure properties), and a deployment target (the reference build targets CloudHub 1.0, one small worker).
- Axiom account with an API token that can query the dataset your Mule apps log to. Those apps must already ship logs there with a
service field matching the alert's system value; without that the enrichment step returns nothing.
- Azure OpenAI resource with a chat model deployed (reference uses a
gpt-4o deployment). Confirm the data-processing terms permit sending operational logs; this is the approval that usually takes longest.
- Jira Cloud project (reference key
OPS) with issue types Incident and Task, and an API user whose token can create issues.
- Infobip account with an SMS sender enabled for your destination countries. Sender registration for some countries takes weeks.
- An alert source (monitoring tool, SIEM, scheduler) able to POST JSON to the endpoint.
- A named owner for each of the five systems. This build stalls on access, not code.
Architecture
1. Define the contract first
- Publish the RAML (or equivalent OAS) before writing flows; every consumer will be an alerting tool you do not control, so the contract is what you can hold them to.
- Required:
alertId, severity in P1-P4, system, description. Optional: notifyPhone in E.164 (for example +12145550199).
- Responses:
200 with alertId, severity, rootCause, recommendedActions, jiraTicketId, jiraTicketUrl, notificationSent, logsAnalyzed, analysisTimestamp; 400 with error; 502 for any upstream failure.
- Why: declaring
400 in the RAML does nothing on its own. Unless the flow validates the body (APIkit router or a validation step, see step 7), malformed requests reach the model and fail later as a misleading 502.
2. Listener and incident capture
- One HTTP listener on
/api/incidents, POST only, port from a property (http.port).
- Immediately store the inbound body in a flow variable (
vars.incident) before any call overwrites the payload. Every later step (query, prompt, ticket, SMS, response) reads from it.
- Keep the severity exactly as the caller sent it. It is an input to the process, not an output of the model (see step 4).
3. Enrich with logs from Axiom
- Call
POST /v1/datasets/{dataset}/query with a bearer token and an APL query: filter to the last 30 minutes, service == {system}, order by _time desc, limit 50, plus startTime/endTime for the same window.
- Reduce the response to a
logs variable: entries (the _raw of each match, defaulting to empty string) and count (sizeOf(matches default [])).
- Why newest-first and capped: the model sees the most recent evidence and the prompt stays a sane size. A noisy service can emit thousands of lines in 30 minutes.
- Edge case:
system is concatenated into the APL string. A value containing a single quote breaks the query or changes it. Validate system against an allow-list of known service names (or at minimum a strict pattern) before building the query.
- Edge case: zero matches is not an error. The flow continues with
count: 0, and the model must say so rather than invent a cause (step 4).
4. Root-cause analysis with Azure OpenAI
- Call
POST /openai/deployments/{deployment}/chat/completions?api-version=2024-02-01 with an api-key header (pin the API version you validated).
- Message shape: a
system message ("senior site reliability engineer ... identify the most likely root cause, and provide 3 recommended actions. Respond in JSON with fields: rootCause (string), recommendedActions (string with numbered list)") and a user message containing the incident serialised as JSON, the log count, and the log lines joined by newlines.
- Parameters in the reference:
temperature: 0.2, max_tokens: 600. Low temperature gives repeatable triage; the token cap bounds latency and cost.
- Parse
choices[0].message.content into vars.aiAnalysis, with a fallback of {rootCause: <raw text>, recommendedActions: "Review logs manually"} if parsing fails. Keep the fallback: models sometimes wrap JSON in prose or code fences, and a ticket with raw text beats a failed incident.
- Design decision: the model never sets severity or priority. Severity comes from the alert source. An LLM that downgrades a P1 because the logs look calm is the failure you are designing out. Add a prompt line telling the model to state "insufficient evidence" when
count is 0.
- Prompt hygiene: log lines are untrusted text and can contain attacker-controlled strings. Treat model output as advisory text only; it is never executed and never used to build a query or URL.
5. Create the Jira ticket
- Call
POST /rest/api/3/issue with Basic auth (user plus API token, Base64) and the project key from a property.
- Summary:
[{severity}] Incident {alertId} - {system}.
- Description in Atlassian Document Format (type
doc, version 1) with the root cause and the recommended actions.
- Issue type:
Incident for P1 and P2, Task otherwise. Priority map: P1 Highest, P2 High, P3 Medium, anything else Low.
- Keep the ticket id, key, and a browse URL (
{jira.base.url}/browse/{key}) in a variable for the SMS and the response.
- Why before SMS: the responder's text should carry the ticket key so they land on the evidence, not a bare alarm.
- Edge case: newlines inside a single ADF
text node do not render as separate paragraphs. If readability matters, split the numbered actions into separate paragraph nodes.
- Edge case: the Jira project must define the
Incident issue type. If it is missing, every P1/P2 returns a Jira 400 that surfaces as a 502.
6. Notify the field team (conditional)
- A
choice router: if notifyPhone is present, call POST /sms/2/text/advanced with Authorization: App {key}, sender MuleSoft, one destination, and text [{severity}] Alert {alertId} on {system}. Jira: {key}. Root cause: {first 80 chars}.
- Otherwise skip and set
notificationSent=false. Set notificationSent=true only after the SMS call returns.
- Why truncate: SMS segments are small; the full analysis lives in the ticket.
- Edge case: the truncation slice
[0 to 80] is applied to the root-cause string. Test it with a root cause shorter than 80 characters and with a missing one (the flow substitutes an empty string); confirm your runtime handles both without erroring.
- Edge case: a failed SMS currently fails the whole request even though the ticket already exists (step 7). Decide with the customer whether a notification failure should degrade to
notificationSent=false instead.
7. Response and error handling
- Build the
200 body from the variables above. logsAnalyzed is the number of log lines supplied to the model, which tells a reader how much evidence the analysis had. analysisTimestamp is now().
- The flow-level handler catches
ANY, returns {"error": "UPSTREAM_ERROR", "message": <error.description>}, and sets an httpStatus variable to 502. Make sure the listener's error response actually reads that variable for its status code; otherwise callers see the default error status with your JSON body.
- Known gaps in the reference build that a delivery team should close: no
400 validation despite the contract, no idempotency (see Deterministic checks), no explicit retry or timeout settings on the four outbound requests, and a catch-all that does not say which upstream failed. Return the failing system's name in the error body to speed triage.
- Partial failure matters: if Jira succeeds and SMS fails, a retry from the alert source creates a second ticket. This is the main reason to add de-duplication.
8. Security and compliance
- Secrets: every credential is a
${secure::...} property (Axiom token, Jira host/user/token, Infobip host/key, Azure OpenAI host/key). Plain properties hold only non-secret config: port, dataset name, deployment name, project key. Never commit literal values.
- Standards: for energy operators this flow sits near NERC CIP and IEC 62443 concerns. Treat logs as potentially sensitive operational data; confirm with security that log lines may leave the network to Azure OpenAI and Jira, and mask hostnames, IPs, and credentials in log lines before they enter the prompt.
- Transport: all outbound connections are HTTPS on 443. Front the listener with API Manager policies (client ID enforcement and rate limiting at minimum) because anyone who can reach it can create tickets and send SMS at your expense.
- Logging: log
alertId, severity, upstream status codes, and logsAnalyzed. Never log Authorization headers, the full prompt, or notifyPhone in clear text; phone numbers are personal data.
- Model use: confirm in the Azure OpenAI agreement how prompts are retained and used; the model has no tools and no write access in this design.
Sample payload - a P2 alert on an inbound B2B endpoint
Request (POST /api/incidents):
{
"alertId": "ALT-9921",
"severity": "P2",
"system": "b2b-inbound-http-rnve",
"description": "Inbound HTTP listener error rate above threshold",
"notifyPhone": "+12145550199"
}
Response 200 has this shape (values depend on your logs and model):
{
"alertId": "ALT-9921",
"severity": "P2",
"rootCause": "{model-generated cause}",
"recommendedActions": "1. {action} 2. {action} 3. {action}",
"jiraTicketId": "{jira-key}",
"jiraTicketUrl": "https://{jira-host}/browse/{jira-key}",
"notificationSent": true,
"logsAnalyzed": 50,
"analysisTimestamp": "{ISO-8601 datetime}"
}
Error: {"error": "UPSTREAM_ERROR", "message": "{upstream error description}"} with status 502.
Deterministic checks
POST /api/incidents with a valid body returns 200 and every field in the response contract, with jiraTicketId non-empty.
- Severity in the response and the Jira ticket equals the severity in the request, regardless of model output.
- Priority and issue type mapping is fixed: P1 Highest/
Incident, P2 High/Incident, P3 Medium/Task, P4 Low/Task.
notificationSent is true if and only if notifyPhone was supplied and the Infobip call returned successfully.
- When any upstream returns an error, the response is
502 with error: "UPSTREAM_ERROR", never a 200.
- If the model returns non-JSON text, the ticket is still created, with the raw text as the root cause and "Review logs manually" as the action.
- Target (not present in the reference build): replaying the same
alertId within a de-duplication window returns the existing ticket and does not create a second one. Implement with an Object Store keyed on alertId, or a Jira JQL lookup.
- The reference project declares MUnit dependencies but ships no test files. Write the suite under
src/test/munit, mocking the four HTTP requests, and require it to pass in CI before deploy.
Testing and validation
- Happy path in a sandbox against real Axiom, a test Jira project, Azure OpenAI, and an Infobip number you own: check the ticket renders, the SMS arrives, and
logsAnalyzed equals the number of lines Axiom holds for that service (up to 50).
- Edge case that breaks a naive build: the same alarm firing repeatedly (flapping threshold). Without de-duplication each repeat creates a ticket, an LLM call, and an SMS. Test five identical posts in a minute.
- Edge case: a
system that matches no log entries. Expect logsAnalyzed: 0; read the produced root cause and confirm it does not fabricate a specific fault.
- Edge case: Axiom returns no
matches key or Azure returns an unexpected shape; the default expressions should keep the flow alive.
- Edge case: a
system value with a quote character (see step 3).
- Mapping accuracy: take ten historical incidents with known causes, replay their logs, and score whether the root cause and three actions would have pointed responders the right way. Treat the model as a triage aid and measure it as one.
- Negative tests: bad Jira credentials, a revoked Azure key, and a malformed phone number each produce the documented
502.
Phased rollout
Phase 1 - Connect
- Deploy to sandbox with real secrets in Secrets Manager. Prove each of the four outbound calls individually (Axiom query, one completion, one Jira issue, one SMS) before chaining them.
Phase 2 - Map and validate
- Wire one non-critical alert source, P3/P4 only, to a test Jira project. Add validation, de-duplication, and timeouts. Review model outputs weekly with the operations lead and tune the system prompt.
Phase 3 - Production
- Enable P1/P2 with a named on-call phone, apply API Manager policies, alert on the endpoint's own error rate, and keep the manual paging path as fallback until responders trust the output.
Success metrics
- Time from alert to a ticket with probable cause attached (baseline from your current process; the flow itself is one synchronous call).
- Time to acknowledge for P1/P2, before versus after SMS notification.
- Share of tickets where responders rate the recommended actions useful in a review sample; track this explicitly.
- Duplicate-ticket rate per alert, expected to be zero after de-duplication.
- Platform side: endpoint
502 share, p95 latency (dominated by the model call), and Azure OpenAI token spend per incident.
Troubleshooting
502 UPSTREAM_ERROR on every call — Likely cause: a missing or wrong ${secure::...} property, or a host property pointing at the wrong tenant. Fix: call each upstream directly with the same credentials and read the message field in the error body.
logsAnalyzed is always 0 — Likely cause: the alert's system does not match the service field in the dataset, or the dataset name is wrong. Fix: run the APL query by hand in Axiom and align naming.
- Jira returns 400 for P1/P2 only — Likely cause: the
Incident issue type does not exist in the project. Fix: add it to the project's issue type scheme or change the mapping.
- Root cause shows raw prose or code fences — Likely cause: the model wrapped JSON in extra text so parsing fell back. Fix: tighten the prompt, use the API's JSON response format option if your model version supports it, and strip fences before parsing.
- Duplicate tickets and repeated SMS — Likely cause: the alert source retries or flaps, and there is no idempotency. Fix: de-duplicate on
alertId and add a suppression window.
- Callers see 500 instead of 502 — Likely cause: the
httpStatus variable is set but not read by the listener error response. Fix: map it in the listener's error response status code expression.
- Ticket created but caller got an error — Likely cause: the SMS call failed after Jira succeeded. Fix: handle the notification step in its own error scope and report
notificationSent: false.
- Slow responses — Likely cause: the sequential four-call chain, dominated by the model. Fix: set explicit timeouts, keep
max_tokens low, and consider async acknowledgement for non-critical severities.