Search in sources :

Example 1 with NodeStats

use of org.sonar.server.es.response.NodeStats in project sonarqube by SonarSource.

the class ElasticSearchMetricTask method updateFileSystemMetrics.

private void updateFileSystemMetrics() {
    try {
        NodeStatsResponse nodeStatsResponse = esClient.nodesStats();
        if (nodeStatsResponse.getNodeStats().isEmpty()) {
            LOG.error("Failed to query ES status, no nodes stats returned by elasticsearch API");
        } else {
            for (NodeStats nodeStat : nodeStatsResponse.getNodeStats()) {
                serverMonitoringMetrics.setElasticSearchDiskSpaceFreeBytes(nodeStat.getName(), nodeStat.getDiskAvailableBytes());
                serverMonitoringMetrics.setElasticSearchDiskSpaceTotalBytes(nodeStat.getName(), nodeStat.getDiskTotalBytes());
            }
        }
    } catch (Exception e) {
        LOG.error("Failed to query ES status", e);
    }
}
Also used : NodeStatsResponse(org.sonar.server.es.response.NodeStatsResponse) NodeStats(org.sonar.server.es.response.NodeStats)

Aggregations

NodeStats (org.sonar.server.es.response.NodeStats)1 NodeStatsResponse (org.sonar.server.es.response.NodeStatsResponse)1