Sample code

To demonstrate the enhanced monitoring capabilities of the system, a sample implementation is provided to integrate the system with Graphite.

Important: The sample code is provided with the sole purpose of demonstrating the usage of the PLTStatisticsConsumer and IStatisticObject interfaces that are provided with the system.

The sample code is available in the following location: <INSTALL_DIR>/xapidocs/code_examples/graphite. You can tweak the code to suit your setup. The properties file referred in the code is available as graphite-exporter.properties.sample in the graphite folder.

Using the sample code

Perform the following steps to use the sample code:
  1. Set the value of yfs.plt.statistics.consumer.classname property to com.ibm.sterling.sample.graphite.StatisticalDataExporterForGraphite in the customer_overrides.properties file.
  2. Make a copy of the graphite-exporter.properties.sample file and rename the copy to graphite-exporter.properties.
  3. Set appropriate values in the graphite-exporter.properties file.
    Note: You can find comprehensive documentation for each property in the sample property file.
  4. Compile the java files provided in the sample code.
  5. Create a JAR file for the compiled files.
    Tip: Ensure that the graphite-exporter.properties file is present in the root folder of the JAR so that the file need not be included separately in the CLASSPATH.
  6. After creating the JAR file, include the new JAR file in the CLASSPATH environment variable by running the install3rdParty utility appropriately:
    • install3rdParty.sh on Unix or Linux
    • install3rdParty.cmd on Windows

    For more information, see Building other extensions.

  7. Build and deploy the EAR.
The system can publish different types of statistical data to Graphite. However, depending on the nature of the metrics, they are classified under the following categories using the graphite-exporter.properties file.
  • timers
  • counters
  • jvmstat

This classification is done to provide a predictable naming convention to the Graphite administrator. Graphite rules around storage and aggregation are set by matching regular expression patterns. The category prefix (controlled through graphite-exporter.properties) and the digest labels (controlled through sample code) give the Graphite administrator a predictable regular expression to manage such configuration.

Most of the metrics that you would like to monitor are already classified under a category. For example, the number of order lines shipped are classified under the counters category. Similarly, the response time of APIs are classified under the timers category. However, certain metric names may not be included in any of these categories. In such scenarios, the sample code automatically classifies them under the default category.

The statistics.category.default.prefix property determines the prefix for metrics published in the default category. We recommend that you monitor metrics published in the default category and include them under the appropriate category by modifying the graphite-exporter.properties appropriately.