Creating a delta filter in logstash using global variable


(jayesh) #1

I was trying to replicate cpu usage graph in jconsole.It needs to substract prvious values from the present values.So I am trying to use @@prevprocesscpuload as a global variable.But it is not working please help
filter{
if [metric_path] == "com.hcl.jmxInput.ProcessCpuLoad.ProcessCpuLoad"
{

ruby{
init=>"@@prevprocesscpuload=-1"
code=>'
if(@@prevprocesscpuload==-1)
delta=0
else
delta=event.get(['metric_value_number'])-@@prevprocesscpuload
end
event.set(['@version'], delta )

@@prevprocesscpuload=event.get(['metric_value_number'])
'
}

}
}


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.