Skip to content

rellyson/ifood-challenge

Repository files navigation

iFood Assessment Challenge

Description

As we receive security alerts from different systems and, and it's not viable checking incidents manually, we need an automated way to receive them in Slack and ensure that no alert will be lost due to the unavailability of some component. Therefore, your objective in this challenge will be to develop a system that receives alerts and notifies them in different channels in Slack, guaranteeing the delivery of messages through an AWS SQS queue.

Your system must have the following components:

  • A server that receives JSON events through its API and sends them to an AWS SQS queue. These events must at least contain the message and the Slack channel where that message will be posted.
  • An AWS SQS queue.
  • A worker that consumes these messages from the queue and post them to the Slack channel.

Project requirements

  • The server must be implemented in Go and the worker in Python.
  • The server, worker and AWS environment must be dockerized.
  • Documentation and testing.

How alert notification works

This diagram ilustrates the notify alert sequence flow.

Usage

Create and configure a Slack App to send messages

You need a Slack App to be able to send messages to a channel. You can create an app following this tutorial. After creating an app, you need to set some configurations to be able to interact with a channel:

  • Click the app and select OAuth & Permissions tab in the left sidebar.
  • Scroll down to Scopes. To send messages to a channel you need to add the chat:write Oauth Scope.
  • Grab your Oauth Token in OAuth Tokens for Your Workspace.
  • Invite your app to a channel using /invite @AppName.

Set yout OAuth Token

Now that you have your App Oauth Token, go to workers/slack-notifier/conf/default.env file and paste it in the SLACK_OUATH_TOKEN variable.

SLACK_OUATH_TOKEN=xox-testestestestsetetstes123

Starting the system

You have these alternatives to start the system:

# Runs using base image
$ docker-compose up

# Runs in a development environment, enabling auto reload
$ docker-compose -f .docker/dev-compose.yaml up

Sending an alert notification

To send an alert notification to a Slack channel through this system, send a POST request to http://localhost:3000/v1/events/notify_alert endpoint, following the payload specified below.

The attachments field is optional. More info about build attachments can be found here.

{
    "channel": "my-notification-channel",
    "messsage": "Hi from notification server",
    "attachments": [
      {
          "text": "Attachment text",
          "fallback": "Fallback text"
      }
    ]
}

Example

# Using curl
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"channel":"my-notification-channel","message":"This is a message"}' \
  http://localhost:3000/v1/events/notify_alert

Useful links