Ashley Poole Profile Photo

Ashley Poole

- Engineering Leadership -
- Engineering Management -
- Product & Platform Engineering -
- Site Reliability Engineering Advocate -
- Speaker -

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 a 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 the 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!