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

# Push run results to New Relic

> Send test results to New Relic as custom events for dashboards, NRQL queries, and alerting.

The `newrelic` reporter pushes run results to the
[New Relic Event API](https://docs.newrelic.com/docs/data-apis/ingest-apis/event-api/introduction-event-api/).
Each test run is sent as a `MomenticRun` custom event and each run group as a
`MomenticRunGroup` summary event, which can be queried with NRQL.

## 1. Configure the reporter

Add a `reporting.newrelic` block to `momentic.config.yaml`:

```yaml momentic.config.yaml theme={null}
name: my-project

reporting:
  newrelic:
    region: US # or EU, selects the ingest endpoint
    accountId: "1234567"
    licenseKey: ${NEW_RELIC_LICENSE_KEY}
    attributes: # optional static tags added to every event
      service: checkout
      team: payments
```

* `region` defaults to `US`. Use `EU` for accounts in New Relic's EU data
  center.
* `licenseKey` is optional. If omitted, the reporter reads the
  `NEW_RELIC_LICENSE_KEY` environment variable. Use an
  [ingest license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#license-key).
* `attributes` adds static tags (e.g. `service`, `team`) to every event, useful
  when multiple projects report into the same account.
* `accountId`, `licenseKey`, and `attributes` values all support `${ENV_VAR}`
  interpolation.

## 2. Run with the New Relic reporter

Pass `--reporter newrelic` to
[`momentic run`](/cli-reference/momentic/commands/run):

```bash theme={null}
npx momentic run --reporter newrelic
```

Pass `--reporter` multiple times to combine reporters:

```bash theme={null}
npx momentic run --reporter newrelic --reporter junit --reporter-dir reports
```

## 3. Event reference

`MomenticRun` is sent once per executed test:

| Attribute                                 | Description                                                 |
| ----------------------------------------- | ----------------------------------------------------------- |
| `runId`, `runGroupId`                     | Momentic run and run group identifiers                      |
| `testId`, `testName`, `filePath`          | Test identity                                               |
| `status`                                  | `PASSED`, `FAILED`, or `CANCELLED`                          |
| `startedAt`, `finishedAt`, `durationMs`   | Timing                                                      |
| `attempts`, `quarantined`, `recovered`    | Retry and quarantine state                                  |
| `labels`                                  | Comma-separated test labels                                 |
| `environment`, `baseUrl`                  | Environment the test ran against                            |
| `failureReason`, `failureMessage`         | Failure details (failed runs only)                          |
| `classificationCategory`                  | AI failure classification category                          |
| `classificationReasoning`                 | AI failure classification explanation                       |
| `runUrl`                                  | Link to the run in the Momentic dashboard                   |
| `gitBranch`, `gitCommit`, `gitRepository` | Git metadata                                                |
| `ciRunUrl`                                | CI build link (GitHub Actions, GitLab, Buildkite, CircleCI) |

`MomenticRunGroup` is sent once per run as a summary:

| Attribute                                                                                   | Description                 |
| ------------------------------------------------------------------------------------------- | --------------------------- |
| `runGroupId`, `runGroupUrl`                                                                 | Run group identity and link |
| `total`, `executed`, `skipped`, `passed`, `failed`, `cancelled`, `quarantined`, `recovered` | Result counts               |
| `passRate`                                                                                  | `passed / executed`         |
| `startedAt`, `finishedAt`, `durationMs`                                                     | Timing                      |
| `environment`, `suiteName`, git and CI attributes                                           | Shared context              |

Custom `attributes` from the config are added to both event types.

## 4. Query in New Relic

Pass rate per test over the last day:

```sql theme={null}
SELECT
  percentage (
    count(*),
    WHERE
      status = 'PASSED'
  )
FROM
  MomenticRun FACET testName SINCE 1 day ago
```

Alert on run group pass rate:

```sql theme={null}
SELECT
  latest (passRate)
FROM
  MomenticRunGroup
WHERE
  environment = 'production'
```
