Wednesday, October 24, 2018

How to do the math and add result into a new field in Kibana

This post is a quick note to let people want to do some math with multiple fields in Kibana and add result into a new field for visualize.

First of all go to Scripted Fields follow below screenshot. Use "add Scripted Field" to add new scripted filed.


Second, you can add your equation into script text box and chose collect parameter. Below is an example for sum of received bytes and sent bytes then divide by request time which is throughput in object storage.


Third, you will have a new filed call e.g. bytes_per_second while you try to create a visualize, then you can create the chart as below.























Last if you have grok pattern pipeline filter, you might try the calculation via ruby code, the example is as below.

ruby {
  code => "event.set('bytes_sum', event.get('bytes_recvd')+event.get('bytes_sent'))"
}
ruby {
  code => "event.set('bytes_per_second', event.get('bytes_sum')/event.get('request_time'))"
}
Hope this is helping :)




No comments:

Post a Comment