Skip to content

Webhook Examples Slack

Jason Shaw edited this page Aug 23, 2024 · 18 revisions

Prerequisites

  • Create a Slack App and enable Incoming Webhooks: https://api.slack.com/messaging/webhooks
  • Emoji: All of the messaging examples contain reference to Slack emoji ⚖️ 🛑 🏃‍♂️. Most are standard, but some might not be so you many see some emoji fail to load. Feel free to remove/edit the emoji references in the webhook DTO. There is reference to a Turbonomic emoji :turbonomic: which you can add to your Slack if you'd like.

Tips & Tricks

To create nicely formatted Slack messages, the following links may be helpful:

Examples

For each example, the following details will be shared:

  • Screenshot of example
  • Variables used from Turbonomic's Action DTO
  • User Variables you must supply
  • Link to JSON Workflow DTO to add webhook to your Turbonomic instance
  • Link to unescaped JSON for Slack Block Kit Builder in case you want to modify the template to your liking

Each example has been written for a specific Action. Please note the platform (On-Prem, Cloud, Container, etc), entity (VM, DB, Workload Controller, etc), and action (Move, Resize, etc) when implementing the webhooks. Webhooks may fail if implemented on the incorrect platform, entity, or action as certain Action DTO variables only exist for specific types of actions.

On-Prem VM Host & Storage Move

This Workflow DTO was written to accommodate On-Prem > VM > Host|Storage Move actions. It could work for other actions as long as the action DTO has the same variables.

image

  • Action DTO Variables

    • $action.target.className
    • $action.actionType
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $action.updateTime
    • $action.target.displayName
    • $action.currentEntity.displayName
    • $action.newEntity.displayName
    • $action.risk.subCategory
    • $action.risk.description
    • $action.target.uuid
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: On-Prem VM Move

  • Slack Block Builder JSON: On-Prem VM Move

On-Prem VM Resize

This Workflow DTO was written to accommodate On-Prem > VM > Resize actions. It could work for other actions as long as the action DTO has the same variables.

  • Action DTO Variables

    • $action.target.className
    • $action.actionType
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $action.updateTime
    • $action.target.displayName
    • $action.details
    • $action.risk.subCategory
    • $action.risk.reasonCommodities (then using a #foreach loop, iterate through each commodity, $resizeRisk)
    • $action.target.uuid
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: On-Prem VM Resize

  • Slack Block Builder JSON: On-Prem VM Resize

On-Prem VM Resize with Tags

This Workflow DTO was written to accommodate On-Prem > VM > Resize actions that have a particular tag. It could work for other actions as long as the action DTO has the same variables.

  • Action DTO Variables

    • $action.target.className
    • $action.actionType
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $action.updateTime
    • $action.target.displayName
    • $action.details
    • $action.risk.subCategory
    • $action.risk.reasonCommodities (then using a #foreach loop, iterate through each commodity, $resizeRisk)
    • $action.target.uuid
    • $action.target.tags["<YOUR TAG KEY>"][0]
      • For example, if your tag was “Owner Email”, then the variable to use would be $action.target.tags["Owner Email"][0] AND when you add to the template, be sure to also escape the quotes. So the final variable would look like $action.target.tags[\"Owner Email\"][0]
      • If your VM is missing the “Owner Email” tag then this webhook will fail to generate.
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your tag key where it says <YOUR TAG KEY>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: On-Prem VM Resize with Tags

  • Slack Block Builder JSON: On-Prem VM Resize with Tags

On-Prem Host Start & Suspend

This Workflow DTO was written to accommodate On-Prem > Host > Start|Suspend actions. It could work for other actions as long as the action DTO has the same variables.

  • Action DTO Variables

    • $action.target.className
    • $action.actionType (using IF/ELSE statement to evaluate if action is SUSPEND or not)
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $!action.updateTime
    • $action.target.displayName
    • $action.details
    • $action.target.connectedEntities[0].displayName
    • $action.risk.subCategory
    • $action.risk.description
    • $action.target.uuid
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: On-Prem Host Start & Suspend

  • Slack Block Builder JSON: On-Prem Host Start & Suspend

On-Prem Storage Unattached Files Delete

This Workflow DTO was written to accommodate On-Prem > Storage > Delete Unattached Files actions. It could work for other actions as long as the action DTO has the same variables.

  • Action DTO Variables

    • $action.target.className
    • $action.actionType (using IF/ELSE statement to evaluate if action is SUSPEND or not)
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $!action.updateTime
    • $action.target.displayName
    • $action.virtualDisks[0].displayName
    • $action.details
    • $action.risk.subCategory
    • $action.risk.description
    • $action.target.uuid
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: On-Prem Storage Unattached Files Delete

  • Slack Block Builder JSON: On-Prem Storage Unattached Files Delete

Container Workload Controller Resize

This Workflow DTO was written to accommodate Container > Workload Controller > Resize actions - including compoundActions when more than one resource is being changed in a single action. It could work for other actions as long as the action DTO has the same variables.

  • Action DTO Variables

    • $action.target.className
    • $action.actionType
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $action.updateTime
    • $action.target.displayName
    • $action.target.aspects.containerPlatformContextAspect.namespaceEntity.displayName
    • $action.target.aspects.containerPlatformContextAspect.containerClusterEntity.displayName
    • $action.details
    • $action.risk.description
    • $action.risk.subCategory
    • $action.compoundActions (then using a #foreach loop, $containerAction)
      • $containerAction.target.displayName
      • $containerAction.risk.reasonCommodities (then using a #foreach loop, iterate through each commodity, $resizeRisk)
      • $containerAction.currentValue
      • $containerAction.newValue
      • $containerAction.valueUnits
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: Container Workload Controller Resize

  • Slack Block Builder JSON: Container Workload Controller Resize

Container Pod Move

This Workflow DTO was written to accommodate Container > Pod > Move actions. It could work for other actions as long as the action DTO has the same variables.

  • Action DTO Variables

    • $action.target.className
    • $action.actionType
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $!action.updateTime
    • $action.target.displayName
    • $action.currentEntity.displayName
    • $action.newEntity.displayName
    • $action.target.discoveredBy.displayName
    • $action.risk.subCategory
    • $action.risk.description
    • $action.target.uuid
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: Container Pod Move

  • Slack Block Builder JSON: Container Pod Move

Container VM Provision & Suspend

This Workflow DTO was written to accommodate Container > VM/Node > Provision|Suspend actions. It could work for other actions as long as the action DTO has the same variables.

  • Action DTO Variables

    • $action.target.className
    • $action.actionType (using IF/ELSE statement to evaluate if action is SUSPEND or not)
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $!action.updateTime
    • $action.target.displayName
    • $action.details
    • $action.target.aspects.containerPlatformContextAspect.containerPlatformCluster
    • $action.risk.subCategory
    • $action.risk.description
    • $action.target.uuid
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: Container VM Provision & Suspend

  • Slack Block Builder JSON: Container VM Provision & Suspend

Cloud VM & Volume Scale

This Workflow DTO was written to accommodate Cloud > VM|Volume > Scale actions. It could work for other actions as long as the action DTO has the same variables.

  • Action DTO Variables

    • $action.target.className
    • $action.actionType
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $action.updateTime
    • $action.target.displayName
    • $action.details
    • $action.risk.subCategory
    • $action.risk.description
    • $action.currentEntity.discoveredBy.displayName
    • $action.currentLocation.displayName
    • $action.stats[0].value
    • $action.target.uuid
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: Cloud VM & Volume Scale

  • Slack Block Builder JSON: Cloud VM & Volume Scale

Cloud Volume Delete

This Workflow DTO was written to accommodate Cloud > Volume > Delete actions. It could work for other actions as long as the action DTO has the same variables.

  • Action DTO Variables

    • $action.target.className
    • $action.actionType
    • $action.actionState (using IF/ELSEIF/ELSE statement to evaluate if action is SUCCEEDED, READY, IN_PROGRESS, FAILED)
    • $action.actionMode
    • $action.userName
    • $action.updateTime
    • $action.target.displayName
    • $action.virtualDisks[0].attachmentState
    • $action.virtualDisks[0].tier
    • $action.virtualDisks[0].numDaysUnattached
    • $action.risk.subCategory
    • $action.risk.description
    • $action.currentEntity.discoveredBy.displayName
    • $action.currentLocation.displayName
    • $action.stats[0].value
    • $action.target.uuid
  • User Variables:

    • Add your Slack Webhook URL where it says <YOUR SLACK WEBHOOK URL>
    • Add your Turbo URL where it says <YOUR_TURBO_URL>
  • Workflow DTO: Cloud Volume Delete

  • Slack Block Builder JSON: Cloud Volume Delete