Search code examples
gridgainignite

How to output gridgain/ignite statistics to a file


How can i capture operation statistics such as puts/sec, gets/sec per server from ignite/gridgain.

Is it possible to output them into some file so that we can analyze them later?


Solution

  • Cache stats for a particular server node can be acquired with IgniteCache.metrics(ClusterGroup grp) method, like this:

    ClusterGroup grp = ignite.cluster().forNodeId(SERVER_NODE_ID);
    
    CacheMetrics metrics = cache.metrics(grp);
    
    long puts = metrics.getCachePuts();
    long gets = metrics.getCacheGets();
    

    You can periodically get them, calculate throughput values for this period of time (you will have to save the previous snapshot) and log to a file.

    Note that metrics are disabled by default for performance reasons. To enable them set statisticsEnabled flag on CacheConfiguration to true:

    cacheCfg.setStatisticsEnabled(true);
    

    Hope this helps.