A Node.js application that nukes (deletes) all alert policies and alert destinations from a New Relic account.
This tool will permanently delete all alert policies and alert destinations in your New Relic account. Use with extreme caution!
- 🚀 Deletes all alert policies
- 🎯 Deletes all alert destinations
- 🔍 Dry run mode for safe testing
- 📊 Detailed logging and progress tracking
- 🛡️ Error handling and validation
- 🌍 Supports both US and EU regions
- Node.js 18 or higher
- New Relic API key with appropriate permissions
- New Relic account ID
-
Clone this repository:
git clone https://github.com/yourusername/nuke-newrelic.git cd nuke-newrelic -
Install dependencies:
npm install
-
Copy the example environment file:
cp .env.example .env
-
Edit
.envwith your New Relic credentials:NEW_RELIC_API_KEY=your_api_key_here NEW_RELIC_ACCOUNT_ID=your_account_id_here NEW_RELIC_REGION=US # or EU DRY_RUN=false # Set to true for safe testing
- Go to New Relic API Keys
- Create a new API key with the following permissions:
AlertsReadAlertsWriteAlertsPolicyDeleteAlertsDestinationDelete
- Go to your New Relic account
- Click on your account name in the top right
- The Account ID is displayed in the dropdown
Test the tool without actually deleting anything:
# Set DRY_RUN=true in your .env file, then:
npm start# Set DRY_RUN=false in your .env file, then:
npm startRun with auto-restart on file changes:
npm run dev- All alert policies in the account
- Includes policies with any incident preference setting
- Policies are deleted regardless of their current state
- All alert destinations in the account
- Includes email, Slack, webhook, and other destination types
- Destinations are deleted regardless of their current usage
The tool provides detailed logging including:
- Number of resources found
- Progress for each deletion
- Success/failure status for each operation
- Final summary with totals
Example output:
💥 NEW RELIC NUKER 💥
====================
🔍 DRY RUN MODE - No actual deletions will occur
Account ID: 123456
Region: US
🚀 Starting to nuke alert policies...
Found 5 alert policies
Deleting policy: Critical Alerts (ID: 123)
✅ [DRY RUN] Would delete: Critical Alerts
...
📊 Alert Policies Summary:
Deleted: 5
Failed: 0
Total: 5
🎉 NUKING COMPLETE! 🎉
=====================
Alert Policies - Deleted: 5, Failed: 0
Alert Destinations - Deleted: 3, Failed: 0
Total Resources - Deleted: 8, Failed: 0
The tool includes comprehensive error handling:
- Validates required environment variables
- Handles API rate limits and timeouts
- Continues processing even if individual deletions fail
- Provides detailed error messages
- Exits with appropriate status codes
- Never commit your
.envfile to version control - Use API keys with minimal required permissions
- Consider using dry run mode first to verify behavior
- Keep backups of important alert configurations
-
"NEW_RELIC_API_KEY and NEW_RELIC_ACCOUNT_ID are required"
- Ensure your
.envfile exists and contains the required variables
- Ensure your
-
"GraphQL errors: [object Object]"
- Check that your API key has the required permissions
- Verify your account ID is correct
-
"Failed to delete" errors
- Some resources may be protected or in use
- Check the New Relic UI for any restrictions
If you encounter issues:
- Check the error messages in the console output
- Verify your API key permissions
- Test with dry run mode first
- Check the New Relic documentation for API limitations
MIT License - Use at your own risk!