Your Dynatrace environment can integrate with a Slack workspace using Slack Connector
. You can automate sending messages to Slack based on the events and schedules defined for your workflow.
External requests enable outbound network connections from your Dynatrace environment to external services. They allow you to control access to public endpoints from the AppEngine with app functions and functions in Dashboards, Notebooks, and Automations.
Go to
Settings > General > External requests.
Select New host pattern.
Add the domain names.
Select Add.
This way you can granularly control the web services your functions can connect to.
Some permissions are required by Workflows to run actions on your behalf. Other permissions are required by actions that come bundled with Slack Connector itself.
To fine-tune permissions granted to Workflows
app-settings:objects:readapp-settings:objects:writestate:app-states:readstate:app-states:writestate:app-states:deletestate:user-app-states:readstate:user-app-states:writestate:user-app-states:deleteFor more on general Workflows user permissions, see User permissions for workflows.
For Slack Connector workflow actions to interact with your Slack workspace, you first need to create a Slack App for Dynatrace and authorize its connection to Slack.
Go to Slack API and select Create an App.
In the Create an app window, select From an app manifest.
In the Pick a workspace to develop your app window, select the Slack workspace you want to connect to and select Next.
In the Enter app manifest below window, paste the manifest YAML provided below into the YAML tab.
Replace <app-name> and <bot-name> with values of your choice (for example, Dynatrace). For more information on the manifest YAML, see Slack documentation.
display_information:name: <app-name>features:bot_user:display_name: <bot-name>always_online: falseoauth_config:scopes:bot:- channels:join- channels:read- chat:write- chat:write.public- files:read- files:write- groups:read- im:read- mpim:read- reactions:read- reactions:writesettings:org_deploy_enabled: falsesocket_mode_enabled: falsetoken_rotation_enabled: false
Your Dynatrace Slack Connector requires an OAuth token to authorize sending messages to Slack.
The workflow action can be used to send Markdown-formatted messages or Block Kit-based interactive messages in Slack.
Connection: select any connection from the dropdown list, for example, dynatrace-notifications-sandbox.
Message: see the examples in the following table.
Input type
Sample input
Markdown
*Hello World*This is Markdown-formatted text!
Block Kit Builder
{"blocks": [{"type": "section","text": {"type": "mrkdwn","text": "*This is a section block with a button.*"},"accessory": {"type": "button","text": {"type": "plain_text","text": "Click Me"},"value": "click_me_123","action_id": "button-action"}}]}
Automation expression
{{ result("workflow_action_script_result") }}
Interactions
Select Run to send your message to your Slack channel.
Output:
Sample result
threadTs
123456789.01234
channelID
ABCDEF012345
messageTs
123456789.01234
permalink
https://your-environment.slack.com/archives/ABCDEFG/p12345679890
Log output examples
[INFO] POST https://slack.com/api/chat.postMessage called successfully[INFO] Message has been posted successfully
[ERROR] Slack API error while calling 'chat.postMessage': 'no_text'
You can use Block Kit Builder to create richly formatted messages for Slack. For text formatting options, see Slack's Markdown reference. After designing your message, copy the JSON output and adapt it to your needs in Dynatrace Workflows using workflow expressions.
{"blocks": [{"type": "header","text": {"type": "plain_text","text": "🚨 Dynatrace Alert: High CPU Usage Detected","emoji": true}},{"type": "section","text": {"type": "mrkdwn","text": "*Alert Details:*\n• *Entity*: `Host-1234`\n• *Metric*: CPU Usage\n• *Threshold*: > 90%\n• *Current Value*: 95%"}},{"type": "divider"},{"type": "section","text": {"type": "mrkdwn","text": "💡 *Recommended Actions:*"}},{"type": "actions","elements": [{"type": "button","text": {"type": "plain_text","text": "Acknowledge Alert"},"style": "primary","value": "acknowledge_alert"},{"type": "button","text": {"type": "plain_text","text": "View in Dynatrace"},"url": "https://dynatrace.example.com/alert/1234","style": "danger"}]},{"type": "context","elements": [{"type": "mrkdwn","text": "Triggered at: 2026-01-08 14:30 UTC"}]}]}
Slack doesn't have a built-in templating language. Use our templating functionality. For more information, see Dynatrace expressions. Expressions will be resolved at execution time, creating a static card payload that will be sent.
If you want to create a structured message with multiple data fields, you can use The Slack Block Kit to develop such a message. See the following example:
{"blocks": [{"type": "header","text": {"type": "plain_text","text": "production-payment-service","emoji": true}},{"type": "section","text": {"type": "plain_text","emoji": true,"text": "2024-01-09T11:30:00+01:00"}},{"type": "section","text": {"type": "mrkdwn","text": "```Error: Connection timeout after 5000ms\n at PaymentGateway.connect (gateway.js:45)\n at processPayment (service.js:123)```"}},{"type": "section","text": {"type": "mrkdwn","text": "DT App function: `processPayment`"}},{"type": "section","text": {"type": "mrkdwn","text": "DT entity service: `SERVICE-A1B2C3D4E5F6G7H8`"}}]}
To replicate this behavior, you can use expressions instead. The same example above can be created with the following snippet:
{%- set data = [{"dt_app_id": "production-payment-service","instance": "2024-01-09T10:30:00Z","error": "Error: Connection timeout after 5000ms\n at PaymentGateway.connect (gateway.js:45)\n at processPayment (service.js:123)","dt_app_function": "processPayment","dt_entity_service": "SERVICE-A1B2C3D4E5F6G7H8"}]-%}{"blocks": [{% for item in data %}{"type": "header","text": {"type": "plain_text","text": "{{ item.dt_app_id }}","emoji": true}},{"type": "section","text": {"type": "plain_text","emoji": true,"text": "{{ item.instance | to_datetime(timezone='Europe/Vienna') }}"}},{"type": "section","text": {"type": "mrkdwn","text": {{ ("```" ~ item.error ~ "```") | to_json }}}},{"type": "section","text": {"type": "mrkdwn","text": "DT App function: `{{ item.dt_app_function }}`"}},{% if 'dt_entity_service' in item %}{"type": "section","text": {"type": "mrkdwn","text": "DT entity service: `{{ item.dt_entity_service }}`"}}{% endif %}{% if not loop.last %},{% endif %}{% endfor %}]}
{% set data = [...] %} - Define data inline or use result("task_name") to reference workflow task results.{{ item.field }} - Access object properties.| to_datetime(timezone='...') - Format timestamps.| to_json - Escape special characters for JSON compatibility.{% if condition %} - Conditional blocks.{% for item in data %} - Iterate over arrays.For more expression capabilities, see Expression reference.
Go to Workflows
and select to create a new workflow.
In the Choose trigger panel, select the trigger best suited to your needs.
On the trigger node, select to browse available actions.
In the Choose action panel, search for slack and select Send message.
Select a pre-configured Slack connection.
Select a channel to send your message to.
We recommend using the Slack channel ID. You can also use a Slack channel name or Slack channel ID; however, not all features of the Send Message action will be available.
Provide a message body. Format your message using Slack Markdown. It is also possible to use workflow expressions as input.
To test your workflow, select Run.
The following are solutions to problems some people had with Slack integration.