Check out example codes for "summation of fields ruby filter". It will help you in understanding the concepts better.

Code Example 1

filter {
  ruby {
    code => "event['sum'] = event['number_field_1'] + event['number_field_2']"
  }
}

Learn ReactJs, React Native from akashmittal.com