Turn every New Relic alert into a tracked Jira ticket

By General Input

Every New Relic alert opens a Jira bug with the full context and a Slack heads up, then closes itself with the incident duration when it recovers.

Integrations

  • New Relic
  • Jira
  • Slack

Type

Deterministic Code

Categories

  • Engineering

Build me a deterministic code workflow that turns every New Relic alert into a tracked Jira ticket, so no alert scrolls past in a chat channel without leaving a permanent record. Trigger it with a webhook. I will point a New Relic alert workflow at the webhook URL as a notification destination, so every incoming request is a New Relic issue event payload.

Branch on the issue state in the payload. When the payload says a New Relic issue opened, run the open branch. When it says the issue closed, run the close branch. There is no judgement anywhere in this workflow, every field is a fixed mapping and the state field decides the path, so keep all of it in code.

Open branch: create a Jira bug with Create Issue. Build the summary from the New Relic condition name and the affected entity, for example "New Relic: <condition name> on <entity name>". In the description include the condition name, the affected entity or entities, the alert priority as New Relic reported it, the timestamp the issue opened, and a direct link back to the New Relic issue so whoever picks up the ticket can jump straight to the telemetry. Set the Jira priority with this fixed lookup on the New Relic priority: CRITICAL becomes Highest, HIGH becomes High, MEDIUM becomes Medium, LOW becomes Low. If the priority is missing or unrecognised, default to Medium.

This next part is what makes the close branch possible, so do not skip it: write the New Relic issue id onto the Jira issue at creation time. Add a label of the form newrelic-<issue id>, and also print the raw issue id on its own line in the description. The close branch finds the ticket again by that label, so the id has to live somewhere a JQL query can match exactly.

Then post the ticket to Slack with Send a Message, to a channel I will configure. The message should carry the Jira issue key and a clickable link to the ticket, plus the condition name, the affected entity and the priority, so the channel sees both the alert itself and where it is now being tracked.

Close branch: when the payload says the New Relic issue closed, find the matching ticket with Search Issues (JQL), querying on the label that holds the New Relic issue id, something like labels = "newrelic-<issue id>" scoped to my Jira project. Take the most recently created match. Move it to Done with Do Transition, resolving the transition by its name rather than hardcoding a transition id, since those ids differ from project to project. Carry a comment on that transition recording how long the incident stayed open, computed as the difference between the opening and closing timestamps in the New Relic payloads and written in plain terms, for example "New Relic issue closed after 2h 14m", along with the closing timestamp. If the transition will not accept a comment, add it separately with Add Comment.

A few fixed guards, all deterministic. Before creating anything on the open branch, run the same JQL lookup first, and if a ticket already exists for that New Relic issue id, skip creation instead of opening a duplicate, because webhook deliveries can retry. On the close branch, if no ticket matches the issue id, post a short note to the same Slack channel saying a close event arrived with no matching ticket, rather than failing the run. If the matched ticket is already in Done, leave it alone.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentWin back LiveChat visitors whose chats went unansweredChat quality review board for LiveChat support leadsWin back no-show and cancelled appointments every morningLive Loop returns analytics with product-level drill-downNewsletter pre-flight and approval board for Mailjet sendsTurn a prospect spreadsheet into personalized sequence enrollmentsMailjet email delivery lookup console for support teamsCatch feature flags that never got switched on in productionKajabi customer support console for member access fixes