When using a cloud service, keeping tabs on availability and performance is critically important. Knowing that your system is humming along without issues helps keep you focused on your core business. One of the ways to keep track of your Akamai properties is through the Adaptive Alerts system, which sends you an email when your website experiences a spike in traffic, errors, or a number of other event types.
Many businesses have DevOps teams who are responsible for making sure that systems are running smoothly. Unfortunately, emails are an inefficient way to tell people that something needs to happen immediately to handle an issue. What’s needed is a more direct way to communicate with the responsible team without filling their inbox. A way to reach them where they are.
The Alerts API allows customers to integrate these alerts into various notification systems, including SMS, phone, or a case management system. It can be time consuming to write these integrations, however, so an ideal solution would reach people where they are without the need to write a lot of code.
Enter Slack. Slack is a messaging system which has been described as “ChatOps.” Slack was designed to make it easy to write hooks into their system, either for sending commands to a remote service or to receive messages sent by a system. Slack is heavily used among our customers’ support and operations teams so it’s a great service to integrate with.
Now, this integration could run on someone’s system, or on a server, but many times the IT department makes it cumbersome to provision new servers. And this is such a small service, it doesn’t need to run on a fully provisioned server. In fact, it’s really just a single command.
Which brings us to the other part of the technology stack – Lambda. This AWS service runs commands based on a trigger, and you only pay for the time the command is actually used. This is a small, quick function so you can frequently make it work with the Free Tier at AWS which allows up to a million requests per month. More information on Lambda pricing is available on their site.
To sum up, we will be using the following technology stack:
- Alerts API
Now, I’ll dig into the details of how to use this for yourself.
In order to create this on your own you’ll need:
- Administrative access to your Slack account
- An AWS account
- Python and pip installed on your local system
- Authentication credentials for the Alerts API
Slack is a chat server which runs in the cloud, and it’s become quite popular for inter-group communication. As well, there are a growing number of plugins increasing the number of actions you can take from within the chat rooms. However, what we’re going to do here is to set Slack up using their core API, rather than using one of the plugins. Here are the steps you need to get Slack setup correctly. If you don’t have a slack channel, this is a great time to get one.
- Navigate to https://[your-team-domain].slack.com/services
- At the top, Click Manage.
- In the left hand navigation bar click Custom Integrations.
- Click Incoming Webhooks and Add Configuration.
- Configure the webhook as you like and copy the URL for use in the next step.
Lambda is a serverless compute system. Each lambda function is managed separately, and the server runs the functions only as needed. You can manage your lambda functions through the AWS console, as we are doing here, but you can also interact via the AWS command line interface.
In order to use the function I’ve created you’ll need to create a code deployment package to upload to AWS. While it is possible to create and edit your function entirely within the console, this function requires some external libraries; the way AWS handles this is to have you upload the libraries along with the function itself.
Download the deployment package to your system, making sure to right- or command-click to save it as a Zip file.
Next, it’s time to set up the function in the AWS console. Through these steps, you’ll give AWS everything it needs to trigger the function you’ve created.
- Go to the AWS console at https://console.aws.amazon.com.
- Navigate to Lambda and Create new Function.
- Choose the blank template as we’ll be building the function from scratch.
- Under triggers, select CloudWatch Events – Scheduled and accept the default parameters (you can change them later), then click Next.
- Name your function, and select the Python 3.6 runtime.
- Code Entry Type is Upload a Zip File, and then upload the file you downloaded.
You need to set up variables for each of the configuration pieces for Akamai’s API Authentication.
- In slackChannel, enter the channel you want messages to appear in.
- In slackUrl use the URL you copied during Slack setup.
Your credentials information is also included in the environment variables as shown here:
At this point you’ve created an integration communicating any specified event to your team in Slack. The Alerts API has many other features, including the ability to create events.
We hope this DIY alerts recipe helps you cut down response times as problems arise, and lightens your inbox. Enabling the integration of our ecosystem into your own processes and systems is a fundamental goal of the Akamai for DevOps initiative. We’re always looking for more ideas from our customers about how we can better meet you where you work.
Categories: DevOps How To