cfxdm - dm:groupby
Group rows by selected columns
Last updated
Group rows by selected columns
Last updated
dm:groupby: This cfxdm tag allows the user to group the data (by rows) based on selected columns using aggregate functions.
dm:groupby syntax:
columns (mandatory): Select one or more columns for grouping the data.
agg (optional):
count: It is applied by default when 'agg' is not specified. Supported on any value types (numeric or non-numeric values)
min: Supported on numeric values only
max: Supported on numeric values only
sum: Supported on numeric values only
In the below example, for a reference, we are going to use VMware vCenter as an extension to query the data from VMs tag and their disk size.
Enter the below command to select VMware vCenter VMs tag (*vcenter:vms). (In this example, vcenter name is used as a label to identify VMware vCenter extension and it's tags. The label is defined while adding the extension in cfxdx configuration file or through UI)
Example-1:
Get the VM's list from the above tag and select the below columns (as shown)
vm_name
disk_capacity_kb
bios_uuid
Pipe the data to dm:groupby tag to view the data grouped by VM Name.
Since 'agg' option is not specified within the dm:groupby tag, it applies agg function 'count' by default.
Example-2:
Continuing with above data, lets use agg function 'sum' to calculate total VM's disk size.
When agg function 'sum' is used, it automatically applies on all eligible columns (numerical values).