Evaluate

Evaluate

Given an expression evaluates the expression string. If performed on the data frame row, it evaluates via passing the row as a dictionary. If performed on a single value, it expects an additional argument 'key' to be used in the expression. @param expr: The expression to evaluate. @param key: An optional 'key' if evaluated on a single value instead of a dictionary.

To perform arithmetic operations on columns, evaluate function is used. This function works on data type with 'Numeric' columns (Float or Integer).

To perform arithmetic operations on columns, make sure the column's data type is set to 'Integer' (Numeric) or 'Float'. Additionally, column values should not contain NULL or Empty values.

Example 1:

Note - This example demos the use of the 'dm: map evaluate' function using expression to calculate total VM CPU count.

Step 1: Create an empty evaluate_example_1 using AIOps studio as shown in the below screenshot.

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment. ##### This pipeline creates a list of rows with vm_cpu_sockets along with vm_cpu_cores ##### for virtual machines using AIOps studio. ##### RDA function 'Evaluate' is used to demo this example that uses expression ##### to calculate total CPU allocated to each virtual machine. @dm:empty --> @dm:addrow vm_cpu_sockets = 1 & vm_cpu_cores = 3 & vm_id = 'vm1' --> @dm:addrow vm_cpu_sockets = 2 & vm_cpu_cores = 8 & vm_id = 'vm1' --> @dm:addrow vm_cpu_sockets = 1 & vm_cpu_cores = 2 & vm_id = 'vm1' --> @dm:addrow vm_cpu_sockets = 2 & vm_cpu_cores = 4 & vm_id = 'vm1' --> @dm:addrow vm_cpu_sockets = 2 & vm_cpu_cores = 8 & vm_id = 'vm1' --> @dm:addrow vm_cpu_sockets = 1 & vm_cpu_cores = 2 & vm_id = 'vm1' --> @dm:map to = 'vm_cpu_total' & func = 'evaluate' & expr = 'vm_cpu_sockets * vm_cpu_cores'

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

Step 5: RDA uses the evaluate function to calculate 'vm_cpu_total' (using expression as shown in the pipeline code snippet) as shown in the below screenshot.

Example 2:

Step 1: Create an empty evaluate_example_2 using AIOps studio as shown in the below screenshot.

Note - In the below example, vm_disk_size_bytes is a column that has disk capacity in bytes, using the 'evaluate' function, create a new column 'vm_disk_size_gb' and convert the bytes into GB.

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.

using the 'evaluate' function, create a new column 'vm_disk_size_gb' and convert the bytes into GB. ##### This pipeline creates a list of rows with vm_disk_size_bytes column that has ##### disk capacity in bytes. Pipeline uses 'evaluate' function and maps to new column ##### and convert the data into 'vm_disk_size_gb' ##### RDA function 'Evaluate' is used to demo this example that uses expression ##### to calculate 'vm_disk_size_gb' @dm:empty --> @dm:addrow vm_disk_size_bytes = 10737418240 & vm_id = 'vm1' --> @dm:addrow vm_disk_size_bytes = 322122542 & vm_id = 'vm2' --> @dm:addrow vm_disk_size_bytes = 21474836480 & vm_id = 'vm3' --> @dm:addrow vm_disk_size_bytes = 322122542 & vm_id = 'vm4' --> @dm:addrow vm_disk_size_bytes = 53687091200 & vm_id = 'vm5' --> @dm:map from = 'vm_disk_size_bytes' & to = 'vm_disk_size_in_gb' --> @dm:map attr = 'vm_disk_size_gb' & func = 'evaluate' & expr = 'vm_disk_size_gb/1024 /1024 /1024 '

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

Step 5: RDA uses the evaluate function to calculate 'vm_disk_size_gb' (using expression as shown in the pipeline code snippet) as shown in the below screenshot.

Similar to the above-provided examples, users can upload any files that require any mathematical calculation and use the 'evaluate' function/expression to print or store the data.

Last updated