My Profile Photo

Ashley Poole

- Speaker -
- Senior Software Developer -
- Co-organiser of @ShropshireDevs -
- Site Reliability Engineering Advocate -

New Relic APM Spring Clean

Having a spring clean of New Relic APM might be a little tedious but luckily New Relic provide a feature rich API which makes this job a breeze.

Below is an Powershell script that will loop through all the non-reporting applications from your New Relic account based on the API key, and issue a delete request to their API for each of those applications.


$appResponse = Invoke-RestMethod -Uri "" -Method Get -Headers @{'X-Api-Key'="$apiKey"}

$nonReportingApps = $AppResponse.applications | Where-Object {$_.reporting -eq $false}

Write-Host "Found $($nonReportingApps.Count) non reporting applications in New Relic"

foreach ($nonReportingApp in $nonReportingApps)
    Write-Host "Deleting New Relic application with Id $($ ($($"

    try {
        Invoke-RestMethod -Uri "$($" -Method Delete -Headers @{'X-Api-Key'="$apiKey"} | Out-Null
    } catch {
        Write-Error "Failed to delete application, status code $($_.Exception.Response.StatusCode.value__)"

Enjoy your New Relic spring clean!

Posted on devops with tags: newrelic

comments powered by Disqus