Hi, thanks for feedback. However, it does not work from my side. This is an alert rule "Log Search"
The "raw outputs" I got from "When a HTTP request is received" is the following.
The error message with your JSON schema is similar:
ExpressionEvaluationFailed. The execution of template action 'For_each' failed: the result of the evaluation of 'foreach' expression '@triggerBody()?['alertContext']?['SearchResults']?['tables']' is of type 'Null'. The result must be a valid array.
Any idea? Thanks.
{
"headers": {
"Connection": "Keep-Alive",
"Expect": "100-continue",
"Host": "prod-14.westeurope.logic.azure.com",
"User-Agent": "IcMBroadcaster/1.0",
"X-CorrelationContext": "RkkKACgAAAACAAAAEAAkvoQ1bLeWTLKmQhysx+9iAQAQAJ5ckB5eil9DkO1o/15fijM=",
"Content-Length": "6894",
"Content-Type": "application/json; charset=utf-8"
},
"body": {
"schemaId": "azureMonitorCommonAlertSchema",
"data": {
"essentials": {
"alertId": "/subscriptions/76ccbf2e-48d1-4c0c-b233-7949ec3ced34/providers/Microsoft.AlertsManagement/alerts/e5bf61b5-1b6c-2dfc-e73f-bdd042d7000e",
"alertRule": "radiflow - iCEN login failure",
"severity": "Sev1",
"signalType": "Log",
"monitorCondition": "Fired",
"monitoringService": "Log Alerts V2",
"alertTargetIDs": [
"/subscriptions/76ccbf2e-48d1-4c0c-b233-7949ec3ced34/resourcegroups/rg-euw-pwhirn/providers/microsoft.operationalinsights/workspaces/law-euw-pwhirn-01"
],
"configurationItems": [
"/subscriptions/xxxxxxxxxxxxxx/resourceGroups/rg-euw-PWhirn/providers/Microsoft.OperationalInsights/workspaces/law-euw-PWhirn-01"
],
"originAlertId": "b9a75ee3-8901-4589-99d8-bbd891ea15ba",
"firedDateTime": "2023-09-29T14:55:48.0621211Z",
"description": "[AssignmentGroup]FJ-OTMMS-SOC[/AssignmentGroup][Impact]2[/Impact][Urgency]2[/Urgency][Category]Cyber Attack[/Category][SubCategory]app-detected[/Subcategory]",
"essentialsVersion": "1.0",
"alertContextVersion": "1.0"
},
"alertContext": {
"properties": {},
"conditionType": "LogQueryCriteria",
"condition": {
"windowSize": "PT5M",
"allOf": [
{
"searchQuery": "Syslog\n| where Facility contains \"auth\" and SeverityLevel contains \"notice\"\n| extend Message=\"User Activity\"\n| extend RankId=\"Medium\"\n| extend Cat=\"'Cyber'\"\n| extend isidName=\"iCEN\"\n| extend Source= replace('IP=', '', replace('\"', '', extract(@\"IP=(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})\", 0, SyslogMessage)))\n| extend Destination=replace('username=', '', replace('\"', '', extract(@\"username=(\\w+)\", 0, SyslogMessage)))\n| extend IdNum=tostring(ProcessID)\n| extend FullLog=tostring(SyslogMessage)\n| where SyslogMessage contains \"Failure\" and SyslogMessage contains \"Log in\" or SyslogMessage contains \"message repeated\"\n| project TimeGenerated, IdNum, SeverityLevel, Cat, isidName, Message, RankId, Source, Destination, FullLog",
"metricMeasureColumn": null,
"targetResourceTypes": "['Microsoft.OperationalInsights/workspaces']",
"operator": "GreaterThan",
"threshold": "0",
"timeAggregation": "Count",
"dimensions": [],
"metricValue": 2,
"failingPeriods": {
"numberOfEvaluationPeriods": 1,
"minFailingPeriodsToAlert": 1
},
"linkToSearchResultsUI": "https://portal.azure.com#@b22f84df-fe30-4f4c-bc2b-37c24bb4f665/blade/Microsoft_Azure_Monitoring_Logs/LogsBlade/source/Alerts.EmailLinks/scope/%7B%22resources%22%3A%5B%7B%22resourceId%22%3A%22%2Fsubscriptions%2F76ccbf2e-48d1-4c0c-b233-7949ec3ced34%2FresourceGroups%2Frg-euw-PWhirn%2Fproviders%2FMicrosoft.OperationalInsights%2Fworkspaces%2Flaw-euw-PWhirn-01%22%7D%5D%7D/q/eJyFkjFPwzAQhXd%2BheUlibAQiNkSqKUoUltVBLYuxjmlB4ld2U5LBfx3LiVN3aHqECV69%2FnOL%2B%2BKna9tdfXDtitwwCZKY41hx7Q1QaHxjKs2rDhTpmQFbMBRcUrvOiKMDaiBUxP4CkDgDLxXFUj%2B5sGxRx1wQ8ci4EWZz7yUfAYltk1UGKkgeTLavYNLIhk9lnPVUEccPc2jQmFbp0EyB%2BtaaUiTfCETwRJ6Bon3Ah1xSof0gROULsvvO3H%2Fu7w5%2B5FxwW4FK%2FZ%2FqLeUZdlx%2BBh8QKMCWiOHaS1ZNt1VL19jQNPl9vritLyct40M1geHpkoXzmqi8nGETNq6ntrqCJ12G1I%2BkaMgJwrr1kGf9hmIBjA0nFl3Fml6hbyDClB2ga2d%2FQAd2Cs28AwGXFcQ%2F67IdrxaolsDMYQuDvsk%2Br0hfB%2B7iBMQB%2Fd%2F/prettify/1/timespan/2023-09-29T14%3a43%3a16.0000000Z%2f2023-09-29T14%3a48%3a16.0000000Z",
"linkToFilteredSearchResultsUI": "https://portal.azure.com#@b22f84df-fe30-4f4c-bc2b-37c24bb4f665/blade/Microsoft_Azure_Monitoring_Logs/LogsBlade/source/Alerts.EmailLinks/scope/%7B%22resources%22%3A%5B%7B%22resourceId%22%3A%22%2Fsubscriptions%2F76ccbf2e-48d1-4c0c-b233-7949ec3ced34%2FresourceGroups%2Frg-euw-PWhirn%2Fproviders%2FMicrosoft.OperationalInsights%2Fworkspaces%2Flaw-euw-PWhirn-01%22%7D%5D%7D/q/eJyFkjFPwzAQhXd%2BheUlibAQiNkSqKUoUltVBLYuxjmlB4ld2U5LBfx3LiVN3aHqECV69%2FnOL%2B%2BKna9tdfXDtitwwCZKY41hx7Q1QaHxjKs2rDhTpmQFbMBRcUrvOiKMDaiBUxP4CkDgDLxXFUj%2B5sGxRx1wQ8ci4EWZz7yUfAYltk1UGKkgeTLavYNLIhk9lnPVUEccPc2jQmFbp0EyB%2BtaaUiTfCETwRJ6Bon3Ah1xSof0gROULsvvO3H%2Fu7w5%2B5FxwW4FK%2FZ%2FqLeUZdlx%2BBh8QKMCWiOHaS1ZNt1VL19jQNPl9vritLyct40M1geHpkoXzmqi8nGETNq6ntrqCJ12G1I%2BkaMgJwrr1kGf9hmIBjA0nFl3Fml6hbyDClB2ga2d%2FQAd2Cs28AwGXFcQ%2F67IdrxaolsDMYQuDvsk%2Br0hfB%2B7iBMQB%2Fd%2F/prettify/1/timespan/2023-09-29T14%3a43%3a16.0000000Z%2f2023-09-29T14%3a48%3a16.0000000Z",
"linkToSearchResultsAPI": "https://api.loganalytics.io/v1/workspaces/224f9021-cc22-4f52-a933-adde0cc2b022/query?query=Syslog%0A%7C%20where%20Facility%20contains%20%22auth%22%20and%20SeverityLevel%20contains%20%22notice%22%0A%7C%20extend%20Message%3D%22User%20Activity%22%0A%7C%20extend%20RankId%3D%22Medium%22%0A%7C%20extend%20Cat%3D%22%27Cyber%27%22%0A%7C%20extend%20isidName%3D%22iCEN%22%0A%7C%20extend%20Source%3D%20replace%28%27IP%3D%27%2C%20%27%27%2C%20replace%28%27%22%27%2C%20%27%27%2C%20extract%28%40%22IP%3D%28%5Cd%7B1%2C3%7D%5C.%5Cd%7B1%2C3%7D%5C.%5Cd%7B1%2C3%7D%5C.%5Cd%7B1%2C3%7D%29%22%2C%200%2C%20SyslogMessage%29%29%29%0A%7C%20extend%20Destination%3Dreplace%28%27username%3D%27%2C%20%27%27%2C%20replace%28%27%22%27%2C%20%27%27%2C%20extract%28%40%22username%3D%28%5Cw%2B%29%22%2C%200%2C%20SyslogMessage%29%29%29%0A%7C%20extend%20IdNum%3Dtostring%28ProcessID%29%0A%7C%20extend%20FullLog%3Dtostring%28SyslogMessage%29%0A%7C%20where%20SyslogMessage%20contains%20%22Failure%22%20and%20SyslogMessage%20contains%20%22Log%20in%22%20or%20SyslogMessage%20contains%20%22message%20repeated%22%0A%7C%20project%20TimeGenerated%2C%20IdNum%2C%20SeverityLevel%2C%20Cat%2C%20isidName%2C%20Message%2C%20RankId%2C%20Source%2C%20Destination%2C%20FullLog×pan=2023-09-29T14%3a43%3a16.0000000Z%2f2023-09-29T14%3a48%3a16.0000000Z",
"linkToFilteredSearchResultsAPI": "https://api.loganalytics.io/v1/workspaces/224f9021-cc22-4f52-a933-adde0cc2b022/query?query=Syslog%0A%7C%20where%20Facility%20contains%20%22auth%22%20and%20SeverityLevel%20contains%20%22notice%22%0A%7C%20extend%20Message%3D%22User%20Activity%22%0A%7C%20extend%20RankId%3D%22Medium%22%0A%7C%20extend%20Cat%3D%22%27Cyber%27%22%0A%7C%20extend%20isidName%3D%22iCEN%22%0A%7C%20extend%20Source%3D%20replace%28%27IP%3D%27%2C%20%27%27%2C%20replace%28%27%22%27%2C%20%27%27%2C%20extract%28%40%22IP%3D%28%5Cd%7B1%2C3%7D%5C.%5Cd%7B1%2C3%7D%5C.%5Cd%7B1%2C3%7D%5C.%5Cd%7B1%2C3%7D%29%22%2C%200%2C%20SyslogMessage%29%29%29%0A%7C%20extend%20Destination%3Dreplace%28%27username%3D%27%2C%20%27%27%2C%20replace%28%27%22%27%2C%20%27%27%2C%20extract%28%40%22username%3D%28%5Cw%2B%29%22%2C%200%2C%20SyslogMessage%29%29%29%0A%7C%20extend%20IdNum%3Dtostring%28ProcessID%29%0A%7C%20extend%20FullLog%3Dtostring%28SyslogMessage%29%0A%7C%20where%20SyslogMessage%20contains%20%22Failure%22%20and%20SyslogMessage%20contains%20%22Log%20in%22%20or%20SyslogMessage%20contains%20%22message%20repeated%22%0A%7C%20project%20TimeGenerated%2C%20IdNum%2C%20SeverityLevel%2C%20Cat%2C%20isidName%2C%20Message%2C%20RankId%2C%20Source%2C%20Destination%2C%20FullLog×pan=2023-09-29T14%3a43%3a16.0000000Z%2f2023-09-29T14%3a48%3a16.0000000Z"
}
],
"windowStartTime": "2023-09-29T14:43:16Z",
"windowEndTime": "2023-09-29T14:48:16Z"
}
},
"customProperties": {}
}
}
}