'Azure monitor Log Analytics Schedule query rule

I am setting an alert rule on my Linux VMs to create alert when its file partitions over 80% utilized from Powershell script. Bug getting error:- Please can you advise how this can be resolved?

Body: { "error": { "code": "BadRequest", "message": "The query of a metric measurement alert rule must include an AggregatedValue column of a numeric type" } }

Here is Script:- $source = New-AzScheduledQueryRuleSource -Query 'Perf | where TimeGenerated > ago(15m)| where Computer contains "az" and CounterPath contains "(/)" and CounterName contains "% Used Space"| where CounterValue >= 80 | project SmartsVM = Computer,TimeGenerated, Alerts_Title = strcat("Smarts Linux VM File Parition (",InstanceName ,") is over 80% used"),CounterValue | summarize a= avg(CounterValue) by bin(TimeGenerated,30m) , SmartsVM, Alerts_Title | project a, SmartsVM, Alerts_Title' -DataSourceId "/subscriptions/xxxxxxx" -QueryType Number

$schedule = New-AzScheduledQueryRuleSchedule -FrequencyInMinutes 5 -TimeWindowInMinutes 2880

$metricTrigger = New-AzScheduledQueryRuleLogMetricTrigger -ThresholdOperator "GreaterThan" -Threshold 1 -MetricTriggerType Total -MetricColumn 4

$triggerCondition = New-AzScheduledQueryRuleTriggerCondition -ThresholdOperator "GreaterThan" -Threshold 80 -MetricTrigger $metricTrigger

$aznsActionGroup = New-AzScheduledQueryRuleAznsActionGroup -ActionGroup "/subscriptions/xxxx" -EmailSubject "Smarts Linux VM Parition Threshold Alerting" -CustomWebhookPayload "{ "alert":"#alertrulename", "IncludeSearchResults":true }"

$alertingAction = New-AzScheduledQueryRuleAlertingAction -AznsAction $aznsActionGroup -Severity "3" -Trigger $triggerCondition

New-AzScheduledQueryRule -ResourceGroupName "xxx" -Location xx-Action $alertingAction -Enabled $true -Description "Smarts Linux VM Parition is 80% over utilized" -Schedule $schedule -Source $source -Name "Smarts Linux VM Parition Threshold Alerting"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source