Hi,
I have metric beat configuration as below:
metricbeat.modules:
- module: system
metricsets: [cpu]
cpu.metrics: [percentages, normalized_percentages]
enabled: true
period: 20s
processes: ['.*']
fields_under_root: true
fields:
df_env: test
df_portal: xxx
df_application: metric
output.console:
pretty: true
When i see the code of beats/metricbeat/module/system/cpu/helper.go
//helper.go
calculate := func(field2 uint64, field1 uint64) float64 {
perc := 0.0
delta := int64(field2 - field1)
perc = float64(delta) / float64(allDelta)
return system.Round(perc*float64(NumCPU), .5, 4)
}
current.UserPercent = calculate(current.Cpu.User, last.Cpu.User)
current.SystemPercent = calculate(current.Cpu.Sys, last.Cpu.Sys)
Based on the above code I realized that while calculating percentage of fields it is using previous/last statistics like system.cpu.system.pct or system.cpu.user.pct fields. But what I actually need is the value**(%Cpu(s): 2.6 us)** which is displaying at top command as below
//command output when i run the top command.
$> top
Tasks: 239 total, 1 running, 238 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.6 us, 0.8 sy, 0.0 ni, 96.6 id, 0.0 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem: 24522424 total, 11352344 used, 13170080 free, 517500 buffers
KiB Swap: 3145724 total, 0 used, 3145724 free. 1916320 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6956 root 20 0 9231628 1.234g 34144 S 19.6 5.3 2677:23 java
31918 gdev 20 0 7798272 1.194g 16060 S 6.3 5.1 900:06.61 java
31959 gdev 20 0 7798272 1.181g 16044 S 5.3 5.0 914:09.06 java
32436 gdev 20 0 7798272 1.148g 16056 S 5.3 4.9 932:21.06 java
31877 gdev 20 0 7798272 1.183g 16032 S 5.0 5.1 902:22.92 java
3629 root 20 0 598044 30272 9348 S 2.3 0.1 272:01.77 BESClient
20392 gdev 20 0 123664 1744 1148 R 1.0 0.0 0:00.06 top
I need to create alert configuration when cpu system.cpu.system.pct > 80%.
But this value is always less than 1% as it is using last metrics.
Please help me how to retrieve above value . Thanks in advance