This commit is contained in:
iwafula025 2021-06-22 18:32:59 +03:00
Родитель 33514268b8
Коммит bb7699188e
13 изменённых файлов: 479 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,238 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"PlaybookName": {
"defaultValue": "IngestionAnomalyAlert",
"type": "string"
},
"Upper Anomaly Threshold": {
"defaultValue": "Upper Anomaly Threshold (type float, E.g 2.5)",
"type": "string"
},
"Reporting Quantity": {
"defaultValue": "Reporting Quantity (type integer, 10GB)",
"type": "int"
},
"Lookback": {
"defaultValue": "Lookback days (type integer, E.g. 30)",
"type": "int"
},
"Percent Increase": {
"defaultValue": "Percent increase (type integer, E.g. 25)",
"type": "int"
},
"Azure Sentinel Log Analytics Workspace Resource Group Name": {
"defaultValue": "Enter Resource Group Name",
"type": "string"
},
"Azure Sentinel Log Analytics Workspace Name": {
"defaultValue": "Enter Workspace Name",
"type": "string"
},
"Notification Email": {
"defaultValue": "Notification email (ex. soc@xyz.com)",
"type": "string"
}
},
"variables": {
"AzureMonitorLogsConnectionName": "[concat('azuremonitorlogs-', parameters('PlaybookName'))]",
"o365ConnectionName": "[concat('o365-', parameters('PlaybookName'))]"
},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[variables('AzureMonitorLogsConnectionName')]",
"location": "[resourceGroup().location]",
"properties": {
"displayName": "[variables('AzureMonitorLogsConnectionName')]",
"customParameterValues": {},
"api": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azuremonitorlogs')]"
}
}
},
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[variables('o365ConnectionName')]",
"location": "[resourceGroup().location]",
"properties": {
"displayName": "[variables('o365ConnectionName')]",
"customParameterValues": {},
"api": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
}
}
},
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('PlaybookName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/connections', variables('AzureMonitorLogsConnectionName'))]",
"[resourceId('Microsoft.Web/connections', variables('o365ConnectionName'))]"
],
"tags": {
"createddate": "04/19/2021",
"owner": "inwafula"
},
"properties": {
"state": "Disabled",
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Day",
"interval": 1
},
"type": "Recurrence"
}
},
"actions": {
"Initialize_variable": {
"runAfter": {
"LookBack": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "PercentIncrease",
"type": "integer",
"value": "[parameters('Percent Increase')]"
}
]
}
},
"LookBack": {
"runAfter": {
"ReportingQty": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "LookBack",
"type": "integer",
"value": "[parameters('Lookback')]"
}
]
}
},
"ReportingQty": {
"runAfter": {
"UpperAnomalyThreshold": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "ReportingQty",
"type": "float",
"value": "[parameters('Reporting Quantity')]"
}
]
}
},
"Run_query_and_visualize_results": {
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"body": "let UpperThreshold = @{variables('UpperAnomalyThreshold')};\nUsage\n| where IsBillable == \"true\"\n| where Quantity > @{variables('ReportingQty')}\n| make-series Qty=sum(Quantity) on TimeGenerated from ago(@{variables('LookBack')}d) to now() step 1d by DataType\n| extend (anomalies, score, baseline) = series_decompose_anomalies(Qty, 1.5, 7, 'linefit', 1, 'ctukey', 0.01)\n| where anomalies[-1] == 1 or anomalies[-1] == -1\n| extend Score = score[-1]\n| where Score >= @{variables('UpperAnomalyThreshold')}\n| extend PercentageQtyIncrease = ((round(todouble(Qty[-1]),0)-round(todouble(baseline[-1]),1))/round(todouble(Qty[-1]),0) * 100)\n| project DataType,ExpectedQty=round(todouble(baseline[-1]),0), ActualQty=round(todouble(Qty[-1]),0),round(PercentageQtyIncrease,0) \n| order by round(todouble(PercentageQtyIncrease),0) desc \n| where PercentageQtyIncrease > @{variables('PercentIncrease')}\n",
"host": {
"connection": {
"name": "@parameters('$connections')['azuremonitorlogs']['connectionId']"
}
},
"method": "post",
"path": "/visualizeQuery",
"queries": {
"resourcegroups": "[parameters('Azure Sentinel Log Analytics Workspace Resource Group Name')]",
"resourcename": "[parameters('Azure Sentinel Log Analytics Workspace Name')]",
"resourcetype": "Log Analytics Workspace",
"subscriptions": "[subscription().subscriptionId]",
"timerange": "Set in query",
"visType": "Html Table"
}
}
},
"Send_an_email_(V2)": {
"runAfter": {
"Run_query_and_visualize_results": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"body": {
"Body": "<p>An ingestion spike has been detected for the below tables:<br>\n<br>\n<br>\n@{base64ToString(body('Run_query_and_visualize_results')?['body'])}</p>",
"Importance": "High",
"Subject": "Ingestion Cost Spike Alert",
"To": "[parameters('Notification Email')]"
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
}
},
"UpperAnomalyThreshold": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "UpperAnomalyThreshold",
"type": "float",
"value": "[parameters('Upper Anomaly Threshold')]"
}
]
}
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"azuremonitorlogs": {
"connectionId": "[resourceId('Microsoft.Web/connections', variables('AzureMonitorLogsConnectionName'))]",
"connectionName": "[variables('AzureMonitorLogsConnectionName')]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azuremonitorlogs')]"
},
"office365": {
"connectionId": "[resourceId('Microsoft.Web/connections', variables('o365ConnectionName'))]",
"connectionName": "[variables('o365ConnectionName')]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
}
}
}
}
}
}
]
}

Двоичные данные
Playbooks/Send-IngestionAnomalyAlert/images/01-azuredeploy.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 14 KiB

Двоичные данные
Playbooks/Send-IngestionAnomalyAlert/images/02-parameters.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 73 KiB

Двоичные данные
Playbooks/Send-IngestionAnomalyAlert/images/03-selectapp.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 160 KiB

Двоичные данные
Playbooks/Send-IngestionAnomalyAlert/images/04-editapp.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 133 KiB

Двоичные данные
Playbooks/Send-IngestionAnomalyAlert/images/05-recurrence.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 24 KiB

Двоичные данные
Playbooks/Send-IngestionAnomalyAlert/images/06-connections.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 32 KiB

Двоичные данные
Playbooks/Send-IngestionAnomalyAlert/images/07-saveapp.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 58 KiB

Двоичные данные
Playbooks/Send-IngestionAnomalyAlert/images/08-enableapp.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 155 KiB

Просмотреть файл

@ -0,0 +1,51 @@
# Ingestion Anomaly Alert Playbook
This playbook sends you an alert should there be an ingestion spike into your workspace. The playbook uses the <em>series_decompose_anomalies</em> KQL funtion to dertermine anomalous ingestion.
## Deployment steps
Scroll to the bottom of this document and click the "Deploy to Azure" button
Fill in the parameters, changing the default values as required for your environment
![02-parameters](../Send-IngestionAnomalyAlert/images/02-parameters.png)
Select your newly deployed app from the resource group
![03-selectapp](../Send-IngestionAnomalyAlert/images/03-selectapp.png)
Click on edit to make the connections to Log Analytics and Office 365
![04-editapp](../Send-IngestionAnomalyAlert/images/04-editapp.png)
Defince the frequency the playbook should execute. Default is daily so you get alerted at the earliest sign of an ingestion anomaly
![05-recurrence](../Send-IngestionAnomalyAlert/images/05-recurrence.png)
Make the connections to your Log Analytics workspace using an account with the appropriate permissions. Do the same for Office 365.
![06-connections](../Send-IngestionAnomalyAlert/images/06-connections.png)
Save the app
![07-saveapp](../Send-IngestionAnomalyAlert/images/07-saveapp.png)
Enable the app
![08-enableapp](../Send-IngestionAnomalyAlert/images/08-enableapp.png)
<em> For more information on the anomaly function read this [this document](https://docs.microsoft.com/azure/data-explorer/kusto/query/series-decompose-anomaliesfunction)</em>
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAzure-Sentinel%2Fmaster%2FPlaybooks%2FSend-IngestionAnomalyAlert%2Fazuredeploy.json" target="_blank">
<img src="https://aka.ms/deploytoazurebutton"/>
</a>
<a href="https://portal.azure.us/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAzure-Sentinel%2Fmaster%2FPlaybooks%2Send-IngestionAnomalyAlert%2Fazuredeploy.json" target="_blank">
<img src="https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/deploytoazuregov.png"/>
</a>

Просмотреть файл

@ -0,0 +1,190 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workflows_IngestionAnomalyAlert_name": {
"defaultValue": "IngestionAnomalyAlert",
"type": "String"
},
"connections_azuremonitorlogs_1_externalid": {
"defaultValue": "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/CxE-inwafula/providers/Microsoft.Web/connections/azuremonitorlogs-1",
"type": "String"
},
"connections_office365_1_externalid": {
"defaultValue": "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/CxE-inwafula/providers/Microsoft.Web/connections/office365-1",
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('workflows_IngestionAnomalyAlert_name')]",
"location": "eastus",
"tags": {
"createddate": "04/19/2021",
"owner": "inwafula"
},
"identity": {
"principalId": "5d0b688e-ba4a-415d-b32c-c7187ee4d689",
"tenantId": "5f1060f2-d9a4-4f59-bf9c-1dd8f3604a4b",
"type": "SystemAssigned"
},
"properties": {
"state": "Enabled",
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Day",
"interval": 1
},
"type": "Recurrence"
}
},
"actions": {
"Initialize_variable": {
"runAfter": {
"LookBack": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "PercentIncrease",
"type": "integer",
"value": 30
}
]
}
},
"LookBack": {
"runAfter": {
"ReportingQty": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "LookBack",
"type": "integer",
"value": 30
}
]
}
},
"ReportingQty": {
"runAfter": {
"UpperAnomalyThreshold": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "ReportingQty",
"type": "float",
"value": 5
}
]
}
},
"Run_query_and_visualize_results": {
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"body": "let UpperThreshold = @{variables('UpperAnomalyThreshold')};\nUsage\n| where IsBillable == \"true\"\n| where Quantity > @{variables('ReportingQty')}\n| make-series Qty=sum(Quantity) on TimeGenerated from ago(@{variables('LookBack')}d) to now() step 1d by DataType\n| extend (anomalies, score, baseline) = series_decompose_anomalies(Qty, 1.5, 7, 'linefit', 1, 'ctukey', 0.01)\n| where anomalies[-1] == 1 or anomalies[-1] == -1\n| extend Score = score[-1]\n| where Score >= @{variables('UpperAnomalyThreshold')}\n| extend PercentageQtyIncrease = ((round(todouble(Qty[-1]),0)-round(todouble(baseline[-1]),1))/round(todouble(Qty[-1]),0) * 100)\n| project DataType,ExpectedQty=round(todouble(baseline[-1]),0), ActualQty=round(todouble(Qty[-1]),0),round(PercentageQtyIncrease,0) \n| order by round(todouble(PercentageQtyIncrease),0) desc \n| where PercentageQtyIncrease > @{variables('PercentIncrease')}\n",
"host": {
"connection": {
"name": "@parameters('$connections')['azuremonitorlogs']['connectionId']"
}
},
"method": "post",
"path": "/visualizeQuery",
"queries": {
"resourcegroups": "CxE-inwafula",
"resourcename": "IW-Sec",
"resourcetype": "Log Analytics Workspace",
"subscriptions": "1c61ccbf-70b3-45a3-a1fb-848ce46d70a6",
"timerange": "Set in query",
"visType": "Html Table"
}
}
},
"Send_an_email_(V2)": {
"runAfter": {
"Run_query_and_visualize_results": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"body": {
"Body": "<p>An ingestion spike has been detected for the below tables:<br>\n<br>\n<br>\n@{base64ToString(body('Run_query_and_visualize_results')?['body'])}</p>",
"Importance": "High",
"Subject": "Ingestion Cost Spike Alert",
"To": "inwafula@microsoft.com"
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
}
},
"UpperAnomalyThreshold": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "UpperAnomalyThreshold",
"type": "float",
"value": 2.5
}
]
}
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"azuremonitorlogs": {
"connectionId": "[parameters('connections_azuremonitorlogs_1_externalid')]",
"connectionName": "azuremonitorlogs-1",
"id": "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/providers/Microsoft.Web/locations/eastus/managedApis/azuremonitorlogs"
},
"office365": {
"connectionId": "[parameters('connections_office365_1_externalid')]",
"connectionName": "office365-1",
"id": "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/providers/Microsoft.Web/locations/eastus/managedApis/office365"
}
}
}
}
}
}
]
}

Двоичные данные
Playbooks/Send-IngestionCostAnomalyAlert/images/02-editapp.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 76 KiB

Двоичные данные
Playbooks/Send-IngestionCostAnomalyAlert/images/03-locateapp.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 85 KiB