---
title: "Setting up New Relic deployment markers"
date: "2022-03-14T21:18:57+00:00"
summary:
image:
type: "article"
url: "/acquia-cloud-platform/help/92241-setting-new-relic-deployment-markers"
id: "3cf954d1-472c-4893-a93c-1589d75306ee"
---

New Relic's monitoring tool offers [deployment markers](https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/record-monitor-deployments/), a feature to accept a POST request to mark the deployment of code.

Below are the steps required to enable automated deployment markers using Acquia Cloud Hooks and New Relic's API. Note that these all happen in your repository and need to be pushed to Acquia Cloud.

1.  Create `hooks/prod/post-code-deploy/newrelic.sh` file with the following contents (see [https://github.com/acquia/cloud-hooks/blob/master/samples/newrelic/newrelic.sh](https://github.com/acquia/cloud-hooks/blob/master/samples/newrelic/newrelic.sh) ):
    
        #!/bin/sh
        #
        # This sample a Cloud Hook script to update New Relic whenever there is a new code deployment 
        
        site=$1         # The site name. This is the same as the Acquia Cloud username for the site.
        targetenv=$2    # The environment to which code was just deployed.
        sourcebranch=$3 # The code branch or tag being deployed.  
        deployedtag=$4  # The code branch or tag being deployed. 
        repourl=$5      # The URL of your code repository.
        repotype=$6     # The version control system your site is using; "git" or "svn".
        
        #Load the New Relic APPID and APPKEY variables.
        . $HOME/newrelic_settings
        
        #https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/recording-deployments#post-deployment
        curl -X POST "https://api.newrelic.com/v2/applications/$APPID/deployments.json" \
             -H "X-Api-Key:$APIKEY" -i \
             -H "Content-Type: application/json" \
             -d \
        "{
          \"deployment\": {
            \"revision\": \"$deployedtag\",
            \"changelog\": \"$deployedtag deployed to $site.$targetenv\",
            \"description\": \"$deployedtag deployed to $site.$targetenv\",
            \"user\": \"$username\"
          }
        }"
    
2.  Create `hooks/prod/post-code-deploy/newrelic_settings` with the following contents:   
    (see [https://github.com/acquia/cloud-hooks/blob/master/samples/newrelic/newrelic\_settings](https://github.com/acquia/cloud-hooks/blob/master/samples/newrelic/newrelic_settings))
    
        APIKEY='123456abcdefgh1234567890abcdefgh1234567890a bc1234567890'
        APPID='123456'
        username='myname@mydomain.com'
    
3.  Replace `application_id` and `x-api-key` with the values from New Relic. From the instructions at [https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/) get your application\_id and your x-api-key. Store these variables and a username you wish to send to New Relic in `$HOME/newrelic_settings` file.
    
4.  Make newrelic\_settings executable   
    run `chmod a+x hooks/prod/post-code-deploy/newrelic.sh`
    

For more information on Acquia Cloud Hooks, see [https://docs.acquia.com/cloud-platform/develop/api/cloud-hooks/](/node/56168)

Let us know if you get stuck on any of those points by [getting in touch with Support](/node/55873).