<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sutrishna Anjoy</title>
    <description>The latest articles on DEV Community by Sutrishna Anjoy (@sutrisnaanjoy19).</description>
    <link>https://dev.to/sutrisnaanjoy19</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1518239%2Fcfff660d-4b29-4c9a-bc6f-5784ec98bf13.png</url>
      <title>DEV Community: Sutrishna Anjoy</title>
      <link>https://dev.to/sutrisnaanjoy19</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sutrisnaanjoy19"/>
    <language>en</language>
    <item>
      <title>Integrating New Relic Alerts with Discord: A Journey from Frustration to Success</title>
      <dc:creator>Sutrishna Anjoy</dc:creator>
      <pubDate>Wed, 26 Mar 2025 11:54:48 +0000</pubDate>
      <link>https://dev.to/sutrisnaanjoy19/integrating-new-relic-alerts-with-discord-a-journey-from-frustration-to-success-5hko</link>
      <guid>https://dev.to/sutrisnaanjoy19/integrating-new-relic-alerts-with-discord-a-journey-from-frustration-to-success-5hko</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Setting up alerts for critical application issues is essential, and tools like New Relic make it easy to monitor application performance. However, New Relic doesn’t offer a direct integration with Discord, which can be frustrating when you want real-time alerts in your Discord channels.&lt;/p&gt;

&lt;p&gt;When I started integrating New Relic Alerts with Discord, I hit multiple roadblocks, from webhook failures to incorrect payload structures. But after several iterations and experiments, I found the best approach that works seamlessly. Here’s a story of my debugging journey and how you can quickly set up New Relic alerts for Discord.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Setting Up New Relic Alerts
&lt;/h4&gt;

&lt;p&gt;Before integrating with Discord, I first needed to create an alert condition in New Relic. Here’s how:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to Alerts &amp;gt; Alert Conditions &amp;gt; Create Alert Condition.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Select Guided Mode.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Choose the APM service and select Error Rate as the metric.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set the window size to 5 minutes and a threshold of 1% error rate in the last 5 minutes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a meaningful name, title, and description.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assign the alert to a default initial policy.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Great! Now I had an alert condition in place. The next challenge? Getting notifications to Discord.&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 2: Trying Webhooks (The Wrong Way 😞)
&lt;/h4&gt;

&lt;p&gt;New Relic provides several notification options, such as Slack, Webhooks, AWS EventBridge, but not Discord.&lt;/p&gt;

&lt;p&gt;I found two promising documents:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://forum.newrelic.com/s/hubtopic/aAX8W0000008aA7WAI/how-to-setup-notification-channel-by-discord" rel="noopener noreferrer"&gt;New Relic Forum - Discord Webhook Setup&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.microideation.com/2022/04/30/new-relic-alerts-integration-to-discord/" rel="noopener noreferrer"&gt;Microideation Blog on New Relic Alerts to Discord&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both documents suggested a workaround: use a Slack-compatible webhook by modifying the Discord Webhook URL like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;YOUR_DISCORD_WEBHOOK_URL&amp;gt;/slack
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I was hopeful, but when I tried setting up Slack in New Relic, it only showed a login page for Slack authentication. 😤&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3otwligjs0q5q5ohcoma.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3otwligjs0q5q5ohcoma.png" alt="Finally alert in channel" width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No option to manually enter the webhook!&lt;/p&gt;

&lt;p&gt;I even tried using New Relic CLI, but it didn’t work either.&lt;/p&gt;

&lt;p&gt;Clearly, the Slack method was a dead end. Time for Plan B. 🚀&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 3: Using AWS EventBridge + Lambda (The Long Way 😅)
&lt;/h4&gt;

&lt;p&gt;Since the webhook approach was failing, I thought of another workaround:✔️ Use AWS EventBridge to catch New Relic alert events. ✔️ Send these events to an AWS Lambda function. ✔️ Convert the payload to a Discord-compatible format and send the alert.&lt;/p&gt;

&lt;h5&gt;
  
  
  Setting Up EventBridge
&lt;/h5&gt;

&lt;h6&gt;
  
  
  Create an EventBridge Partner Event Bus using New Relic:
&lt;/h6&gt;

&lt;p&gt;aws.partner/newrelic.com/&amp;lt;NEWRELIC_ACC_ID&amp;gt;/acc&lt;/p&gt;

&lt;h6&gt;
  
  
  Create an event rule:
&lt;/h6&gt;

&lt;p&gt;Name: newrelic_alerts_to_discord&lt;/p&gt;

&lt;p&gt;Event Pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "source": [{
    "prefix": "aws.partner/newrelic.com"
  }]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Target: AWS Lambda Function&lt;/p&gt;

&lt;h5&gt;
  
  
  Lambda Function to Send Alerts to Discord
&lt;/h5&gt;

&lt;p&gt;Here’s the Python Lambda function I wrote:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json
import requests
import os
DISCORD_WEBHOOK_URL = os.getenv("DISCORD_WEBHOOK_URL")  # Set in Lambda environment variables
def lambda_handler(event, context):
    try:
        print("Received Event:", json.dumps(event, indent=2))
        event_detail = event.get("detail", {})
        # Extract fields
        alert_condition = ", ".join(event_detail.get("alertConditionNames", ["N/A"]))
        alert_description = ", ".join(event_detail.get("alertConditionDescriptions", ["N/A"]))
        impacted_entities = ", ".join(event_detail.get("impactedEntities", ["N/A"]))
        state = event_detail.get("state", "N/A")
        created_at = event_detail.get("createdAt", "N/A")
        # Format message for Discord
        discord_payload = {
            "content": "🚨 **New Relic Alert** 🚨",
            "embeds": [
                {
                    "title": alert_condition,
                    "description": (
                        f"**Condition Description:** {alert_description}\n"
                        f"**Impacted Entities:** {impacted_entities}\n"
                        f"**State:** {state}\n"
                        f"**Created At:** {created_at}"
                    ),
                    "color": 15158332
                }
            ]
        }
        response = requests.post(DISCORD_WEBHOOK_URL, json=discord_payload)
        if response.status_code == 204:
            return {"status": "Success"}
        else:
            return {"status": "Failed", "error": response.text}
    except Exception as e:
        return {"status": "Error", "message": str(e)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It worked! 🎉 But, let’s be real – this was too complex for a simple webhook notification.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ifaivykf9zx8gl5z5kl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ifaivykf9zx8gl5z5kl.png" alt="Finally alert in channel" width="800" height="147"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 4: The Best Approach – Using Webhooks the Right Way ✅
&lt;/h4&gt;

&lt;p&gt;For Discord Webhooks to work, the JSON payload must include content or embeds. Without these keywords, Discord will reject the payload!&lt;/p&gt;

&lt;p&gt;Final JSON Payload for Discord Webhook&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "content": "🚨 **New Relic Alert** 🚨",
  "embeds": [
    {
      "title": "{{ accumulations.conditionName.[0] }}",
      "description": "**Condition Description:** {{#each accumulations.conditionDescription}}{{#unless @first}}, {{/unless}}{{escape this}}{{/each}}\n**Impacted Entities:** {{#each entitiesData.names}}{{#unless @first}}, {{/unless}}{{this}}{{/each}}\n**State:** {{state}}\n",
      "color": 15158332,
      "footer": {
        "text": "{{timezone createdAt 'Asia/Kolkata'}}"
      }
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why This Works?&lt;/p&gt;

&lt;p&gt;✔️ Uses Handlebars syntax to format the payload correctly. ✔️ Includes the required content field, making Discord accept the message. ✔️ No need for EventBridge or Lambda – pure webhook solution! ✔️ Works seamlessly with New Relic webhook notifications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fephceu5igubp5q6q5pgn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fephceu5igubp5q6q5pgn.png" alt="Finally alert in channel" width="800" height="147"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  Conclusion
&lt;/h4&gt;

&lt;p&gt;💡 Lesson Learned: Always check the webhook payload format before building unnecessary workarounds! 😅&lt;/p&gt;

&lt;p&gt;By correctly structuring the JSON using Handlebars syntax and ensuring the presence of content or embeds, I was able to directly send New Relic alerts to Discord without using AWS services.&lt;/p&gt;

&lt;p&gt;🚀 If you’re setting up New Relic to Discord alerts, follow Solution 2 – it’s simple, efficient, and works perfectly!&lt;/p&gt;

</description>
      <category>newrelic</category>
      <category>discord</category>
      <category>aws</category>
      <category>devops</category>
    </item>
    <item>
      <title>Virtualization - The Basics</title>
      <dc:creator>Sutrishna Anjoy</dc:creator>
      <pubDate>Mon, 01 Jul 2024 14:45:56 +0000</pubDate>
      <link>https://dev.to/sutrisnaanjoy19/virtualization-the-basics-462e</link>
      <guid>https://dev.to/sutrisnaanjoy19/virtualization-the-basics-462e</guid>
      <description>&lt;p&gt;&lt;strong&gt;Virtualization&lt;/strong&gt; in computing means creating a virtual version of something instead of a physical one. This includes virtual versions of computer hardware, storage devices, and network resources.&lt;br&gt;
In this post, I will focus on discussing virtual machines on bare metal or a host machine, specifically in terms of Linux.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtual Machine&lt;/strong&gt;: A VM is a software version of a physical computer. It allows you to run an operating system and applications just like on a real computer, but it works within another computer (the host), sharing its resources like CPU, memory, and storage. In fact, each VM believes it is the only system running on the hardware.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hypervisor&lt;/strong&gt;: A hypervisor is software that lets you run multiple VMs on one physical computer. It manages the computer's resources and makes sure each VM operates independently.&lt;/p&gt;

&lt;p&gt;Type-1: A Type-1 hypervisor, also known as a bare-metal hypervisors, are installed directly onto the physical hardware without needing a separate operating system. It manages the VMs directly, providing them with access to the hardware resources.&lt;br&gt;
Examples include KVM (Kernel-based Virtual Machine), Proxmox, VMware ESXi, Microsoft Hyper-V Server and Citrix Hypervisor (formerly XenServer).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdhinq4zyy43fmjrye76n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdhinq4zyy43fmjrye76n.png" alt="Image description" width="696" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Type-2: A Type-2 hypervisor is like a software application that you install on your computer's operating system (like Windows, macOS, or Linux). It creates VMs that can run different operating systems alongside your main operating system. &lt;br&gt;
Examples include VirtualBox, VMware Workstation, and QEMU.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgsp8jqjlk3yx28wvqtl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgsp8jqjlk3yx28wvqtl.png" alt="Image description" width="696" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Different virtualization techniques used in VMs are as follows:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fully Virtualized&lt;/strong&gt;: When a guest OS running in a VM attempts to access hardware (like CPU, memory, or network), it interacts with virtual hardware interfaces provided by the hypervisor. The hypervisor translates these hardware calls into commands that the physical hardware can execute. This process involves emulating the actual hardware interfaces and translating the commands to ensure they are compatible with the host hardware. The guest OS are unaware that they are running on virtualized hardware.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo48l2zc5ueyxftbuh42j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo48l2zc5ueyxftbuh42j.png" alt="Image description" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Paravirtualization&lt;/strong&gt;: In paravirtualization, the guest OS is modified to replace certain privileged instructions with hypercalls, which are calls directly to the hypervisor. Hypercalls are specific function calls that the guest OS uses to request services from the hypervisor, such as memory management, I/O operations, or scheduling. It reduced overhead and improve efficiency compared to traditional fully virtualized approaches.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj9t2r6bthyabtcy2lr34.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj9t2r6bthyabtcy2lr34.png" alt="Image description" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Emulation&lt;/strong&gt;: When a guest software running on an emulated environment makes a hardware call, such as accessing memory or processing data, the emulated software (QEMU) translates these calls into instructions that the host system can understand and execute.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjq53aqsee7zk0vfeyxwp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjq53aqsee7zk0vfeyxwp.png" alt="Image description" width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shared Hardware Virtualization&lt;/strong&gt;: Suppose a VM running a high-performance application requires direct access to a specialized GPU for computational tasks. The hypervisor identifies the GPU and assigns it to the VM using pass-through. When the VM makes hardware calls related to GPU operations those calls are handled directly by the GPU without involving the hypervisor's virtualization layer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fom3a6m2ctm5au3pprrgv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fom3a6m2ctm5au3pprrgv.png" alt="Image description" width="800" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;: virtualization improves efficiency by maximizing hardware use(overcommiting). This optimizes hardware use, reduces costs, enhances security by isolating each VM, and makes IT systems more flexible and easier to manage. It also speeds up deploying new software and recovering from failures.&lt;/p&gt;

</description>
      <category>virtualmachine</category>
      <category>linux</category>
      <category>sre</category>
      <category>virtualization</category>
    </item>
  </channel>
</rss>
