New Relic Deployment Marker

Updated 1 month ago by Michael Cretzman

You can use the New Relic REST API v2 to record Harness deployments and then view them in the New Relic APM Deployments page and in the Event log list on the Overview page. For more information, see REST API Procedures from New Relic.

For example, here is a cURL command that sends a POST to the API to record a deployment:

curl -X POST 'https://api.newrelic.com/v2/applications/${APP_ID}/deployments.json' \
-H 'X-Api-Key:${APIKEY}' -i \
-H 'Content-Type: application/json' \
-d \
'{
"deployment": {
"revision": "REVISION",
"changelog": "Added: /v2/deployments.rb, Removed: None",
"description": "Added a deployments resource to the v2 API",
"user": "datanerd@example.com"
}
}'

In a Harness Workflow, you can add a New Relic Deployment Marker to perform the POST as part of your Workflow:

The API key parameter is provided by the New Relic Server you select, using the credentials you provided when you set up the New Relic Verification Provider in Harness. You can also enter variable expressions, such as: ${serviceVariable.new_relic_connector_name} .

If the New Relic Server field contains an expression, the Application Name field must also use an expression.

The App ID parameter is provided by the Application Name you select. The list of applications is pulled from the New Relic Server you selected. You can also enter variable expressions, such as: ${app.name}.

The Body section contains the standard JSON content as in the cURL example:

{
"deployment": {
"revision": "${artifact.buildNo}",
"description": "Harness Deployment via workflow ${workflow.name}",
"user": "${workflow.name}"
}
}

Harness uses some built-in variables to provide the revision information and other settings.

Now when the Workflow is deployed you will see the Deployment Marker vertical line in New Relic:

YAML Example

Here's an example YAML schema that you can use for New Relic Deployment Marker.

- type: NEW_RELIC_DEPLOYMENT_MARKER
name: New Relic Deployment Marker
properties:
analysisServerConfigId: 1crZaE-DQrKE_YFmH97CSg
applicationId: "${service.name}"
body: |-
{
"deployment": {
"revision": "${artifact.buildNo}",
"description": "Harness Deployment via workflow ${workflow.name}",
"user": "${workflow.name}"
}
}
templateUuid: null
templateVariables: null
templateVersion: null

For applicationId, you can use a Harness built-in variable expression such as ${service.name} or a Workflow or Service variable.

For more information about variables and expressions, see the following topics:

Next Step


How did we do?