Skip to content

Automated script that listens for alerts from New Relic APM, fetches recent error traces for impacted services, and sends them via email in a CSV report format.

License

Notifications You must be signed in to change notification settings

pkdeva/NewRelic-APM-Error-Handler-Automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

New Relic APM Error Alert Handler

This repository contains an automated script that listens for alerts from New Relic APM, fetches recent error traces for impacted services, and sends them via email in a CSV report format.

Features

  • Listens to New Relic webhook alert payloads (ideal for AWS Lambda or Flask app).
  • Fetches recent errors (last 60 minutes) for selected applications using New Relic's GraphQL API.
  • Generates a detailed CSV report of error traces.
  • Sends the report via email using Gmail SMTP.
  • Cleans and formats data before sending.

Requirements

  • Python 3.8+
  • Gmail SMTP credentials
  • New Relic API key and Account ID
  • Pre-configured environment variables

Environment Variables

Variable Description
NEWRELIC_API_KEY New Relic User API Key
NEWRELIC_ACCOUNT_ID Your New Relic Account ID
GMAIL_USER Gmail address to send emails from
GMAIL_PASSWORD Gmail App Password (not your account password)
RECEIVER_EMAILS Comma-separated list of recipient emails
RECEIVER_CC (Optional) CC email address

Flow Diagram

flowchart TD
    A[New Relic<br>Alert Triggered] --> B[Webhook Payload<br>Received]
    B --> C[Check if alert<br>is ACTIVATED]
    C -- No --> Z[Ignore and exit]
    C -- Yes --> D[Parse impactedEntities]
    D --> E[Call New Relic<br>GraphQL API]
    E --> F[Fetch recent<br>ErrorTrace events]
    F --> G[Generate CSV<br>from error data]
    G --> H[Send email via<br>SMTP with attachment]
    H --> I[Log success<br>or failure]
Loading

About

Automated script that listens for alerts from New Relic APM, fetches recent error traces for impacted services, and sends them via email in a CSV report format.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages