Azure-Sentinel/Playbooks/Send-IngestionCostAlert
..
images
azuredeploy.json
readme.md

readme.md

Ingestion Cost Alert Playbook

Managing cost for cloud services is an essential part of ensuring that you get maximum value for your investment in solutions running on this computing platform. Azure Sentinel is no different. To help you exercise greater control over your budget for Azure Sentinel  this playbook will send you an alert should you exceed a budget that you define for your Azure Sentinel Workspace within a given time-frame.

Deployment steps

  1. Log into the Azure Portal
  2. In the Azure search box type Log Analytics Workspaces

01-laazureportal

  1. Select the Azure Sentinel workspace

02-laworkspaces

  1. Copy the Subscription ID, Resource group and the Workspace name

The Logic App is activated by a Recurrence trigger whose frequency of execution can be adjusted to your requirements

03-Rgselection

  1. Scroll to the bottom of this document and select Deploy to Azure

04-Azuredeploy

  1. Log into the Azure portal

  2. Enter the following information

  • Subscription: Select the Subscription
  • Resource Group: Select the RG
  • Playbook Name: Enter playbook name
  • Sentinel WS Name: Enter workspace name
  • Sentinel Sub ID: Enter Subscription ID
  • Sentinel ES Resource Group: Enter Resource Group Name
  • Mail List: Enter email address of user(s) that need to get the notification
  • User Name: Enter account with permissions to create a logic app

05-deploymentscope

  1. Select Review + create + Create
  2. Click Go to resource group
  3. Click o365-IngestionCostAlert

06-o365api

  1. Click Test connection failed.

07-testconnection

  1. Click Authorize

08-authorizeAPI1

  1. Login into portal again

09-portalauth

  1. Click Save

10-authapisuccess

  1. Click the resource group again

11-clickrg2

  1. Click teams-IngestionCostAlert

12-teamsapi

  1. Click Test connection failed.

13-teamstestapi

  1. Click Authorize

14-teamsauthorize

  1. Login into portal again

15-teamslogin

  1. Click Save

16-teamsapisave

  1. In the Azure search box type Logic App

17-logicappsearch

  1. Select the newly created logic app

18-logicappfind

  1. Click Logic app designer

19-LAdesigner

  1. Select Price Per GB
  2. Change the Type to Float
  3. For the value, enter the total cost of Sentinel. This value will consist of the cost of:

These 3 costs should be added together

20-recurrence

  1. Select Days in a month and change the days to 31

21-daysvar

  1. Select Monthly budget and enter the total monthly budget

22-totfund

  1. Select Threshold per day and enter the daily limit. To get this value simply divide the total budget from step 29 above by the number of days per month (31) in step 28

23-daythresh

  1. Select Connection

  2. Select the account to log in with or add a new connection

24-connection1

  1. Click Sign-in and log into the account

25-AMconnection

  1. Click For Each -> Condition

  2. Enter the email address of the user(s) that will receive the notification. (secops@yourdomain.onmicrosoft.com) 25-foreach

  3. Click Add an Action

  4. Search for “Office365 Outlook”

  5. Select “Send an e-mail”

27-sendmail

  1. Select “Add an action”
  2. In the search box type Teams -> Microsoft Teams

28-searchteams

  1. In the search box type Post a message -> Post a message (V3) (preview)

29-teamspost

  1. Select the Teams group that will receive the message

  2. Select the Team Channel within that teams group

30-teamsaddress

  1. In the message box type You have exceeded your daily budget

  2. Click the Dynamic content -> Max_per_day

31-teamsdynamic

When complete this section should look as follows:

32-teamsthresh

  1. Click Save

33-saveapp

Below is the query being executed in the step above in text format which you can use for validation directly in the Log Analytics query window. Ensure to replace the variables below with actual numbers if running the query within the Log Analytics query window.

  let price_per_GB = price_per_GB;
  let how_many_days = days_in_month;
  let total_funding = monthly_budget;
  let max_per_day = toreal(monthly_budget) / toreal(days_in_month);
  Usage
  | where TimeGenerated > startofday(ago(1d))
  | where IsBillable == true
  | summarize AggregatedValue= sum(Quantity) * price_per_GB / 1024
  | where AggregatedValue > max_per_day

In this step, the aggregated value obtained from the previous step is compared against the budget value you set and should it exceed the amount then the logic branches to the left and sends out an e-mail or posts a Microsoft Teams message. If you are still within budget, then the logic branches to the right and no message is sent.

34-computation

In the final step below sends out an e-mail to the specified recipient list and a message is posted in a Microsoft Teams channel that you selected earlier

35-sendmessage

Additional information on cost management can be found in this document

Special thanks to Damon Neal for his documentation template