Displaying Current and Historical Apache Geode Statistics

Barry Oglesby
3 min readAug 9, 2021

Introduction

Apache Geode produces a variety of statistics in each member of the DistributedSystem. See my article here for the most useful ones.

There are several ways to display these statistics. The main way to display historical statistics (contained in a gfs archive file) is to use the Visual Statistics Display (vsd) tool. See the documentation here for additional details on vsd.

The main way to display current statistics (from the members in a running DistributedSystem) is to access the JMX MBeans, although not all statistics are available via JMX. See the documentation here for additional details on JMX. Any JMX tool (e.g. JConsole or VisualVM) can be used to access the MBeans.

Other ways to display both current and historical statistics include:

  • the SystemAdmin class for historical statistics
  • a custom Function for current statistics

This article describes both of these ways to display the statistics.

SystemAdmin Class

The SystemAdmin class can be used to show historical statistics from a gfs archive file.

The scripts described in this article are available here.

The systemadmin.sh Script

TheSystemAdmin class can be invoked using the systemadmin.sh script.

Several examples of using the systemadmin.sh script to display specific statistics are shown below.

To display the Old Gen heap memory statistics, execute the systemadmin.sh script like:

To display the garbage collection statistics, execute the systemadmin.sh script like:

To display all the distribution statistics, execute the systemadmin.sh script like:

To display a specific distribution statistic like replyWaitsInProgress, execute the systemadmin.sh script like:

To display all the operating system statistics, execute the systemadmin.sh script like:

To display a specific operating system statistic like freeMemory, execute the systemadmin.sh script like:

The displaystatistics.sh Script

All of the most useful statistics described in my article here can be displayed using the displaystatistics.sh script. Several of the functions from that script are shown below.

The get_stat function retrieves a statistic from the archive file.

The log_stat function shows the minimum, maximum and last values for a single statistic.

The log_stats function shows the minimum, maximum and last values for multiple statistics.

An example of using the displaystatistics.sh script is shown below.

Custom Function

The current value of any statistic in a running DistributedSystem member is available via Java API. A custom Function can be written that logs or retrieves the current value of any statistic.

All source code described in this article as well as an example usage is available here.

GetStatisticValueFunction

The GetStatisticValueFunction gets the value for a specific statistic.

It can be easily modified to return all the statistics values:

  • for a member
  • for a specific category (e.g. DistributionStats) in a member
  • for a specific category and instance (e.g. VMMemoryPoolStats — CMS Old Gen heap memory) in a member

The getStatisticValue method:

  • gets all the statistics for the input typeName (e.g. PartitionedRegionStats)
  • filters those for the input textId (e.g. /Trade)
  • returns the value for the first occurrence of the input statistic (e.g dataStoreEntryCount) or -1 if none

Its parameters are:

  • statisticsFactory — the InternalDistributedSystem instance
  • typeName — the statistic category
  • textId — the statistic instance
  • statistic — the desired statistic

To log the value of the CMS Old Gen heap memory currentUsedMemory statistic, execute the GetStatisticValueFunction like:

To log the value of the Trade region dataStoreBytesInUse statistic, execute the GetStatisticValueFunction like:

To log the value of the Trade region dataStoreEntryCount statistic, execute the GetStatisticValueFunction like:

LogAllStatisticValuesFunction

The LogAllStatisticValuesFunction logs all the statistic categories, instances and values.

It can easily be modified to log the statistics values for:

  • a specific category (e.g. DistributionStats)
  • a specific category and instance (e.g. VMMemoryPoolStats — CMS Old Gen heap memory)

The logAllStatistics method:

  • gets all the categories of statistics
  • sorts them by name
  • adds each category to the builder

The addStatistics method:

  • gets all the individual statistics for each category
  • sorts them by name
  • adds each statistic to the builder

The addStatistic method adds each statistic name and value to the builder.

A truncated example is shown below.

Conclusion

This article has shown several ways to display both current and historical statistics.

--

--