Unable to use if condition and calculate percenatge inside ruby code

Hello,
I am trying to first filter my data with only 3 KPI and only with hostname which domain is ".xxx.com".
then I want to calculate percentage from value_current and value_max columns.
filter{
mutate {convert => ["value_current", "integer"]}
mutate {convert => ["value_max", "integer"]}
if [kpi_name] in ["DiskFilesystemUtilization","CpuUtilization","MemoryUtilization"]{
if ("xxxx.com" in [host_name]){

``````                    ruby{

code => 'event.set("[Percentage]",[event.get("[value_current]") / event.get("[value_max]") * 100 ] )'
}
}
``````

}
}

This does not look at filter and sending the data as it is.

It works only if I put if condition in output section of logstash. but that takes lot of time to first calculate percentage and then filter with 3 KPI and host names.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8137967,"math_prob":0.8363971,"size":749,"snap":"2019-26-2019-30","text_gpt3_token_len":186,"char_repetition_ratio":0.10604027,"word_repetition_ratio":0.0,"special_character_ratio":0.28170896,"punctuation_ratio":0.1328125,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96334386,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-06-19T07:36:47Z\",\"WARC-Record-ID\":\"<urn:uuid:f437161e-277c-4f83-a3d4-19bac327046e>\",\"Content-Length\":\"15823\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6a457221-0a08-4a2e-b454-0b375336d046>\",\"WARC-Concurrent-To\":\"<urn:uuid:7cd5d94c-ee58-4468-8d84-741590b12299>\",\"WARC-IP-Address\":\"64.71.168.217\",\"WARC-Target-URI\":\"https://discuss.elastic.co/t/unable-to-use-if-condition-and-calculate-percenatge-inside-ruby-code/167586\",\"WARC-Payload-Digest\":\"sha1:P7Q2AC2J2CRULRRBUDNMRJ5VVWFFC7QD\",\"WARC-Block-Digest\":\"sha1:OWZ35XY6CIQTCYMXL5MUWWSPB4L6XNRN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-26/CC-MAIN-2019-26_segments_1560627998923.96_warc_CC-MAIN-20190619063711-20190619085711-00062.warc.gz\"}"}