Skip to content

Instantly share code, notes, and snippets.

@hydrosquall
Last active March 25, 2024 14:30
Show Gist options
  • Save hydrosquall/e9d264e7a4afc0ecafa0aa6c361a3e7a to your computer and use it in GitHub Desktop.
Save hydrosquall/e9d264e7a4afc0ecafa0aa6c361a3e7a to your computer and use it in GitHub Desktop.
Webhook Payload: Datadog Graphs -> Discord Bot
{
"embeds":[
{
"title":"$EVENT_TITLE",
"url":"$LINK",
"description":"$EVENT_MSG",
"thumbnail":{
"url":"$SNAPSHOT"
}
},
{
"fields":[
{
"name":"tags",
"value":"$TAGS",
"inline":true
}
]
}
]
}
@timetinytim
Copy link

Chiming in here as I'm encountering similar issues.

While investigating, I found out that discord's support of markdown is somewhat limited, and doesn't include images. The $EVENT_MSG and $INCIDENT_MSG vars in datadog both include an image markdown link, but since discord doesn't support it, it will instead always display that ugly [![Metric Graph](https://...)

Additionally after doing some additional testing, I confirmed that sometimes the thumbnail image won't display because $SNAPSHOT URL will point to an image that hasn't been generated yet. The solution would be to wait a little bit before displaying the message, but I don't think there's a way to do that with discord (I'm considering creating a simple app that waits/processes the message before it reaches discord to fix the issue...).

For now, I'm using this setup, which is admittedly less "complete", but is concise & clear at a glance, even without the image. Somehow in my testing the image seems to render much more often, though I could have just been lucky:

{
   "avatar_url": "https://cdn-1.webcatalog.io/catalog/datadog/datadog-icon.png",
   "embeds": [
      {
         "title": "$ALERT_TITLE",
         "color": 6499494,
         "url": "$LINK",
         "description": "### $EVENT_TITLE\n$ALERT_STATUS",
         "image": {
            "url": "$SNAPSHOT"
         }
      },
      {
         "fields": [
            {
               "name": "tags",
               "value": "$TAGS",
               "inline": true
            }
         ]
      }
   ]
}

@Prisoner2-6-7
Copy link

Chiming in here as I'm encountering similar issues.

While investigating, I found out that discord's support of markdown is somewhat limited, and doesn't include images. The $EVENT_MSG and $INCIDENT_MSG vars in datadog both include an image markdown link, but since discord doesn't support it, it will instead always display that ugly [![Metric Graph](https://...)

Additionally after doing some additional testing, I confirmed that sometimes the thumbnail image won't display because $SNAPSHOT URL will point to an image that hasn't been generated yet. The solution would be to wait a little bit before displaying the message, but I don't think there's a way to do that with discord (I'm considering creating a simple app that waits/processes the message before it reaches discord to fix the issue...).

For now, I'm using this setup, which is admittedly less "complete", but is concise & clear at a glance, even without the image. Somehow in my testing the image seems to render much more often, though I could have just been lucky:

{
   "avatar_url": "https://cdn-1.webcatalog.io/catalog/datadog/datadog-icon.png",
   "embeds": [
      {
         "title": "$ALERT_TITLE",
         "color": 6499494,
         "url": "$LINK",
         "description": "### $EVENT_TITLE\n$ALERT_STATUS",
         "image": {
            "url": "$SNAPSHOT"
         }
      },
      {
         "fields": [
            {
               "name": "tags",
               "value": "$TAGS",
               "inline": true
            }
         ]
      }
   ]
}

image

the avatar is nice but i still dont see graph image.

@timetinytim
Copy link

Yeah it's a dice roll whether Datadog creates the image in time before discord receives & shows the post. I don't think there's a way around that at the moment.

I really do need to create middleman app to fix this.

@hydrosquall
Copy link
Author

hydrosquall commented Mar 25, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment