How to Incorporate Slack Alerts Into Your Development Process

DZone 's Guide to

How to Incorporate Slack Alerts Into Your Development Process

Slack is quickly becoming a part of our daily dev lives. You can use your own tool to send Slack notifications, as well as send Slack notifications from BlazeMeter.

· Integration Zone ·
Free Resource

Most developers today use instant messaging apps like Slack, HipChat, and Lync. These apps are used to communicate with other company members and to get automated alerts — for example, when their server is down, when a certain service isn’t working, when jobs fail, or when CPU is too high. These notifications are important because they inform you of the status of your development and let you quickly fix what needs fixing. Slack is also more convenient than emails because people often ignore them.

In this blog post, I will show you what you need to do to get Slack notifications and alerts when you’re developing and testing. Then, I'll show you how to get Slack notifications for your BlazeMeter tests.

Let’s go!

1. Create a New Incoming Webhook URL

First, you need to create a new incoming webhook URL on Slack. Webhooks post external messages on Slack, by using HTTP requests with a JSON payload. To do that, go to the Slack site here (you will need to sign in with your team domain).

2. Choose Your Channel

Choose the channel you want to get notifications to and click Add Incoming Webhooks integration.

Image title

3. Copy the URL

Copy the Webhook URL you receive:

Image title

4. Customize

You can customize the image and the name that you will receive notifications from:

Image title

5. Save Your Settings

Pretty self-explanatory.

6. Configure

Paste the URL you copied in the tools you are using for developing or testing. Each tool has a different configuration, so search the documentation for exact instructions on your tool.

For example, the configuration for codecov is defined in a file called codecov.yml. As you can see here, the webhook URL is defined inside the Coverage section. You get Slack notifications from codecov when the unittests-coverage delta is worst from what you demand. 

Image title

Now, BlazeMeter also supports integration with Slack for determining test failure according to the criteria you determine. The notification is sent directly to your channel or private room, so you can handle it quickly and efficiently. Until now, you could receive notifications when the test was saved, when it started and when it ended — but now, you are notified about your test passing or failing.

Go to Workspace settings > Alerts > (+).

You will get this screen:

Image title

2. Configure the alert settings and fill in the email and/or Slack Webhook URL (creation is the same as described above) that you want to receive notifications to. You will get a notification with a link to the report/test according to the trigger you set.

You can also configure Slack alerts via API. Just run the following lines in the command line:

curl -X POST https://a.blazemeter.com/api/v4/usage-alerts -H "Content-Type: application/json" -H "x-api-key: <api_key>" -d '{"email":”<your_email>”,"testConcurrency":<minimum_test_concurrency>,"testDuration":<minimum_test_Duration>,"testEndedEvent":<true/false>,"testFailedEvent":<true/false>,"testPassedEvent":<true/false>,"testSavedEvent":<true/false>,"testStartedEvent":<true/false>,"slackWebhookUrl":"<your_slack_Webhook_Url>","workspaceId":<your_workspace_Id>}'

That’s it! You now know how to get Webhook URLs from Slack, what to do to add them to your tool, and how to add Slack notifications to your BlazeMeter tests.

blazemeter, integration, slack, tutorial, webhooks

Published at DZone with permission of Dor Atias , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}