SOLVED
Home

useing let to create variable not working

DubG83
New Contributor

HI,

 

I'm new to Azure Log Analytics, so sorry or such a basic question.

 

From looking at this documentation https://docs.microsoft.com/en-us/azure/azure-monitor/log-query/advanced-query-writing

 

I should be able to create a variable using let

 

for example

let CPUThreshold = 5;
pref| where TimeGenerated > now(-30m)
and ObjectName == "Processor"
and CounterName == "% Processor Time"
and InstanceName == "_Total"
and CounterValue > CPUThreshold
| project Computer, ObjectName
, CounterName, CounterValue
, TimeGenerated;

 

I get this

'where' operator: Failed to resolve column or scalar expression named 'CPUThreshold'

 

I'm not sure what I'm doing wrong.

 

2 Replies
Solution
let CPUThreshold = 5;
Perf
| where TimeGenerated > now(-30m)  
    and ObjectName == "Processor"  
    and CounterName == "% Processor Time"  
    and InstanceName == "_Total"  
    and CounterValue > CPUThreshold
| project Computer, ObjectName  , CounterName, CounterValue  , TimeGenerated

I removed the final ";" and also you had spelled "Perf" wrongly.  This now works 

Thanks,

taking away the ; did it.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies