Setting up Turbonomic Action Notifications to Slack Channels

An interesting use-case that I’ve bumped into lately is where folks want to enable automation, but they also need to know when automated things happen. Email was the common platform for notifications, and still is, but there are many more organizations adoption Slack for day-to-day activity monitoring and building out interesting interactive ways to enable the ChatOps approach to IT operations management.

Since you may have followed along my first article which showed you how to set up a custom WebHook integration for your Slack team channel, we will take that one step further and show you how to configure Turbonomic to send notifications of actions to your Slack channel.

Setting up Action Scripts in Turbonomic

One of the cool features within Turbonomic is something called Action Scripts. These are scripts that are run when a particular actions happens on a particular entity within the environment. Action scripts run at different times in the process including before (PRE) and after (POST) the action so that you can either get notification or to trigger some interaction with the action.

Action Scripts run for every action time available including moves, scale/resize, and more. The naming of each Action Script is relative to the timing (PRE/POST) and the action type. You only need to create one Action Script which is hosted on your Turbonomic control instance and launched by the Turbonomic engine as actions are triggered.

The official documentation on using Action Scripts is here, but for our purposes here I will give you a crash course in creating a PRE move script so that we can send Slack notifications when an application workload is about to move.

Variables Accessible during Action Script Execution

There are a number of environment variables which are generated when a Turbonomic action is instantiated. Some of these include:

$VMT_TARGET_NAME – the entity which is subject to the move action
$VMT_CURRENT_NAME – the source location where the entity is located
$VMT_NEW_NAME – the destination where the entity will be moved
$VMT_ACTION_NAME – the unique ID for the action

These are the ones that I’ve chosen to include for my Slack notifications because I will want to know the workload which is subject to the move, the source location, target location, and then having the ID of the action is helpful for auditing and also for more deeper integration with a true ChatOps approach that we will dive into further in another post.

For now, the Slack notifications will be simply to log for us using our Slack channel whenever there are moves occurring. You can select from any of the different actions in the Action Scripts, so this is a good place to start.

The PRE_MOVE_VirtualMachine.sh Script

The simplest view of the script is as follows. Simply create a file named PRE_MOVE_VirtualMachine.sh which is the one that is called by a move action. This could be anything from a VM migration across hosts, clusters, or also container pod changes and more.

We need to leverage the action variables that we have been given and pass them into the our Slack API call. The simplest method for this is to inject a cURL command into the Action Script that will run using the native cURL command available on your Turbonomic instance.

The command to post to the API for Slack requires your WebHook URL which you can get by following this guide that helps you get the WebHook set up.

This is the full GitHub Gist of the code. If you have existing Action Scripts in the folder, you can simply append these lines to your existing script.

Take note of the use of quotes within the command line as we need to pass the variables into the cURL command which requires additional double-quotes around the entire command.

Last step – Enable Action Script for Moves in Turbonomic

At the time of this writing, the Action Scripts features are still in the traditional flash UI. Go to the Policy view in your Turbonomic instance and expand the Action | VM section where we will enable the Action Scripts for Virtual Machines in this case.

Simply check off the Action Script Settings setting for the PreMove action and you are all set. In the image above we can see that I also have Move actions automated which may be set to Manual for your environment.

NOTE: Enabling policy changes within Turbonomic will trigger a refresh of the actions. This is because the state of your policies has changed and the entities in the environment must shop for the appropriate resources to satisfy their demand based on the newly formed policy configuration. This is the nature of the system being real-time so that no actions are held when they could be stale or unnecessary due to other environmental changes that have occurred.

The Slack View

Under your Slack channel, you will now begin seeing notifications whenever an action occurs. This is what your channel will start to look like as the moves take place:

In my case, I have enabled full automation; This means that these actions are triggered and the notification is done as the action is about to occur. We can also do POST_MOVE script which is handy if we are building out other hooks.

The goal with Action Scripts is to be able to integrate with any application lifecycle management process or product.  Look for much more in the coming weeks as we walk through some more integrations that can be done with this method.




Setting up a Slack WebHook to Post Notifications to a Team Channel

If ChatOps is something you’ve been hearing a lot about, there is is a reason. Slack is fast becoming the de facto standard in what we are calling ChatOps. Before we go full out into making chatbots and such, the first cool use-case I explored is enabling notifications for different systems.

In order to do any notifications to Slack, you need to enable a WebHook. This is super easy but it made sense for me to give you the quick example so that you can see the flow yourself.

Setting up the Slack Webhook

First, we login to your Slack team in the web interface. From there we can open up the management view of the team to be able to get to the apps and integrations. Choose Additional Options under the settings icon:

You can also get there by using the droplets in left-hand pane and selecting Apps and Integrations from the menu:

Next, click the Manage button in the upper right portion of the screen near the team name:

Select Custom Integrations and then from there click the Incoming WebHooks option:

Choose the channel you want to post to and then click the Add Incoming WebHooks Integration button:

It’s really just that easy! You will see a results page with a bunch of documentation such as showing your WebHook URL:

Other parts of the documentation also show you how to configure some customizations and even an example cURL command to show how to do a post using the new WebHook integration:

If you go out to a command line where you have the cURL command available, you can run the example command and you should see the results right in your Slack UI:

There are many other customization options such as which avatar to use, and the specifics of the command text and such. You can get at the WebHook any time under the Incoming WebHooks area within the Slack admin UI:

Now all you have to do is configure whatever script or function you have that you want to send notifications to Slack with and you are off to the races.




All Slacked Out – Long Live Email

There is always a fight for the industry to come up with a “better mouse trap”.  Quite often, there is good reason for this.  The real question when we try to do something like design a better mouse trap, should be “do we really have a mouse problem?”

Here’s my Slack journey.

Step 1 – Everyone talks about Slack.  I try Slack.

We’ve been inundated with the conversations that start with “Hey, are you on Slack yet?” and the plethora of emails with invites from all of our communities that we participate in.  As the promised “email killer”, Slack seems like it could be a worthy replacement for the IM world, combined with the ability to share information like some file sharing products do.  By sharing better in real time and with persistent chat, this could really unseat the need for email, right?

Slack-WhyNot

Step 2 – Day 1 – So much chat goodness!!

It’s like having DMs, but with the world!  Every sub-group of folks that I do things with are on Slack, so I’m on 7 different Slack teams, each with two channels: #random and #general

Slack-day1

I’m a little worried about the fact that everything is in these two unorganized channels, but that’s the beauty of Slack, right?  Everyone says that we should segment it to make it better, but not a single one of the Slack teams have done so yet.  I’m sure that they will, right?

Slack is interesting because it’s got the randomness and immediacy of Twitter, the reach of IM, and the promise of eliminating the need for email.  I can’t wait to make this work!

Step 3 – It’s a little overwhelming

Well, I still have email.  I still have Skype, which I also use for voice and video calls every day.  I still have SMS and Twitter, both of which are primary contact methods for many people.  FaceTime for free calls is a clincher, so that’s not going away.  I’m sure that I can make Slack a primary use product.  After all, it’s promised to eliminate the need for email.

slack-lots-of-content

Step 4 – Always on.  ALWAYS, ALWAYS, ALWAYS on

The email killer is now taking up most of the day tracking notifications.  The conversation counter is ticking up constantly.  There is quite a bit of chatter on here, so more chat should mean more value, right?  The issue is that it has become so noisy that I have already started to just reset the notifications and scroll to the bottom without reading the content.

Email has the ability to be closed out.  I’ve specifically set my email regimen to be only open during certain hours of the day, and I check occasionally just to make sure that nothing urgent comes up.  Skype and SMS are the primary source of “Hey, I need something pretty urgently…” type of content.

At this point in the Slack journey, I’ve already stopped using the client after hours and on weekends because it has become very noisy.

Slack-downtime

Step 5 – Slack Jumps the Shark for me

It doesn’t take too long before I hit the wall.  I’ve tried using Slack in my daily routine on 3 different occasions.  Each time I give it a try over a few weeks.  Each time it results in the same sensation.  I want out.

Slack-lastday

 

Step 6 – Freedom from Slack

I still have Slack.  Notifications are turned off altogether.  I log in every once in a while just to scroll through the conversations.  What’s interesting is that I’m not the only one.  Most of the Slack teams I’m on have reduced the usage to near zero.  Email is a very different medium for sharing information.  IM, Skype, SMS, FaceTime, and other products have such a deep integration to day-to-day interaction with many people that it has become a mainstay.

The moment that I accept that Slack just isn’t working, I immediately feel relieved.

Slack-ImOut

Slack is great, but not for me.  If you’re connecting Slack to development workflows and lots of micro-team collaborative work, I applaud you and the product.  I think I could have made it work with a few adjustments:

  • Organize the channels and content appropriately
  • Integrate with other systems to enhance the workflow
  • Find the teams that can use it well, and will also shed other medium to fully embrace it

Slack didn’t replace email.  It never will.  Hoping that you can find more from it than I did.

slack-irony