Displaying Current and Historical Apache Geode Statistics
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:
SystemAdminclass for historical statistics
- a custom Function for current statistics
This article describes both of these ways to display the statistics.
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
SystemAdmin 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
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.
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.
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:
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.
This article has shown several ways to display both current and historical statistics.