Skip to content

Webhook Examples Slack

amccook edited this page Jul 12, 2023 · 18 revisions

Prerequisites

Create a Slack App and enable Incoming Webhooks: https://api.slack.com/messaging/webhooks

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 Move

This Workflow DTO was written to accommodate On-Prem > VM > 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

Container Workload Controller Resize

This Workflow DTO was written to accommodate container 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.namespace
    • $action.target.aspects.containerPlatformContextAspect.containerPlatformCluster
    • $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 VM/node provision and 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
    • $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 and cloud 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