Tutorial Highlights & Transcript
00:00 - nSights Slack Slash Commands ( introduction )
Hello, everyone. So today I’m going to give a demo on using slash commands to perform actions on Datadog. Basically, in this demo, I’m going to show untoiling a process that we on call us to do.
00:25 - What are Slash Commands?
So basically Slack slash commands allow users to invoke your app by typing a string into the message composer box, a submitted slash command will cause a payload of data to be sent to Slack to the associated app that sends and then respond whatever way it wants, using the context provided by the payload.
00:46 - Slash Commands Use Case
This is a use case in one of our clients who had their application running on two live servers out of four every time in which two remain on standby. So every time they switch their server, they send information to us on Slack with the Switch server name, then our on-call team needs to update the Datadog field Datadog monitor which earlier included the old server name with the new server. This process of updating our monitors on Datadog takes time, as we need to update the monitor individually and thus create a toil. Now, we will use the Slack slash command to update the Datadog monitor within seconds.
01:25 - Slash Command Flowchart
So this is the flowchart of what we’ll be doing. So here first, you can see the user will enter the slash command. As soon as the slash command is entered. The payload is sent to the API gateway. As we have configured the slash command to send the payload to the API gateway. As soon as the API gateway receives the payload, it triggers a Lambda function. So basically the Lambda function is the one which is making the DD API calls to update the monitor. Also, at the same time, when these monitors are updated it sends us messages back to the slash. So let me take you to the console.
02:00 - Demo Using Slack Slash Commands
And let’s first show you my Lambda function code. So, this is the main function code which will be making the changes that Datadog monitors. So this is the basic library I am using. And this first function is filtering the payload. According to my requirement, I am fetching the command sent by the user and also the service name. And the next section provides me with the current status. If the user wants to know which servers are currently active, then the user can send the command Switch server status, then this function will give him the current life rate service name. And then this section of the code will make the main changes in the Datadog Monitor. And also, I made a few conditions so that if a user accidentally enters some long service name, it will not change the Datadog monitor. It will only change the monitor when the user enters the correct server from the list. And also, if the server should be different from the current live servers. If someone entered the same server name that is already active, then it won’t change the monitor. So this is the Lambda function I’m working on. So for demo purposes, I have these other three monitors. We generally perform the changes manually, when the client tells us to switch the servers. So I have now cloned this monitor and mute it so that I can show you the changes I am making through slash commands. So, let me move to this my Slack channel. In this channel I have configured the Slack slash command. So I will first check if this is the Switch server command. And if I need to check the status of current servers being active, I will just go with it. So it will tell the current server that the bingo monitors are bingo GMS8 and bingo GMS 10 that we can check it from here. So current live servers you can see are bingo GMS 8 and bingo GMS 10. As soon as the client tells us to change the monitor from 8 and 10 to 7 and 9. Then we generally used to update it manually but now we can just place the command along with a new service name bingo GMS 7, 9. Now it says the Datadog monitor has been switched. So we can check it from here also.
Now you can see that the servers being monitored are now changed to 7 and 9. And this also the conditions are for not host equal to 8. So using slash command, within seconds, we have switched the servers and reduced the Enter. That reduces toil for our on call teams. So it was a short demo from my side. Thank you so much.
Sachin Kapoor
Support Team Lead
nClouds
Sachin has been a DevOps Engineer at nClouds since 2018. He is an AWS Certified Solutions Architect - Associate and AWS Certified SysOps Administrator - Associate. He has hands-on experience in architecting/automating and optimizing complex deployments over a variety of large scale infrastructure.