> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-continuous-delivery/verify-deployments/configure-cv/configure-verify-step-with-ai/health-sources/create-a-new-relic-metrics-health-source.md).

# Create a New Relic Metrics health source for AI Verify

Connect New Relic to AI Verify (v2) to collect and analyze metrics during deployments using manual NRQL queries.

AI Verify (v2) supports a New Relic Metrics health source type that lets you connect a New Relic connector to your deployment pipeline and analyze metrics during deployment verification. New Relic currently supports the **Metrics** feature only; a native Logs health source for New Relic is not yet available. You configure a New Relic Metrics health source using **Manual Setup**, where you write the NRQL query yourself and map the fields the AI analysis engine needs.

## What you will learn from this topic

* **Create a New Relic Metrics health source:** How to [configure a New Relic Metrics health source](#create-a-new-relic-metrics-health-source), including the NRQL query rules and the field mapping the AI analysis engine needs.
* **Add multiple queries:** How to [add more than one query](#add-multiple-queries) to a single health source.
* **Use the health source in a pipeline:** How to [reference the health source in an AI Verify (v2) step](#use-the-health-source-in-an-ai-verify-pipeline).
* **View analysis results:** How to [read the verification verdict](#view-analysis-results) after a pipeline run.

***

## Before you begin

* **New Relic connector:** You need a New Relic connector configured with access to the New Relic account you want to query. Go to [Connect to monitoring and logging systems](https://developer.harness.io/harness-platform/use-harness-platform/connectors/monitoring-and-logging-systems/connect-to-monitoring-and-logging-systems) to create one.
* **AI Verify step:** The health source must be referenced in an AI Verify (v2) step inside a Container Step Group. Go to [Configure the AI Verify (v2) step](/continuous-delivery/use-continuous-delivery/verify-deployments/configure-cv/configure-verify-step-with-ai/ai-verify.md) to set it up.

***

## Create a New Relic Metrics health source

Navigate to **Account/Org/Project Settings**, then select **Health Sources** from the left navigation. Click **+ New Health Source** to open the configuration wizard.

{% stepper %}
{% step %}
**Configure the overview**

On the **Overview** tab, provide the basic health source details.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-746f67e0fd2ad9e1aa796f4a1384ab6e8e35bda4%2Fnew-relic-metrics-health-source-overview.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

1. Enter a **Health Source Name**, for example, `newrelic-prod-metrics`.
2. In **Select health source type**, select the **New Relic** tile.
3. In **Select Connector**, choose the New Relic connector that points to your New Relic account.
4. In **Select Feature**, the dropdown shows **Metrics** as the only option. A native Logs health source is not yet supported for New Relic.
5. Under **Setup Approach**, select **Manual Setup**. AI-assisted setup is not currently available for New Relic Metrics health sources.
6. Click **Continue**.
   {% endstep %}

{% step %}
**Define the query specification**

The **Query Specifications** tab is where you configure the NRQL query that fetches metrics from New Relic. Each health source can have one or more named queries.

The left panel lists your queries. Click **+ Add Query** to add additional queries. Select a query in the list to edit its settings in the right panel.

**Query Name and identifier**

Enter a human-readable **Query Name**, for example, `Checkout Service Latency`. Harness derives the query identifier automatically. The identifier must be unique within the health source.

**New Relic Group Name**

Enter a **New Relic Group Name** for the query, or select an existing group to add this query to it. The group name is required and is used to organize related queries in the analysis results.

**NRQL query**

Enter an NRQL query that returns a metric time series, for example a `SELECT average(...) FROM Metric TIMESERIES` query. If your query includes a `TIMESERIES` clause but no `FACET` clause, Harness automatically adds `FACET host` to the query before running it, so the plugin can distinguish metric values per host. If your query already has its own `FACET` clause, Harness leaves it unchanged.

Click **Run Query** to execute the query against your New Relic connector. Harness displays the returned response in the **Records** section.
{% endstep %}

{% step %}
**Map metric fields**

After the query returns a record, map the fields the AI analysis engine needs. Each field takes an absolute path from the root of the record, written in bracket notation: object keys in single quotes and array positions as numbers, with segments joined by dots. For example, `['results'].[0].['average']`.

| Field                                 | Required | Description                                                                                                                          |
| ------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| **Metric Value JSON Path**            | Yes      | Path to the numeric metric value in the response                                                                                     |
| **Timestamp Field/Locator JSON Path** | Yes      | Path to the timestamp for each metric value                                                                                          |
| **Service Instance Identifier**       | Yes      | Path to the field that identifies which host or service instance the metric value belongs to, typically the faceted `host` attribute |

To select a path interactively, click the **+** icon next to a field. A path picker opens, showing the parsed record returned by **Run Query**. Click any value in the tree to fill in its path. You can also type the path directly, but it must use the bracket notation shown above.

Click **Build Chart** to preview the metric as a time series chart using the mapped **Metric Value JSON Path** and **Timestamp Field/Locator JSON Path**. This step is optional but lets you confirm the field mapping is correct before saving.
{% endstep %}

{% step %}
**Save the health source**

Click **Save** to create the health source. The health source appears on the **Health Sources** listing page with a **Metric** signal-type badge and **New Relic** as the type.

The health source is now ready to reference in an AI Verify (v2) step.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
New Relic Metrics health sources always aggregate query results using the `AVG` aggregation type. There is no option to select a different aggregation.
{% endhint %}

***

## Add multiple queries

New Relic Metrics health sources support multiple queries within a single health source. You might add multiple queries to cover different metrics from the same New Relic connector, for example, one query for latency and another for error rate. Use the **New Relic Group Name** field to organize related queries into the same group in the analysis results.

In the **Query Specifications** tab, click **+ Add Query** to add a new query entry in the left panel. Each query has its own name, group, NRQL query, and field mapping. All queries in the health source run as part of the same AI Verify step execution.

***

## Use the health source in an AI Verify pipeline

Reference the New Relic Metrics health source by its identifier in the `AIVerifyNG` step. During execution, the step first fetches baseline metrics using the saved NRQL query, then fetches post-deployment (canary) metrics during the deployment window, and submits both sets to the AI analysis engine for comparison.

<details>

<summary>Kubernetes rolling deployment with New Relic Metrics health source: full YAML</summary>

```yaml
pipeline:
  name: New Relic Metrics E2E
  identifier: New_Relic_Metrics_E2E
  projectIdentifier: your_project
  orgIdentifier: default
  stages:
    - stage:
        name: test-stage
        identifier: teststage
        type: Deployment
        spec:
          deploymentType: Kubernetes
          service:
            serviceRef: your_service
          environment:
            environmentRef: your_environment
            deployToAll: false
            infrastructureDefinitions:
              - identifier: your_k8s_infrastructure
          execution:
            steps:
              - step:
                  name: Rollout Deployment
                  identifier: rolloutDeployment
                  type: K8sRollingDeploy
                  timeout: 10m
                  spec:
                    skipDryRun: false
                    pruningEnabled: false
              - stepGroup:
                  name: AI Verify
                  identifier: aiVerifyGroup
                  steps:
                    - step:
                        type: AIVerifyNG
                        name: AIVerifyV2_1
                        identifier: AIVerifyV2_1
                        spec:
                          dataCollectionWindow: 2m
                          healthSources:
                            - healthSourceRef: newrelicprodmetricsHS
                          resources:
                            limits:
                              cpu: 250m
                              memory: 256Mi
                        timeout: 10m
                  stepGroupInfra:
                    type: KubernetesDirect
                    spec:
                      connectorRef: your_k8s_connector
                      namespace: default
            rollbackSteps:
              - step:
                  name: Rollback Rollout Deployment
                  identifier: rollbackRolloutDeployment
                  type: K8sRollingRollback
                  timeout: 10m
                  spec:
                    pruningEnabled: false
        failureStrategies:
          - onFailure:
              errors:
                - AllErrors
              action:
                type: StageRollback
```

</details>

***

## View analysis results

After the pipeline runs, click the AI Verify step in the execution view. The **Analysis** tab shows a result for the New Relic Metrics health source. Click the health source entry to see its **Query Summaries** section, which lists each query with a **healthy** or **unhealthy** badge.

When a query is marked unhealthy, the analysis displays a summary of the detected anomalous metric patterns and a root cause hypothesis. This output is generated by the AI analysis engine, which compares the baseline metric window against the post-deployment metric window.

The **Logs** tab in the execution view shows the raw plugin output, including the baseline metric fetch, the canary (post-deployment) metric fetch, and the call to the AI Verify agent that produces the health summary.

***

## Next steps

* [Configure the AI Verify (v2) step](/continuous-delivery/use-continuous-delivery/verify-deployments/configure-cv/configure-verify-step-with-ai/ai-verify.md): Add it to your pipeline and reference this health source.
* [AI Verify (v2) overview](/continuous-delivery/use-continuous-delivery/verify-deployments/configure-cv/configure-verify-step-with-ai/overview.md): Understand how the AI analysis engine compares baseline and post-deployment data to produce a verdict.
* [Interpret metric results](/continuous-delivery/use-continuous-delivery/verify-deployments/cv-results/interpret-metric-results.md): Read and act on the metric analysis results from verification runs.

{% @harness-feedback/feedback %}
