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

# New Relic

> Client-mode REST API connector for a curated New Relic slice: Metric/Event/Log ingest from MQTT, NerdGraph NRQL queries, and REST v2 application list; alert webhook is an ENABLE_SERVER companion

Technical Preview

## Overview

A client-mode connector for a **curated observability / ITSM** slice of the [New Relic APIs](https://docs.newrelic.com/docs/apis/intro-apis/introduction-new-relic-apis/):

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| POST metric payload | `POST /metric/v1` | **Host:** `https://metric-api.newrelic.com` — Metric API; license `Api-Key`; expect **202** |
| POST events | `POST /v1/accounts/events` | **Host:** `https://insights-collector.newrelic.com` — Event API; license `Api-Key`; expect **200** |
| POST logs (source\_hint) | `POST /log/v1` | **Host:** `https://log-api.newrelic.com` — Log API; license `Api-Key`; expect **202** |
| POST NRQL via NerdGraph | `POST /graphql` | **Host:** `https://api.newrelic.com` — user `Api-Key`; GraphQL body with NRQL |
| GET applications (smoke) | `GET /v2/applications.json` | Same API host — REST API v2; user `Api-Key` |
| Alert webhook (inbound) | ENABLE\_SERVER companion | Not a client event — configure Alerts webhook → broker HTTP/MQTT |

Default `BASE_ADDRESS` is `https://metric-api.newrelic.com` (US Metric API). Topics use `itsm/new-relic/<object>/<verb>`.

> [!NOTE]
>
> Metric, Event, Log, and NerdGraph/REST use **different hosts**. Switch connector `BASE_ADDRESS` (or deploy copies) before calling non-Metric events. EU accounts use `metric-api.eu.newrelic.com`, `insights-collector.eu01.nr-data.net`, `log-api.eu.newrelic.com`, `api.eu.newrelic.com`.

> [!NOTE]
>
> Prefer Hub secrets for license and user API keys. This template has not been verified against a live New Relic account. Status remains blocked until an authenticated live smoke succeeds.

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — New Relic (Metric/Event/Log + NerdGraph + REST v2)
# Auth: Api-Key={value.json.api_key} (license for ingest; user key for NerdGraph/REST)
# BASE_ADDRESS Metric: https://metric-api.newrelic.com
# Event: set BASE to https://insights-collector.newrelic.com
# Log: set BASE to https://log-api.newrelic.com
# NerdGraph/REST: set BASE to https://api.newrelic.com

DEFINE ROUTE NewRelicRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://metric-api.newrelic.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Submitmetrics
        WITH SOURCE_TOPIC "itsm/new-relic/metric/submit"
        WITH DESTINATION_TOPIC "itsm/new-relic/metric/submit/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/metric/v1"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Api-Key" "{value.json.api_key}"
        WITH BODY "{payload}"
    ADD EVENT Submitevents
        WITH SOURCE_TOPIC "itsm/new-relic/event/submit"
        WITH DESTINATION_TOPIC "itsm/new-relic/event/submit/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1/accounts/events"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Api-Key" "{value.json.api_key}"
        WITH BODY "{payload}"
    ADD EVENT Submitlogs
        WITH SOURCE_TOPIC "itsm/new-relic/log/submit"
        WITH DESTINATION_TOPIC "itsm/new-relic/log/submit/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/log/v1"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Api-Key" "{value.json.api_key}"
        WITH BODY "{payload}"
    ADD EVENT Nerdgraphnrql
        WITH SOURCE_TOPIC "itsm/new-relic/nerdgraph/nrql"
        WITH DESTINATION_TOPIC "itsm/new-relic/nerdgraph/nrql/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/graphql"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Api-Key" "{value.json.api_key}"
        WITH BODY "{payload}"
    ADD EVENT Listapplications
        WITH SOURCE_TOPIC "itsm/new-relic/application/list"
        WITH DESTINATION_TOPIC "itsm/new-relic/application/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/v2/applications.json?filter[name]={value.json.filter_name}&page={value.json.page}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Api-Key" "{value.json.api_key}"
```

## Authentication

| Surface | Header | Key type |
| - | - | - |
| Metric / Event / Log | `Api-Key: {value.json.api_key}` | License / ingest key |
| NerdGraph / REST v2 | `Api-Key: {value.json.api_key}` | User API key |

Store keys in Hub secrets (`NEW_RELIC_LICENSE_KEY`, `NEW_RELIC_USER_KEY`) and resolve via `GET SECRET` — never commit credentials.

## MQTT examples

**Metrics** (BASE = Metric API host) — publish a JSON **array** of metric batches as the payload body the connector forwards:

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
[
  {
    "metrics": [
      {
        "name": "coreflux.plant.vibration_rms",
        "type": "gauge",
        "value": 12.4,
        "timestamp": 1728000000000,
        "attributes": {"line": "a", "source": "coreflux"}
      }
    ]
  }
]
```

Include `api_key` in the MQTT JSON envelope if the connector substitutes `{value.json.api_key}` from the same message. Expect **HTTP 202**.

**Events** (BASE = insights-collector) — JSON array of events with required `eventType`. Expect **HTTP 200**.

**NerdGraph NRQL** (BASE = `https://api.newrelic.com`):

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "api_key": "YOUR_USER_KEY",
  "query": "{ actor { account(id: YOUR_ACCOUNT_ID) { nrql(query: \"SELECT count(*) FROM Transaction SINCE 1 hour ago\") { results } } } }"
}
```

## Alert webhook (companion)

Configure a New Relic Alerts [webhook notification](https://docs.newrelic.com/docs/alerts/get-notified/notification-integrations/#webhook) to POST to a Coreflux broker HTTP endpoint. That inbound path belongs in a separate `ENABLE_SERVER` `TYPE REST_API` connector (or MQTT bridge) — not in this client template.

## Live test status

Blocked pending lab credentials. Unauthenticated probes returned Metric **403**, Event **401**, Log **403**, NerdGraph **401** as expected. See package `TEST.md`.

## Official references

* [Metric API](https://docs.newrelic.com/docs/data-apis/ingest-apis/metric-api/report-metrics-metric-api/)
* [Event API](https://docs.newrelic.com/docs/data-apis/ingest-apis/event-api/introduction-event-api/)
* [Log API](https://docs.newrelic.com/docs/logs/log-api/introduction-log-api/)
* [NerdGraph](https://docs.newrelic.com/docs/apis/nerdgraph/get-started/introduction-new-relic-nerdgraph/)
* [REST API v2](https://docs.newrelic.com/docs/apis/rest-api-v2/get-started/introduction-new-relic-rest-api-v2/)
* [Alerts webhook](https://docs.newrelic.com/docs/alerts/get-notified/notification-integrations/#webhook)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.