Back to Geneos FAQ

How do I get the total number of rows returned in a rule? (rowcount)

Some plugins like FKM and SQL-Toolkit have built-in options to show counters as a headline cell. This article talks about the configuration to achieve the same for other plugins. We will create a new headline for the row count as an example.

Add Headline to Dataview In Geneos, the samplers can add custom table cells and headlines as placeholders to display additional data. In the sampler’s Advanced tab, please scroll down to the Dataviews option and select Add New to match the sampler’s dataview name (which should be the sampler’s Name in most cases). Geneos - How do I get the total number of rows returned in a rule? (rowcount) Then at the Additions button, it allows you to create headlines, columns and rows to the dataview. We will be creating a new headline named rowCount. Geneos - How do I get the total number of rows returned in a rule? (rowcount) Populate the Row Count After creating a new headline cell, you can configure a gateway rule to show the number of rows through the count() statistical function. Statistical functions help to make data more relevant by providing summary data rather than raw data. Geneos - How do I get the total number of rows returned in a rule? (rowcount) Below is the syntax for the value count function.

value count(wpath "myPathAlias" value)

“wpath” is a wildcard path and can resolve to one or many targets. The Path Alias should be configured at the rule’s Advanced tab. For example, we can use the following relative path to return the column named “myColumnName” from the same dataview as the Targets path.

../../rows/row/cell[(@column="myColumnName")]

As an example, the “My New Toolkit” dataview with the custom rowCount headline populated may look something like below: Screenshot Attached for reference are the configuration files for the above sampler and rule.

Additional Information 1. If you are doing a count of a column where the dataview may be empty, you can use +0 in the value setting in case the path evaluates to no cells. In the example:

value count(wpath "myPathAlias" value) + 0

The value will then always display at least a 0 rather than an empty cell. 2. In case you want to count the number of cells matching specific values, you can configure this in the Path Alias. As an example, below is the syntax of Path Alias to match empty cells (value field is set to match “BLANK_STRING”).

../../rows/row/cell[(@value="")][(@column="myColumnName")]

Please note using the count function with value will not count cells with blank values. You can instead count another property of the cell. For example, you can use the count function with the severity property. This will count the severity of the cells in that column even if the severity is undefined. As undefined is still considered a severity state. Below is the syntax you would use.

value count(wpath "myPathAlias" severity)

For more information on the different functions you can apply on rules, please refer to: Where can I see a list of functions the gateway rule engine supports

There is an undocumented syntax that users may see in their legacy configurations that short-cuts the Path Alias declarations. It uses two percent signs, like this: value count(%%../../../rows/row/cell[(@column=“myColumnName”)] value) We strongly advise not using this and updating configurations to use Path Aliases as soon as possible.

["Geneos"] ["Geneos > Gateway"] ["FAQ"]

Was this topic helpful?