> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aciona.me/llms.txt
> Use this file to discover all available pages before exploring further.

# New Relic

> Connect New Relic to aciona.me with Workflows and a Webhook destination.

## Overview

New Relic sends alerts through a **Webhook destination**, rendering a Handlebars template over the issue payload. A **Workflow** decides which issues are sent and on which transitions.

|                     |                                           |
| ------------------- | ----------------------------------------- |
| **Source type**     | `New Relic`                               |
| **Mechanism**       | Workflows + Webhook destination           |
| **Correlation**     | `issueId`                                 |
| **Auto-resolution** | ✅ (requires `Closed` under "Notify when") |

## Prerequisites

* Permission to create destinations and workflows in New Relic.
* A service created in aciona.me and linked to a team with an active schedule.

## 1. Create the alert source in aciona.me

Under **Alert sources**, create a source of type **New Relic**. Copy the URL and the token.

## 2. Create the Webhook destination

Under **Alerts → Destinations → Webhook → Create**:

<Steps>
  <Step title="Name">
    `aciona-me`
  </Step>

  <Step title="URL">
    `https://ingress.aciona.me/webhooks/<alertSourceId>`
  </Step>

  <Step title="Secure custom header">
    Name `X-Aciona-Token`, value `<sourceToken>`. New Relic masks the value after saving.
  </Step>

  <Step title="Payload template">
    Paste the recommended Handlebars template:

    ```handlebars theme={null}
    {
      "issueId": {{json issueId}},
      "state": {{json state}},
      "triggerEvent": {{json triggerEvent}},
      "priority": {{json priority}},
      "issueTitle": {{json issueTitle}},
      "issuePageUrl": {{json issuePageUrl}},
      "issueCreatedAt": {{json issueCreatedAt}},
      "issueClosedAt": {{json issueClosedAt}},
      "accountId": {{json accountId}},
      "accountName": {{json accountName}},
      "conditionName": {{json accumulations.conditionName}},
      "conditionDescription": {{json accumulations.conditionDescription}},
      "policyName": {{json accumulations.policyName}},
      "policyUrl": {{json accumulations.policyUrl}},
      "runbookUrl": {{json accumulations.runbookUrl}},
      "entityName": {{json entitiesData.entities.[0].name}},
      "entityType": {{json entitiesData.entities.[0].type}},
      "entityGuid": {{json entitiesData.entities.[0].guid}},
      "tags": {{json tags}},
      "details": {{json details}}
    }
    ```
  </Step>
</Steps>

## 3. Create the Workflow

Under **Alerts → Workflows → New workflow**:

<Steps>
  <Step title="Filter (optional)">
    For example, only issues with `CRITICAL` or `HIGH` priority.
  </Step>

  <Step title="Notify → Add destination → Webhook">
    Select `aciona-me`.
  </Step>

  <Step title="Notify when — the critical step">
    Open the **"Notify when"** menu and make sure **BOTH** are checked:

    * ✅ `Activated`
    * ✅ `Closed`
  </Step>
</Steps>

<Warning>
  **An unchecked `Closed` is the number-one problem in New Relic integrations.** Without it, New Relic only sends the opening event and incidents in aciona.me never close on their own. It is the equivalent of Alertmanager's `send_resolved: true`.
</Warning>

## 4. Test

Use **Test workflow** to send a sample payload. Confirm the incident under **Incidents**.

To validate auto-resolution, wait for an issue to close naturally (or close it manually) and confirm the matching incident was resolved.

## How fields are translated

### State

The decision follows this order of precedence:

| Origin          | Values                                                                                                          |
| --------------- | --------------------------------------------------------------------------------------------------------------- |
| `state`         | `CREATED`, `ACTIVATED` → opens · `CLOSED` → resolves                                                            |
| `triggerEvent`  | `CLOSE_INACTIVE`, `CLOSE_TTL`, `USER_ACTION` → resolves · `STATE_CHANGE`, `INCIDENT_ADDED`, `ACTIVATED` → opens |
| `issueClosedAt` | Present → resolves                                                                                              |
| Default         | Opens (prefers to notify)                                                                                       |

<Note>
  `triggerEvent = INCIDENT_CLOSED` does **not** resolve the incident. In New Relic's Issues model, an issue can hold several sub-events; closing one of them does not mean the issue is over. Resolving there would close the incident too early.
</Note>

### Severity

| `priority` | Severity   |
| ---------- | ---------- |
| `CRITICAL` | `critical` |
| `HIGH`     | `high`     |
| `MEDIUM`   | `warning`  |
| `LOW`      | `info`     |

### Service

The hint comes, in order, from the affected-service tag, the entity name, the condition name and the policy name. Tag your entities with a service tag that matches the name in aciona.me.

## Troubleshooting

<AccordionGroup>
  <Accordion title="The incident opens but never closes" icon="triangle-alert">
    `Closed` is not checked under "Notify when" in the Workflow. Check it and test again.
  </Accordion>

  <Accordion title="Webhooks suddenly stopped arriving" icon="bell-off">
    New Relic puts destinations into automatic **snooze** after consecutive errors (4xx, 5xx or timeouts). Check the destination status in New Relic. To catch this proactively, create an NRQL alert on `NrIntegrationError` with `category='NotificationError'`.
  </Accordion>

  <Accordion title="Title shows as Untitled alert" icon="type">
    The template does not emit `issueTitle`. Use the recommended template.
  </Accordion>

  <Accordion title="Severity lower than expected" icon="gauge">
    New Relic's historical template maps `HIGH` to `WARNING` in a legacy field. Emit `priority` explicitly, as in the template above — it takes precedence.
  </Accordion>
</AccordionGroup>
