Question

How to modify Slack deployment alerts on App Platform

I have integrated my deployments alerts with Slack, but on Slack, I get a generic message that the deployment for app failed at [TIMESTAMP], it provides me links to view in detail, but since i cannot share the DO account with fellow devs, I need a way to show build logs or error stack on Slack.

Is there a way to do that?

Or do I have to setup alerts another way?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
December 19, 2023

Hey @abbasanemone,

Indeed, DigitalOcean’s App Platform offers Slack integration for deployment notifications, but these notifications are generic and do not include detailed build logs or error stacks directly in the Slack message.

The best thing to do to get your voice heard regarding this would be to head over to our Product Ideas board and post a new idea, including as much information as possible for what you’d like to see implemented.

https://ideas.digitalocean.com/

For the time being, what you could do is create a script that uses doctl (the official DigitalOcean CLI tool) to fetch deployment logs and then potentially send them to Slack, you’ll need to have doctl installed and authenticated with your DigitalOcean account.

The script can be written in a language like Bash. Here’s a basic outline of how such a script might look:

#!/bin/bash

# Set your DigitalOcean App ID
APP_ID="your-app-id-here"

# Get the last deployment ID
DEPLOYMENT_ID=$(doctl apps list-deployments $APP_ID --format ID --no-header | head -n 1)

if [ -z "$DEPLOYMENT_ID" ]; then
    echo "No deployment found for app ID $APP_ID"
    exit 1
fi

echo "Fetching logs for deployment ID $DEPLOYMENT_ID..."

# Fetch the deployment logs
LOGS=$(doctl apps logs $APP_ID --deployment $DEPLOYMENT_ID --type BUILD --follow=false)

# Check if logs are empty
if [ -z "$LOGS" ]; then
    echo "No logs found for deployment ID $DEPLOYMENT_ID"
    exit 1
fi

# Output the logs
echo "Logs for deployment ID $DEPLOYMENT_ID:"
echo "$LOGS"

# Send logs to Slack (you need to replace this with your Slack webhook or another method of sending messages to Slack)
# SLACK_WEBHOOK_URL="your-slack-webhook-url"
# curl -X POST -H 'Content-type: application/json' --data '{"text": "'"Logs for deployment ID $DEPLOYMENT_ID:\n$LOGS"'"}' $SLACK_WEBHOOK_URL

Some remarks:

  1. Replace your-app-id-here with the actual ID of your application in DigitalOcean.
  2. The script fetches the logs for the latest deployment. You can modify the script to target specific deployments as needed.
  3. The commented-out Slack section shows a basic example of how you might send the logs to Slack using a webhook. You’ll need to set up a Slack Incoming Webhook and replace your-slack-webhook-url with your actual webhook URL.

Hope that helps!

- Bobby.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel