# New Relic

[<mark style="color:blue;">New Relic</mark>](https://newrelic.com/) is an observability platform built to help engineers create more perfect software. From monoliths to serverless, you can instrument everything, then analyze, troubleshoot, and optimize your entire software stack, all from one place.

Route detailed monitoring alerts from New Relic to the right users in Squadcast.

### How to integrate New Relic with Squadcast

#### In Squadcast: Using New Relic as an Alert Source

1. Navigate to **Services** -> **Service Overview** -> select or search for your Service. Expand the accordion -> In the Alert Sources section, click **Add**.

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-4fbd74e7ca0b30173c47a1d58ed6a0804a0465aa%2FAlert_Sources.png?alt=media\&token=aaca6610-9d18-4dd4-9cf5-320042f326f1)

2\. Select **New Relic.** Copy the displayed **Webhook URL** to [configure](#in-new-relic-add-a-squadcast-webhook) it within **New Relic**. Finish by clicking **Add Alert Source** -> **Done.**

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-a9255b07491d7b416136f59dc641dd52c2538a85%2FNew%20Relic.png?alt=media)

{% hint style="warning" %}
**Important:**

When an alert source turns Active, it’ll show up under Configured Alert Sources, you can either generate a test alert from the integration or wait for a real-time alert to be generated by the Alert Source. An Alert Source is active if there is a recorded incident via that Alert Source for the Service.
{% endhint %}

#### In New Relic: Add a Squadcast Webhook

Log in to your New Relic account.

**(1)** From **Explorer** dashboard, click on **Alerts & AI**. Then naviagte to **Workflows** and click on **+ Add a workflow**

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-f1efd9ee20d92973bf57510ed3a8c162da53ac60%2Fnew_relic_2_new.png?alt=media)

**(2)** Fill in the **Name**, select Issues according to your own preference. Under **Mute issues**, choose **Always send notifications** and click on **Webhook**

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-3f1dcc7261d005bfe88e6b8e5902ccd00e0ad981%2Fnew_relic_4_new.png?alt=media)

**(3)** Put in the webhook channel's name and click on **+ Add a destination**

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-45046c46bf3d524dcf0631a95ad8303c97fb4182%2Fnew_relic_3_new.png?alt=media)

**(4)** Now, you can add a **Webhook name**, paste the previously copied Squadcast Webhook URL in the placeholder for **Endpoint URL** and save it.

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-81148f7742b1843de022b943fdbc30c5fd3665b7%2Fnew_relic_5_new.png?alt=media)

**(5)** Select the previously created Squadcast Webhook as **Destination** and paste the payload mentioned below under the **Payload template**. Then click on **Update message**

```json
{
    "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 }},
    "isCorrelated": {{ json isCorrelated }},
    "createdAt": {{ createdAt }},
    "updatedAt": {{ updatedAt }},
    "sources": {{ json accumulations.source }},
    "alertPolicyNames": {{ json accumulations.policyName }},
    "alertConditionNames": {{ json accumulations.conditionName }},
    "workflowName": {{ json workflowName }},
    "status" : {{ json status }},
    "annotationsDescription":{{json annotations.description.[0]}}
}
```

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-c345ff9007934c300bba675ef9f5bbd894f36706%2Fnew_relic_6_new.png?alt=media)

You can also send test notifications to Squadcast through **Send test notification**

{% hint style="info" %}
**Note**

**Add Additional Incident Information**

You can even send additional information for an incident.

Users can define additional variables along with the default variables to receive more detailed information about an Incident under the **Payload template**. You can copy the template mentioned below instead of the template mentioned above for **Step (5)**

```json
{
	"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 }},
	"isCorrelated": {{ json isCorrelated }},
	"createdAt": {{ createdAt }},
	"updatedAt": {{ updatedAt }},
	"sources": {{ json accumulations.source }},
	"alertPolicyNames": {{ json accumulations.policyName }},
	"alertConditionNames": {{ json accumulations.conditionName }},
	"workflowName": {{ json workflowName }},
    "status" : {{ json status }},
    "annotationsDescription":{{json annotations.description.[0]}},
    "showAdditionalData":"true",
    "additionalData":{
    {{#if nrAccountId}}"account_id": {{nrAccountId}},{{/if}}
    "account_name": {{json accumulations.tag.account.[0]}},
    "closed_violations_count": {
        "critical": {{#if closedIncidentsCount}}{{closedIncidentsCount}}{{else}}0{{/if}},
        "warning": 0,
        "total": {{#if closedIncidentsCount}}{{closedIncidentsCount}}{{else}}0{{/if}}
    },
    "condition_family_id": {{accumulations.conditionFamilyId.[0]}},
    "condition_id": {{accumulations.conditionFamilyId.[0]}},
    "condition_name": {{json accumulations.conditionName.[0]}},
    "current_state": {{#if issueClosedAt}}"closed"{{else if issueAcknowledgedAt}}"acknowledged"{{else}}"open"{{/if}},
    "details": {{json issueTitle}},
    "duration": {{#if issueDurationMs}}{{issueDurationMs}}{{else}}0{{/if}},
    "event_type": "INCIDENT",
    "incident_acknowledge_url": {{json issueAckUrl}},
    "incident_url": {{json issuePageUrl}},
    "issue_id": {{json issueId}},
    "metadata": {
        {{#if locationStatusesObject}}"location_statuses": {{json locationStatusesObject}},{{/if}}
        {{#if accumulations.metadata_entity_type}}"entity.type": {{json accumulations.metadata_entity_type.[0]}},{{/if}}
        {{#if accumulations.metadata_entity_name}}"entity.name": {{json accumulations.metadata_entity_name.[0]}}{{/if}}
    },
    "open_violations_count": {
        "critical": {{#if openIncidentsCount}}{{openIncidentsCount}}{{else}}0{{/if}},
        "warning": 0,
        "total": {{#if openIncidentsCount}}{{openIncidentsCount}}{{else}}0{{/if}}
    },
    "policy_name": {{json accumulations.policyName.[0]}},
    "radar_entity": {
        {{#if accumulations.tag.accountId}}"accountId": {{json accumulations.tag.accountId.[0]}},{{/if}}
        "domain": {{json accumulations.conditionProduct.[0]}},
        "domainId": {{json issueId}},
        "entityGuid": {{json entitiesData.entities.[0].id}},
        "name": {{#if accumulations.targetName}}{{json accumulations.targetName.[0]}}{{else if entitiesData.entities}}{{json entitiesData.entities.[0].name}}{{else}}"NA"{{/if}},
        "type": {{#if entitiesData.types.[0]}}{{json entitiesData.types.[0]}}{{else}}"NA"{{/if}}
    },
    "severity": "{{#eq 'HIGH' priority}}WARNING{{else}}{{priority}}{{/eq}}",
    "state": {{json state}},
    "status": {{json status}},
    "targets": [
        {
            "id": {{#if entitiesData.entities.[0].id}}{{json entitiesData.entities.[0].id}}{{else if accumulations.nrqlEventType}}{{json accumulations.nrqlEventType.[0]}}{{else}}"N/A"{{/if}},
            "name": {{#if accumulations.targetName}}{{json accumulations.targetName.[0]}}{{else if entitiesData.entities}}{{json entitiesData.entities.[0].name}}{{else}}"NA"{{/if}},
            "link": {{json issuePageUrl}},
            "product": {{json accumulations.conditionProduct.[0]}}
        }
    ],
        "timestamp": {{updatedAt}},
    "timestamp_utc_string": {{json issueUpdatedAt}},
    "version": "1.0",
    "VIOLATION DESCRIPTION": {{json accumulations.conditionDescription.[0]}},
    "violation_callback_url": {{json issuePageUrl}}
    {{#if accumulations.tag.action}},"action":{{json accumulations.tag.action.[0]}}{{/if}}
    {{#if accumulations.evaluationName}},"condition_metric_name": {{json accumulations.evaluationName.[0]}}{{/if}}
    {{#if accumulations.evaluationMetricValueFunction}},"condition_metric_value_function": {{json accumulations.evaluationMetricValueFunction.[0]}}{{/if}}
    {{#if labels.nrIncidentId}},"incident_id": {{labels.nrIncidentId.[0]}}{{/if}}
    {{#if owner}},"owner": {{json owner}}{{/if}}
    {{#if policyUrl}},"policy_url": {{json policyUrl}}{{/if}}
    {{#if accumulations.runbookUrl}},"runbook_url": {{json accumulations.runbookUrl.[0]}}{{/if}}
    }
}
```

{% endhint %}

**(6)** Finally click on **Activate workflow**. You can even test the workflow by clicking on **Test workflow**

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-c8b9c8e7fdb327e18ce2045317d62ec208ee3266%2Fnew_relic_7_new.png?alt=media)

That's it, you are good to go! Your New Relic integration is now complete.

Whenever New Relic fires an alert, an incident will be created in Squadcast for it. Also, when an alert is resolved in New Relic, the corresponding incident gets **auto-resolved** in Squadcast.

*Have any questions?* [*Ask the community*](https://community.squadcast.com/view/home)*.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.squadcast.com/integrations/alert-source-integrations-native/new_relic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
