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

# New Relic

> Receive alerts from New Relic observability platform

## Overview

Easyalert automatically detects and processes webhooks from New Relic Workflows.

<Info>
  New Relic Workflows is the recommended method for new integrations. Classic
  Alerts is deprecated but still supported.
</Info>

***

## Requirements

* **New Relic** account (One platform)
* **Easyalert account** and active tenant
* Access to **Alerts & AI → Workflows** in New Relic

***

## Setup Instructions

<Steps>
  <Step title="Create Integration in Easyalert">
    1. Go to **Integrations** page from left menu
    2. Click **Add Integration** button
    3. Select **New Relic** as **Source Type**
    4. Enter a name (e.g., `New Relic Production`)
    5. Click **Create** to save
    6. Copy the generated **Webhook URL**

    > **Example:** `https://api.easyalert.io/api/v1/webhooks/ingest/wh_abc123...`
  </Step>

  <Step title="Create Workflow in New Relic">
    Go to **Alerts & AI → Workflows → Add a workflow**
  </Step>

  <Step title="Create Webhook Destination">
    1. In **Notify** section, select **Webhook**
    2. Click **Create new destination**
    3. Paste Easyalert Webhook URL as **Endpoint URL**
  </Step>

  <Step title="Configure Payload Template">
    Use this recommended payload:

    ```json theme={null}
    {
      "id": {{ json issueId }},
      "issueUrl": {{ json issuePageUrl }},
      "title": {{ json annotations.title.[0] }},
      "priority": {{ json priority }},
      "impactedEntities": {{ json entitiesData.names }},
      "totalIncidents": {{ json totalIncidents }},
      "state": {{ json state }},
      "trigger": {{ json triggerEvent }},
      "sources": {{ json accumulations.source }},
      "alertPolicyNames": {{ json accumulations.policyName }},
      "alertConditionNames": {{ json accumulations.conditionName }},
      "workflowName": {{ json workflowName }},
      "description": {{ json annotations.description.[0] }},
      "customer": "YOUR_CUSTOMER_NAME",
      "team": "YOUR_TEAM_NAME",
      "environment": "production"
    }
    ```

    > **NOTE:** Handlebars syntax uses `{{ }}`. The `{{ json ... }}` helper produces JSON-safe output.
  </Step>

  <Step title="Test the Integration">
    Use the **Send test notification** feature in New Relic
  </Step>
</Steps>

***

## Handlebars Variables

New Relic Workflows use Handlebars syntax:

| Variable                                 | Description                              |
| ---------------------------------------- | ---------------------------------------- |
| `{{ json issueId }}`                     | Issue ID                                 |
| `{{ json issuePageUrl }}`                | New Relic UI link                        |
| `{{ json annotations.title.[0] }}`       | Issue title                              |
| `{{ json annotations.description.[0] }}` | Issue description                        |
| `{{ json state }}`                       | ACTIVATED, CLOSED, CREATED, ACKNOWLEDGED |
| `{{ json priority }}`                    | CRITICAL, HIGH, MEDIUM, LOW              |
| `{{ json triggerEvent }}`                | STATE\_CHANGE, INCIDENT\_ADDED, etc.     |
| `{{ json entitiesData.names }}`          | Impacted entities                        |
| `{{ json totalIncidents }}`              | Number of incidents                      |
| `{{ json accumulations.policyName }}`    | Policy names                             |
| `{{ json accumulations.conditionName }}` | Condition names                          |
| `{{ json accumulations.source }}`        | Alert sources                            |
| `{{ json workflowName }}`                | Workflow name                            |

***

## Field Mapping

| New Relic Field                              | Easyalert Field |
| -------------------------------------------- | --------------- |
| `issueId` / `id`                             | Event ID        |
| `annotations.title[0]` / `title`             | Title           |
| `annotations.description[0]` / `description` | Description     |
| `priority`                                   | Severity        |
| `state`                                      | Status          |
| `entitiesData.names` / `impactedEntities`    | Host/Service    |
| `issuePageUrl` / `issueUrl`                  | URL             |

***

## State and Severity Mapping

### Status Mapping

| New Relic State | Easyalert Status       |
| --------------- | ---------------------- |
| `ACTIVATED`     | Problem                |
| `CREATED`       | Problem                |
| `ACKNOWLEDGED`  | Problem (acknowledged) |
| `CLOSED`        | OK                     |
| `DEACTIVATED`   | OK                     |

### Severity Mapping

| New Relic Priority | Easyalert Severity |
| ------------------ | ------------------ |
| `CRITICAL`         | Critical           |
| `HIGH`             | Critical           |
| `MEDIUM`           | Warning            |
| `LOW`              | Info               |

***

## Trigger Events

| Trigger Event      | Description                 |
| ------------------ | --------------------------- |
| `STATE_CHANGE`     | Issue state changed         |
| `INCIDENT_ADDED`   | New incident added to issue |
| `INCIDENT_CLOSED`  | Incident closed             |
| `PRIORITY_CHANGED` | Priority updated            |
| `ACKNOWLEDGED`     | Issue acknowledged          |

***

## Custom Field → Tag Conversion

**All custom fields** you add to the template are automatically captured as tags.

### Example

Template:

```json theme={null}
{
  "id": {{ json issueId }},
  "state": {{ json state }},
  "customer": "AcmeCorp",
  "datacenter": "EU-West"
}
```

In Easyalert:

```
tags.policy = "Production Policy"
tags.condition = "High CPU"
tags.customer = "AcmeCorp"
tags.datacenter = "EU-West"
```

***

## Routing Examples

**Escalation Routing:**

```
tags.customer equals "AcmeCorp" → Acme Corp Policy
tags.environment equals "production" → Production Policy
tags.alertPolicyNames contains "Critical" → Critical Policy
```

**Notification Rules:**

```
tags.priority equals "CRITICAL" → call + sms + email
tags.sources contains "Infrastructure" → Infra Team channel
```

***

## Workflow Filter Examples

### Critical Issues Only

```
priority = 'CRITICAL'
```

### Specific Policies

```
accumulations.policyName LIKE '%Production%'
```

### Specific Entity Types

```
entitiesData.types = 'HOST'
```

***

## Test

```bash theme={null}
curl -X POST "YOUR_WEBHOOK_URL" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "NR1-123",
    "title": "High CPU Usage",
    "state": "ACTIVATED",
    "trigger": "STATE_CHANGE",
    "priority": "CRITICAL",
    "impactedEntities": ["web-server-01"],
    "alertPolicyNames": ["Production Policy"],
    "alertConditionNames": ["High CPU"],
    "createdAt": 1733234400000,
    "customer": "TestCustomer"
  }'
```

### Recovery Test

```bash theme={null}
curl -X POST "YOUR_WEBHOOK_URL" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "NR1-123",
    "state": "CLOSED",
    "trigger": "STATE_CHANGE"
  }'
```

***

## Classic Alerts Setup (Legacy)

For legacy New Relic alerts:

<Steps>
  <Step title="Create Notification Channel">
    1. Go to **Alerts → Notification channels** 2. Click **New notification
       channel** 3. Select **Webhook**
  </Step>

  <Step title="Configure Webhook">
    * **Channel name**: Easyalert - **Base URL**: Your Easyalert webhook URL
  </Step>

  <Step title="Add to Policies">
    1. Go to your alert policy 2. Add the webhook channel to notification
       settings
  </Step>
</Steps>

### Classic Alerts Field Mapping

| New Relic Field   | Easyalert Field |
| ----------------- | --------------- |
| `incident_id`     | Event ID        |
| `condition_name`  | Title           |
| `details`         | Description     |
| `severity`        | Severity        |
| `current_state`   | Status          |
| `targets[0].name` | Host            |
| `incident_url`    | URL             |

***

## Troubleshooting

<AccordionGroup>
  <Accordion title="Webhooks not being received">
    1. Test destination from New Relic UI
    2. Verify workflow filter matches your issues
    3. Check workflow is enabled
    4. Verify destination URL is correct
  </Accordion>

  <Accordion title="Custom fields not becoming tags">
    1. Verify field is added to webhook payload template
    2. Check field name spelling
    3. View webhook samples in Easyalert
  </Accordion>

  <Accordion title="Invalid JSON error">
    1. Use `{{ json ... }}` helper for proper formatting
    2. Verify Handlebars template syntax
    3. Check field names match New Relic schema
    4. Test with simplified payload first
  </Accordion>

  <Accordion title="Issues not auto-resolving">
    1. Verify CLOSED state triggers workflow
    2. Check `issueId` matches between states
    3. Ensure workflow sends on all state changes
  </Accordion>

  <Accordion title="Wrong priority mapping">
    1. Check priority field in payload
    2. Configure custom severity mapping
    3. Verify priority is set on alert conditions
  </Accordion>
</AccordionGroup>

***

## Best Practices

<AccordionGroup>
  <Accordion title="Use Workflows">
    Migrate to Workflows for better control and flexibility over Classic Alerts.
  </Accordion>

  <Accordion title="Include Entity Data">
    Add `entitiesData.names` to identify affected infrastructure or services.
  </Accordion>

  <Accordion title="Set Proper Priorities">
    Configure priority on your alert conditions for accurate severity mapping.
  </Accordion>

  <Accordion title="Add Custom Fields for Routing">
    Include `customer`, `team`, `environment` in payload for escalation routing.
  </Accordion>

  <Accordion title="Include Runbook URLs">
    Add runbook links in alert conditions for quick remediation access.
  </Accordion>

  <Accordion title="Use Tags">
    Leverage `accumulations.tag.*` for routing and filtering in Easyalert.
  </Accordion>
</AccordionGroup>
