Logic app to get the alert log search rule result via mail
Siva
646
Reputation points
Hi Team,
I am unable to pass the query from alert rule result to logic app for attaching the logsearch results in the alert mail.
Failed with below error. can any one assist on this?
{ "ResultStatus": "BadRequest", "Content": { "error": { "message": "The request had some invalid properties", "code": "BadArgumentError", "correlationId": "958a7146-30f0-45a4-a6a7-e5109acc8b37", "innererror": { "code": "SemanticError", "message": "A semantic error occurred.", "innererror": { "code": "SEM0002", "message": "No tabular expression statement found" } } } }, "Message": "Failed to get HTTP response because of invalid input (DRAFT, queryData). Bad request input. Please Check user input parameters (query syntax, chart type or other resource input)\r\nclientRequestId: b2933854-7dcd-461e-bff4-cf5e31dd6ceb"}
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"triggers": {
"When_an_HTTP_request_is_received": {
"type": "Request",
"kind": "Http",
"inputs": {
"schema": {
"type": "object",
"properties": {
"SubscriptionId": {
"type": "string"
},
"AlertRuleName": {
"type": "string"
},
"SearchQuery": {
"type": "string"
},
"SearchIntervalStartTimeUtc": {
"type": "string"
},
"SearchIntervalEndtimeUtc": {
"type": "string"
},
"AlertThresholdOperator": {
"type": "string"
},
"AlertThresholdValue": {
"type": "integer"
},
"ResultCount": {
"type": "integer"
},
"SearchIntervalInSeconds": {
"type": "integer"
},
"LinkToSearchResults": {
"type": "string"
},
"LinkToFilteredSearchResultsUI": {
"type": "string"
},
"LinkToSearchResultsAPI": {
"type": "string"
},
"LinkToFilteredSearchResultsAPI": {
"type": "string"
},
"Description": {
"type": "string"
},
"Severity": {
"type": "string"
},
"SearchResult": {
"type": "object",
"properties": {
"tables": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"columns": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"name",
"type"
]
}
},
"rows": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"required": [
"name",
"columns",
"rows"
]
}
},
"dataSources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"resourceId": {
"type": "string"
},
"region": {
"type": "string"
},
"tables": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"resourceId",
"region",
"tables"
]
}
}
}
},
"WorkspaceId": {
"type": "string"
},
"ResourceId": {
"type": "string"
},
"AlertType": {
"type": "string"
}
}
}
}
}
},
"actions": {
"Initialize_variables": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "AffectedResource",
"type": "array",
"value": "@split(triggerBody()?['data']?['essentials']?['alertTargetIDs'][0], '/')"
}
]
}
},
"Read_a_resource": {
"runAfter": {
"Initialize_variables": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['arm']['connectionId']"
}
},
"method": "get",
"path": "/subscriptions/@{encodeURIComponent(variables('AffectedResource')[2])}/resourcegroups/@{encodeURIComponent(variables('AffectedResource')[4])}/providers/@{encodeURIComponent(variables('AffectedResource')[6])}/@{encodeURIComponent(concat(variables('AffectedResource')[7], '/', variables('AffectedResource')[8]))}",
"queries": {
"x-ms-api-version": "2018-07-10"
}
}
},
"Compose": {
"runAfter": {
"Run_query_and_list_results": [
"Succeeded"
]
},
"type": "Compose",
"inputs": "@body('Run_query_and_list_results')"
},
"Send_an_email_(V2)": {
"runAfter": {
"Create_CSV_table": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['outlook']['connectionId']"
}
},
"method": "post",
"body": {
"To": "******@gmail.com",
"Subject": "testmail",
"Body": "<p class=\"editor-paragraph\">@{body('Create_CSV_table')}</p>",
"Importance": "Normal"
},
"path": "/v2/Mail"
}
},
"Run_query_and_list_results": {
"runAfter": {
"Read_a_resource": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azuremonitorlogs-1']['connectionId']"
}
},
"method": "post",
"body": "@triggerBody()?['SearchQuery']",
"path": "/queryData",
"queries": {
"subscriptions": "28e1e42a-4438-4c30-9a5f-7d7b488fd883",
"resourcegroups": "1-ad9bb353-playground-sandbox",
"resourcetype": "Log Analytics Workspace",
"resourcename": "LAworkspace",
"timerange": "Set in query"
}
}
},
"Create_CSV_table": {
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "Table",
"inputs": {
"from": "@outputs('Compose')",
"format": "CSV"
}
}
},
"outputs": {},
"parameters": {
"$connections": {
"type": "Object",
"defaultValue": {}
}
}
},
"parameters": {
"$connections": {
"type": "Object",
"value": {
"arm": {
"id": "/subscriptions/28e1e42a-4438-4c30-9a5f-7d7b488fd883/providers/Microsoft.Web/locations/southcentralus/managedApis/arm",
"connectionId": "/subscriptions/28e1e42a-4438-4c30-9a5f-7d7b488fd883/resourceGroups/1-ad9bb353-playground-sandbox/providers/Microsoft.Web/connections/arm",
"connectionName": "arm"
},
"outlook": {
"id": "/subscriptions/28e1e42a-4438-4c30-9a5f-7d7b488fd883/providers/Microsoft.Web/locations/southcentralus/managedApis/outlook",
"connectionId": "/subscriptions/28e1e42a-4438-4c30-9a5f-7d7b488fd883/resourceGroups/1-ad9bb353-playground-sandbox/providers/Microsoft.Web/connections/outlook",
"connectionName": "outlook"
},
"azuremonitorlogs-1": {
"id": "/subscriptions/28e1e42a-4438-4c30-9a5f-7d7b488fd883/providers/Microsoft.Web/locations/southcentralus/managedApis/azuremonitorlogs",
"connectionId": "/subscriptions/28e1e42a-4438-4c30-9a5f-7d7b488fd883/resourceGroups/1-ad9bb353-playground-sandbox/providers/Microsoft.Web/connections/azuremonitorlogs-1",
"connectionName": "azuremonitorlogs-1"
}
}
}
}
}
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
Sign in to answer