public void setStatisticsLevel(Level level) {
        if (running && siddhiAppContext.getStatisticsManager() != null) {

            if (siddhiAppContext.getRootMetricsLevel().compareTo(level) == 0) {
                if (level == Level.OFF) {
                    log.info("Siddhi App '" + getName() + "' statistics reporting is already disabled!");
                } else if (level == Level.BASIC || level == Level.DETAIL) {
                    log.info("Siddhi App '" + getName() + "' statistics reporting is already in " + level + " level!");
                }
            } else {
                if (level == Level.OFF) {
                    memoryUsageTracker.disableMemoryUsageMetrics();
                    siddhiAppContext.setRootMetricsLevel(Level.OFF);
                    siddhiAppContext.getStatisticsManager().stopReporting();
                    log.info("Siddhi App '" + getName() + "' statistics reporting stopped!");
                } else {
                    if (siddhiAppContext.getRootMetricsLevel().compareTo(Level.OFF) == 0) {
                        siddhiAppContext.getStatisticsManager().startReporting();
                        log.debug("Siddhi App '" + getName() + "' statistics reporting started!");
                    }
                    if (level == Level.DETAIL) {
                        memoryUsageTracker.enableMemoryUsageMetrics();
                    }
                    siddhiAppContext.setRootMetricsLevel(level);
                    log.info("Siddhi App '" + getName() + "' statistics reporting changed to: " + level.toString());
                }
            }
        } else {
            if (running) {
                log.debug("Siddhi App '" + getName() + "' statistics reporting not changed, " +
                        "as app has not started running!");
            } else {
                log.debug("Siddhi App '" + getName() + "' statistics reporting not changed, as StatisticsManager" +
                        " is not defined!");
            }
        }
    }
To enable, disable and change Siddhi App statistics level on runtime.

@param level whether statistics is OFF, BASIC or DETAIL
modules/siddhi-core/src/main/java/io/siddhi/core/SiddhiAppRuntimeImpl.java