Найдите высоконагруженные процессы ЦП в Azure Log Analytics

Найдите высоконагруженные процессы ЦП в Azure Log Analytics

Я создал следующее оповещение в Log Analytics. Оповещение предназначено для получения всех компьютеров, где _Total CPU usage превысил 90% за последние десять минут. Однако при запуске оповещения я получаю ошибку:

Оператор «join»: не удалось разрешить выражение таблицы или столбца с именем «FindCPU»

Может ли кто-нибудь подсказать, что может потребоваться для решения этой проблемы?

//Find Top processes utilizing CPU
// by finding the machine(s) using over 90% of CPU
// then finding the processes using the CPU
// also finding CPU count of the machines to find the actual percentage of CPU being used

//defining our CPU threshold
let CPUThreshold = 90;

//define time sample rate
let Time = 10m;

//define Count of processes to return
let Count = 5;

//Find instances of total cpu being used above 90% over the last 10 minutes
let TopCPU = Perf
| where TimeGenerated > now(-Time)
              and ObjectName == "Processor"
              and CounterName == "% Processor Time"
              and InstanceName == "_Total"
              and CounterValue > CPUThreshold
| project Computer, ObjectName
              , CounterName, CounterValue
              , TimeGenerated;
//end query

// find top Processes, excluding _Total and Idle instances, there may be other instances you want to exclude as well
let TopProcess = Perf
| where TimeGenerated > now(-Time)
               and CounterName == "% Processor Time"
               and InstanceName != "_Total"
               and InstanceName != "Idle"
| project Computer, ObjectName
              , CounterName, InstanceName
              , CounterValue, TimeGenerated;
// end query

// find CPU count for servers(s)
let FindCPU = Perf
| where TimeGenerated >= ago(1h)
| where ObjectName == "Processor"
              and CounterName == "% Processor Time"
              and InstanceName!="_Total"
| sort by InstanceName asc nulls first
| summarize CPUCount = dcount(InstanceName) by Computer;
// end query

//Join all 3 datasets together
FindCPU | join(TopCPU) on Computer 
| join(TopProcess)on Computer
| extend PercentProcessorUsed = CounterValue1 / CPUCount
| summarize avg(PercentProcessorUsed) by Computer, ObjectName
                  , CounterName, CPUCount 
                  , TotalCPU=CounterValue //rename CounterValue to TotalCPU 
                  , Process=ObjectName1 //rename ObjectName1 to Process 
                  , ProcessTime=CounterName1 //rename CounterName1 to ProcessTime 
                  , ProcessName=InstanceName //rename InstanceName to ProcessName 
                  , TimeGenerated
| where Process == "Process"
and avg_PercentProcessorUsed > 25 // only return processes that are using more than 25%
| top Count by avg_PercentProcessorUsed desc
| project Computer, CPUCount
                , ProcessName , avg_PercentProcessorUsed
                , TotalCPU, Process
                , ProcessTime, TimeGenerated

Спасибо

решение1

Запрос выполняется нормально (хотя кажется немного сложным для того, что вы пытаетесь сделать), однако вам нужно убедиться, что вы выбрали все запросы при его запуске.

По умолчанию, если курсор находится в конце всех запросов, Log Analytics выполнит только последний запрос, который, очевидно, выдаст ошибку, поскольку не сможет найти «FindCPU». Выделите все, затем запустите, и все заработает.

Связанный контент