org.elasticsearch.action.admin.cluster.node.stats.NodeStats Java Examples
The following examples show how to use
org.elasticsearch.action.admin.cluster.node.stats.NodeStats.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticSearchHealthCheckJob.java From soundwave with Apache License 2.0 | 6 votes |
private void logNodeStats(Map<String, NodeStats> statsMap) { Map<String, String> tags = new HashMap<>(); for (NodeStats stat : statsMap.values()) { tags.put("esnode", stat.getHostname()); Stats.setGauge(StatsUtil.getStatsName("eshealth", "heapUsedPercent", tags), stat.getJvm().getMem().getHeapUsedPrecent()); Stats.setGauge(StatsUtil.getStatsName("eshealth", "heapMaxMB", tags), stat.getJvm().getMem().getHeapMax().getMbFrac()); Stats.setGauge(StatsUtil.getStatsName("eshealth", "heapUsedMB", tags), stat.getJvm().getMem().getHeapUsed().getMbFrac()); Stats.setGauge(StatsUtil.getStatsName("eshealth", "upMinutes", tags), stat.getJvm().getUptime().getMinutesFrac()); Stats.setGauge(StatsUtil.getStatsName("eshealth", "docCount", tags), stat.getIndices().getDocs().getCount()); } }
Example #2
Source File: MockInternalClusterInfoService.java From crate with Apache License 2.0 | 6 votes |
private List<NodeStats> adjustNodesStats(List<NodeStats> nodesStats) { BiFunction<DiscoveryNode, FsInfo.Path, FsInfo.Path> diskUsageFunction = this.diskUsageFunction; if (diskUsageFunction == null) { return nodesStats; } return nodesStats.stream().map(nodeStats -> { final DiscoveryNode discoveryNode = nodeStats.getNode(); final FsInfo oldFsInfo = nodeStats.getFs(); return new NodeStats( discoveryNode, nodeStats.getTimestamp(), new FsInfo( oldFsInfo.getTimestamp(), oldFsInfo.getIoStats(), StreamSupport.stream(oldFsInfo.spliterator(), false) .map(fsInfoPath -> diskUsageFunction.apply(discoveryNode, fsInfoPath)) .toArray(FsInfo.Path[]::new) )); }).collect(Collectors.toList()); }
Example #3
Source File: CircuitBreakerTest.java From siren-join with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testCircuitBreakerOnCoordinator() throws Exception { // Update circuit breaker settings Settings settings = settingsBuilder() .put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, "60b") .build(); assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); SearchRequestBuilder searchRequest = new CoordinateSearchRequestBuilder(client()).setIndices("index1").setQuery( QueryBuilders.filterJoin("foreign_key").indices("index2").types("type").path("id").query( boolQuery().filter(termQuery("tag", "aaa")) ).termsEncoding(TermsByQueryRequest.TermsEncoding.LONG) ); assertFailures(searchRequest, RestStatus.INTERNAL_SERVER_ERROR, containsString("Data too large, data for [<terms_set>] would be larger than limit of [60/60b]")); NodesStatsResponse stats = client().admin().cluster().prepareNodesStats().setBreaker(true).get(); int breaks = 0; for (NodeStats stat : stats.getNodes()) { CircuitBreakerStats breakerStats = stat.getBreaker().getStats(CircuitBreaker.REQUEST); breaks += breakerStats.getTrippedCount(); } assertThat(breaks, greaterThanOrEqualTo(1)); }
Example #4
Source File: CircuitBreakerTest.java From siren-join with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testCircuitBreakerOnShard() throws Exception { // Update circuit breaker settings Settings settings = settingsBuilder() .put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, "8b") .build(); assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); SearchRequestBuilder searchRequest = new CoordinateSearchRequestBuilder(client()).setIndices("index1").setQuery( QueryBuilders.filterJoin("foreign_key").indices("index2").types("type").path("id").query( boolQuery().filter(termQuery("tag", "aaa")) ).termsEncoding(TermsByQueryRequest.TermsEncoding.LONG) ); assertFailures(searchRequest, RestStatus.INTERNAL_SERVER_ERROR, containsString("Data too large, data for [<terms_set>] would be larger than limit of [8/8b]")); NodesStatsResponse stats = client().admin().cluster().prepareNodesStats().setBreaker(true).get(); int breaks = 0; for (NodeStats stat : stats.getNodes()) { CircuitBreakerStats breakerStats = stat.getBreaker().getStats(CircuitBreaker.REQUEST); breaks += breakerStats.getTrippedCount(); } assertThat(breaks, greaterThanOrEqualTo(1)); }
Example #5
Source File: PrometheusMetricsCollector.java From elasticsearch-prometheus-exporter with Apache License 2.0 | 6 votes |
public void updateMetrics(ClusterHealthResponse clusterHealthResponse, NodeStats nodeStats, IndicesStatsResponse indicesStats, ClusterStatsData clusterStatsData) { Summary.Timer timer = catalog.startSummaryTimer("metrics_generate_time_seconds"); updateClusterMetrics(clusterHealthResponse); updateNodeMetrics(nodeStats); updateIndicesMetrics(nodeStats.getIndices()); if (isPrometheusIndices) { updatePerIndexMetrics(clusterHealthResponse, indicesStats); } updateTransportMetrics(nodeStats.getTransport()); updateHTTPMetrics(nodeStats.getHttp()); updateThreadPoolMetrics(nodeStats.getThreadPool()); updateIngestMetrics(nodeStats.getIngestStats()); updateCircuitBreakersMetrics(nodeStats.getBreaker()); updateScriptMetrics(nodeStats.getScriptStats()); updateProcessMetrics(nodeStats.getProcess()); updateJVMMetrics(nodeStats.getJvm()); updateOsMetrics(nodeStats.getOs()); updateFsMetrics(nodeStats.getFs()); if (isPrometheusClusterSettings) { updateESSettings(clusterStatsData); } timer.observeDuration(); }
Example #6
Source File: PrometheusMetricsCollector.java From elasticsearch-prometheus-exporter with Apache License 2.0 | 6 votes |
private void updateNodeMetrics(NodeStats ns) { if (ns != null) { // Plugins can introduce custom node roles from 7.3.0: https://github.com/elastic/elasticsearch/pull/43175 // TODO(lukas-vlcek): List of node roles can not be static but needs to be created dynamically. Map<String, Integer> roles = new HashMap<>(); roles.put("master", 0); roles.put("data", 0); roles.put("ingest", 0); for (DiscoveryNodeRole r : ns.getNode().getRoles()) { roles.put(r.roleName(), 1); } for (String k : roles.keySet()) { catalog.setNodeGauge("node_role_bool", roles.get(k), k); } } }
Example #7
Source File: ClusterStatsNodes.java From Elasticsearch with Apache License 2.0 | 6 votes |
public void addNodeStats(NodeStats nodeStats) { if (nodeStats.getProcess() == null) { return; } count++; if (nodeStats.getProcess().getCpu() != null) { cpuPercent += nodeStats.getProcess().getCpu().getPercent(); } long fd = nodeStats.getProcess().getOpenFileDescriptors(); if (fd > 0) { // fd can be -1 if not supported on platform totalOpenFileDescriptors += fd; } // we still do min max calc on -1, so we'll have an indication of it not being supported on one of the nodes. minOpenFileDescriptors = Math.min(minOpenFileDescriptors, fd); maxOpenFileDescriptors = Math.max(maxOpenFileDescriptors, fd); }
Example #8
Source File: NodeService.java From Elasticsearch with Apache License 2.0 | 6 votes |
public NodeStats stats(CommonStatsFlags indices, boolean os, boolean process, boolean jvm, boolean threadPool, boolean fs, boolean transport, boolean http, boolean circuitBreaker, boolean script) { // for indices stats we want to include previous allocated shards stats as well (it will // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats) return new NodeStats(discovery.localNode(), System.currentTimeMillis(), indices.anySet() ? indicesService.stats(true, indices) : null, os ? monitorService.osService().stats() : null, process ? monitorService.processService().stats() : null, jvm ? monitorService.jvmService().stats() : null, threadPool ? this.threadPool.stats() : null, fs ? monitorService.fsService().stats() : null, transport ? transportService.stats() : null, http ? (httpServer == null ? null : httpServer.stats()) : null, circuitBreaker ? circuitBreakerService.stats() : null, script ? scriptService.stats() : null ); }
Example #9
Source File: TransportClusterStatsAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeRequest) { NodeInfo nodeInfo = nodeService.info(false, true, false, true, false, true, false, true); NodeStats nodeStats = nodeService.stats(CommonStatsFlags.NONE, true, true, true, false, true, false, false, false, false); List<ShardStats> shardsStats = new ArrayList<>(); for (IndexService indexService : indicesService) { for (IndexShard indexShard : indexService) { if (indexShard.routingEntry() != null && indexShard.routingEntry().active()) { // only report on fully started shards shardsStats.add(new ShardStats(indexShard.routingEntry(), indexShard.shardPath(), new CommonStats(indexShard, SHARD_STATS_FLAGS), indexShard.commitStats())); } } } ClusterHealthStatus clusterStatus = null; if (clusterService.state().nodes().localNodeMaster()) { clusterStatus = new ClusterStateHealth(clusterService.state()).getStatus(); } return new ClusterStatsNodeResponse(nodeInfo.getNode(), clusterStatus, nodeInfo, nodeStats, shardsStats.toArray(new ShardStats[shardsStats.size()])); }
Example #10
Source File: NodeService.java From Elasticsearch with Apache License 2.0 | 6 votes |
public NodeStats stats() throws IOException { // for indices stats we want to include previous allocated shards stats as well (it will // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats) return new NodeStats(discovery.localNode(), System.currentTimeMillis(), indicesService.stats(true), monitorService.osService().stats(), monitorService.processService().stats(), monitorService.jvmService().stats(), threadPool.stats(), monitorService.fsService().stats(), transportService.stats(), httpServer == null ? null : httpServer.stats(), circuitBreakerService.stats(), scriptService.stats() ); }
Example #11
Source File: ClusterStatsNodes.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void addNodeInfoStats(NodeInfo nodeInfo, NodeStats nodeStats) { availableProcessors += nodeInfo.getOs().getAvailableProcessors(); allocatedProcessors += nodeInfo.getOs().getAllocatedProcessors(); if (nodeInfo.getOs().getName() != null) { names.addTo(nodeInfo.getOs().getName(), 1); } if (nodeStats.getOs() != null && nodeStats.getOs().getMem() != null) { availableMemory += nodeStats.getOs().getMem().getFree().bytes(); } }
Example #12
Source File: GraphiteReporter.java From elasticsearch-graphite-plugin with Do What The F*ck You Want To Public License | 5 votes |
public GraphiteReporter(String host, int port, String prefix, NodeIndicesStats nodeIndicesStats, List<IndexShard> indexShards, NodeStats nodeStats, Pattern graphiteInclusionRegex, Pattern graphiteExclusionRegex) { this.host = host; this.port = port; this.prefix = prefix; this.indexShards = indexShards; this.nodeStats = nodeStats; this.graphiteInclusionRegex = graphiteInclusionRegex; this.graphiteExclusionRegex = graphiteExclusionRegex; this.timestamp = Long.toString(System.currentTimeMillis() / 1000); this.nodeIndicesStats = nodeIndicesStats; }
Example #13
Source File: GraphiteService.java From elasticsearch-graphite-plugin with Do What The F*ck You Want To Public License | 5 votes |
public void run() { while (!closed) { DiscoveryNode node = clusterService.localNode(); boolean isClusterStarted = clusterService.lifecycleState().equals(Lifecycle.State.STARTED); if (isClusterStarted && node != null && node.isMasterNode()) { NodeIndicesStats nodeIndicesStats = indicesService.stats(false); CommonStatsFlags commonStatsFlags = new CommonStatsFlags().clear(); NodeStats nodeStats = nodeService.stats(commonStatsFlags, true, true, true, true, true, true, true, true, true); List<IndexShard> indexShards = getIndexShards(indicesService); GraphiteReporter graphiteReporter = new GraphiteReporter(graphiteHost, graphitePort, graphitePrefix, nodeIndicesStats, indexShards, nodeStats, graphiteInclusionRegex, graphiteExclusionRegex); graphiteReporter.run(); } else { if (node != null) { logger.debug("[{}]/[{}] is not master node, not triggering update", node.getId(), node.getName()); } } try { Thread.sleep(graphiteRefreshInternal.millis()); } catch (InterruptedException e1) { continue; } } }
Example #14
Source File: TermsByQueryBenchmark.java From siren-join with GNU Affero General Public License v3.0 | 5 votes |
public void memStatus() throws IOException { NodeStats[] nodeStats = client.admin().cluster().prepareNodesStats() .setJvm(true).setIndices(true).setTransport(true) .execute().actionGet().getNodes(); log("==== MEMORY ===="); log("Committed heap size: [0]=" + nodeStats[0].getJvm().getMem().getHeapCommitted() + ", [1]=" + nodeStats[1].getJvm().getMem().getHeapCommitted()); log("Used heap size: [0]=" + nodeStats[0].getJvm().getMem().getHeapUsed() + ", [1]=" + nodeStats[1].getJvm().getMem().getHeapUsed()); log("FieldData cache size: [0]=" + nodeStats[0].getIndices().getFieldData().getMemorySize() + ", [1]=" + nodeStats[1].getIndices().getFieldData().getMemorySize()); log("Query cache size: [0]=" + nodeStats[0].getIndices().getQueryCache().getMemorySize() + ", [1]=" + nodeStats[1].getIndices().getQueryCache().getMemorySize()); log(""); log("==== NETWORK ===="); log("Transport: [0]=" + nodeStats[0].getTransport().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS).string() + ", [1]=" + nodeStats[1].getTransport().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS).string()); log(""); }
Example #15
Source File: FilterJoinBenchmark.java From siren-join with GNU Affero General Public License v3.0 | 5 votes |
public void memStatus() throws IOException { NodeStats[] nodeStats = client.admin().cluster().prepareNodesStats() .setJvm(true).setIndices(true).setTransport(true) .execute().actionGet().getNodes(); log("==== MEMORY ===="); log("Committed heap size: [0]=" + nodeStats[0].getJvm().getMem().getHeapCommitted() + ", [1]=" + nodeStats[1].getJvm().getMem().getHeapCommitted()); log("Used heap size: [0]=" + nodeStats[0].getJvm().getMem().getHeapUsed() + ", [1]=" + nodeStats[1].getJvm().getMem().getHeapUsed()); log("FieldData cache size: [0]=" + nodeStats[0].getIndices().getFieldData().getMemorySize() + ", [1]=" + nodeStats[1].getIndices().getFieldData().getMemorySize()); log("Query cache size: [0]=" + nodeStats[0].getIndices().getQueryCache().getMemorySize() + ", [1]=" + nodeStats[1].getIndices().getQueryCache().getMemorySize()); log(""); log("==== NETWORK ===="); log("Transport: [0]=" + nodeStats[0].getTransport().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS).string() + ", [1]=" + nodeStats[1].getTransport().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS).string()); log(""); }
Example #16
Source File: Elasticsearch5SearchIndexTest.java From vertexium with Apache License 2.0 | 5 votes |
private long getNumQueries() { NodesStatsResponse nodeStats = NodesStatsAction.INSTANCE.newRequestBuilder(elasticsearchResource.getClient()).get(); List<NodeStats> nodes = nodeStats.getNodes(); assertEquals(1, nodes.size()); SearchStats searchStats = nodes.get(0).getIndices().getSearch(); return searchStats.getTotal().getQueryCount(); }
Example #17
Source File: Elasticsearch7SearchIndexTest.java From vertexium with Apache License 2.0 | 5 votes |
private long getNumQueries() { NodesStatsResponse nodeStats = new NodesStatsRequestBuilder(elasticsearchResource.getClient(), NodesStatsAction.INSTANCE).get(); List<NodeStats> nodes = nodeStats.getNodes(); assertEquals(1, nodes.size()); SearchStats searchStats = nodes.get(0).getIndices().getSearch(); return searchStats.getTotal().getQueryCount(); }
Example #18
Source File: NodePrometheusMetricsResponse.java From elasticsearch-prometheus-exporter with Apache License 2.0 | 5 votes |
public NodePrometheusMetricsResponse(ClusterHealthResponse clusterHealth, NodeStats nodesStats, @Nullable IndicesStatsResponse indicesStats, @Nullable ClusterStateResponse clusterStateResponse, Settings settings, ClusterSettings clusterSettings) { this.clusterHealth = clusterHealth; this.nodeStats = nodesStats; this.indicesStats = indicesStats; if (clusterStateResponse != null) { this.clusterStatsData = new ClusterStatsData(clusterStateResponse, settings, clusterSettings); } }
Example #19
Source File: NodePrometheusMetricsResponse.java From elasticsearch-prometheus-exporter with Apache License 2.0 | 5 votes |
public NodePrometheusMetricsResponse(StreamInput in) throws IOException { super(in); clusterHealth = new ClusterHealthResponse(in); nodeStats = new NodeStats(in); indicesStats = PackageAccessHelper.createIndicesStatsResponse(in); clusterStatsData = new ClusterStatsData(in); }
Example #20
Source File: ClusterStatsNodeResponse.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); clusterStatus = null; if (in.readBoolean()) { clusterStatus = ClusterHealthStatus.fromValue(in.readByte()); } this.nodeInfo = NodeInfo.readNodeInfo(in); this.nodeStats = NodeStats.readNodeStats(in); int size = in.readVInt(); shardsStats = new ShardStats[size]; for (size--; size >= 0; size--) { shardsStats[size] = ShardStats.readShardStats(in); } }
Example #21
Source File: ClusterStatsNodeResponse.java From Elasticsearch with Apache License 2.0 | 5 votes |
public ClusterStatsNodeResponse(DiscoveryNode node, @Nullable ClusterHealthStatus clusterStatus, NodeInfo nodeInfo, NodeStats nodeStats, ShardStats[] shardsStats) { super(node); this.nodeInfo = nodeInfo; this.nodeStats = nodeStats; this.shardsStats = shardsStats; this.clusterStatus = clusterStatus; }
Example #22
Source File: ClusterStatsNodes.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void addNodeInfoStats(NodeInfo nodeInfo, NodeStats nodeStats) { versions.addTo(new JvmVersion(nodeInfo.getJvm()), 1); org.elasticsearch.monitor.jvm.JvmStats js = nodeStats.getJvm(); if (js == null) { return; } if (js.getThreads() != null) { threads += js.getThreads().getCount(); } maxUptime = Math.max(maxUptime, js.getUptime().millis()); if (js.getMem() != null) { heapUsed += js.getMem().getHeapUsed().bytes(); heapMax += js.getMem().getHeapMax().bytes(); } }
Example #23
Source File: OsStatsMonitor.java From Raigad with Apache License 2.0 | 4 votes |
@Override public void execute() throws Exception { // If Elasticsearch is started then only start the monitoring if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) { String exceptionMsg = "Elasticsearch is not yet started, check back again later"; logger.info(exceptionMsg); return; } OsStatsBean osStatsBean = new OsStatsBean(); try { NodesStatsResponse nodesStatsResponse = ElasticsearchTransportClient.getNodesStatsResponse(config); NodeStats nodeStats = null; List<NodeStats> nodeStatsList = nodesStatsResponse.getNodes(); if (nodeStatsList.size() > 0) { nodeStats = nodeStatsList.get(0); } if (nodeStats == null) { logger.info("OS stats is not available (node stats is not available)"); return; } OsStats osStats = nodeStats.getOs(); if (osStats == null) { logger.info("OS stats is not available"); return; } //Memory osStatsBean.freeInBytes = osStats.getMem().getFree().getBytes(); osStatsBean.usedInBytes = osStats.getMem().getUsed().getBytes(); osStatsBean.actualFreeInBytes = osStats.getMem().getFree().getBytes(); osStatsBean.actualUsedInBytes = osStats.getMem().getUsed().getBytes(); osStatsBean.freePercent = osStats.getMem().getFreePercent(); osStatsBean.usedPercent = osStats.getMem().getUsedPercent(); //CPU osStatsBean.cpuSys = osStats.getCpu().getPercent(); osStatsBean.cpuUser = 0; osStatsBean.cpuIdle = 0; osStatsBean.cpuStolen = 0; //Swap osStatsBean.swapFreeInBytes = osStats.getSwap().getFree().getBytes(); osStatsBean.swapUsedInBytes = osStats.getSwap().getUsed().getBytes(); //Uptime osStatsBean.uptimeInMillis = 0; //Timestamp osStatsBean.osTimestamp = osStats.getTimestamp(); } catch (Exception e) { logger.warn("Failed to load OS stats data", e); } osStatsReporter.osStatsBean.set(osStatsBean); }
Example #24
Source File: EsInstanceStore.java From soundwave with Apache License 2.0 | 4 votes |
public Map<String, NodeStats> getNodesStats() throws Exception { NodesStatsResponse nodesStats = esClient.admin().cluster().prepareNodesStats().all().get(); return nodesStats.getNodesMap(); }
Example #25
Source File: TransportStatsMonitor.java From Raigad with Apache License 2.0 | 4 votes |
@Override public void execute() throws Exception { // If Elasticsearch is started then only start the monitoring if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) { String exceptionMsg = "Elasticsearch is not yet started, check back again later"; logger.info(exceptionMsg); return; } TransportStatsBean transportStatsBean = new TransportStatsBean(); try { NodesStatsResponse nodesStatsResponse = ElasticsearchTransportClient.getNodesStatsResponse(config); NodeStats nodeStats = null; List<NodeStats> nodeStatsList = nodesStatsResponse.getNodes(); if (nodeStatsList.size() > 0) { nodeStats = nodeStatsList.get(0); } if (nodeStats == null) { logger.info("Transport stats are not available (node stats is not available)"); return; } TransportStats transportStats = nodeStats.getTransport(); if (transportStats == null) { logger.info("Transport stats are not available"); return; } transportStatsBean.serverOpen = transportStats.getServerOpen(); transportStatsBean.rxCount = transportStats.getRxCount(); transportStatsBean.rxSize = transportStats.getRxSize().getBytes(); transportStatsBean.rxSizeDelta = transportStats.getRxSize().getBytes() - transportStatsBean.rxSize; transportStatsBean.txCount = transportStats.getTxCount(); transportStatsBean.txSize = transportStats.getTxSize().getBytes(); transportStatsBean.txSizeDelta = transportStats.getTxSize().getBytes() - transportStatsBean.txSize; } catch (Exception e) { logger.warn("Failed to load transport stats data", e); } transportStatsReporter.transportStatsBean.set(transportStatsBean); }
Example #26
Source File: FsStatsMonitor.java From Raigad with Apache License 2.0 | 4 votes |
@Override public void execute() throws Exception { // Only start monitoring if Elasticsearch is started if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) { String exceptionMsg = "Elasticsearch is not yet started, check back again later"; logger.info(exceptionMsg); return; } FsStatsBean fsStatsBean = new FsStatsBean(); try { NodesStatsResponse nodesStatsResponse = ElasticsearchTransportClient.getNodesStatsResponse(config); NodeStats nodeStats = null; List<NodeStats> nodeStatsList = nodesStatsResponse.getNodes(); if (nodeStatsList.size() > 0) { nodeStats = nodeStatsList.get(0); } if (nodeStats == null) { logger.info("File system info is not available (node stats are not available)"); return; } FsInfo fsInfo = nodeStats.getFs(); if (fsInfo == null) { logger.info("File system info is not available"); return; } fsStatsBean.total = fsInfo.getTotal().getTotal().getBytes(); fsStatsBean.free = fsInfo.getTotal().getFree().getBytes(); fsStatsBean.available = fsInfo.getTotal().getAvailable().getBytes(); fsStatsBean.availableDiskPercent = (fsStatsBean.available * 100) / fsStatsBean.total; } catch (Exception e) { logger.warn("Failed to load file system stats data", e); } fsStatsReporter.fsStatsBean.set(fsStatsBean); }
Example #27
Source File: ThreadPoolStatsMonitor.java From Raigad with Apache License 2.0 | 4 votes |
@Override public void execute() throws Exception { // If Elasticsearch is started then only start the monitoring if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) { String exceptionMsg = "Elasticsearch is not yet started, check back again later"; logger.info(exceptionMsg); return; } ThreadPoolStatsBean threadPoolStatsBean = new ThreadPoolStatsBean(); try { NodesStatsResponse nodesStatsResponse = ElasticsearchTransportClient.getNodesStatsResponse(config); NodeStats nodeStats = null; List<NodeStats> nodeStatsList = nodesStatsResponse.getNodes(); if (nodeStatsList.size() > 0) { nodeStats = nodeStatsList.get(0); } if (nodeStats == null) { logger.info("Thread pool stats are not available (node stats is not available)"); return; } ThreadPoolStats threadPoolStats = nodeStats.getThreadPool(); if (threadPoolStats == null) { logger.info("Thread pool stats are not available"); return; } Iterator<ThreadPoolStats.Stats> threadPoolStatsIterator = threadPoolStats.iterator(); while (threadPoolStatsIterator.hasNext()) { ThreadPoolStats.Stats stat = threadPoolStatsIterator.next(); if (stat.getName().equals("index")) { threadPoolStatsBean.indexThreads = stat.getThreads(); threadPoolStatsBean.indexQueue = stat.getQueue(); threadPoolStatsBean.indexActive = stat.getActive(); threadPoolStatsBean.indexRejected = stat.getRejected(); threadPoolStatsBean.indexLargest = stat.getLargest(); threadPoolStatsBean.indexCompleted = stat.getCompleted(); } else if (stat.getName().equals("get")) { threadPoolStatsBean.getThreads = stat.getThreads(); threadPoolStatsBean.getQueue = stat.getQueue(); threadPoolStatsBean.getActive = stat.getActive(); threadPoolStatsBean.getRejected = stat.getRejected(); threadPoolStatsBean.getLargest = stat.getLargest(); threadPoolStatsBean.getCompleted = stat.getCompleted(); } else if (stat.getName().equals("search")) { threadPoolStatsBean.searchThreads = stat.getThreads(); threadPoolStatsBean.searchQueue = stat.getQueue(); threadPoolStatsBean.searchActive = stat.getActive(); threadPoolStatsBean.searchRejected = stat.getRejected(); threadPoolStatsBean.searchLargest = stat.getLargest(); threadPoolStatsBean.searchCompleted = stat.getCompleted(); } else if (stat.getName().equals("bulk")) { threadPoolStatsBean.bulkThreads = stat.getThreads(); threadPoolStatsBean.bulkQueue = stat.getQueue(); threadPoolStatsBean.bulkActive = stat.getActive(); threadPoolStatsBean.bulkRejected = stat.getRejected(); threadPoolStatsBean.bulkLargest = stat.getLargest(); threadPoolStatsBean.bulkCompleted = stat.getCompleted(); } } } catch (Exception e) { logger.warn("Failed to load thread pool stats data", e); } tpStatsReporter.threadPoolBean.set(threadPoolStatsBean); }
Example #28
Source File: ElasticSearchService.java From sakai with Educational Community License v2.0 | 4 votes |
protected SearchStatus newSearchStatusWrapper(SearchStatus toWrap, NodesStatsResponse nodesStatsResponse) { return new SearchStatus() { @Override public String getLastLoad() { return toWrap.getLastLoad(); } @Override public String getLoadTime() { return toWrap.getLoadTime(); } @Override public String getCurrentWorker() { return getNodeName(); } @Override public String getCurrentWorkerETC() { return getNodeName(); } @Override public List getWorkerNodes() { List<Object[]> workers = new ArrayList(); for (NodeStats nodeStat : nodesStatsResponse.getNodes()) { if (nodeStat.getNode().isDataNode()) { workers.add(new Object[]{nodeStat.getNode().getName() + "(" + nodeStat.getHostname() + ")", null, // No way to get a meaningful "start" time per node, so now just set a null Date. // Historically used an index builder starttime, which was always meaningless in this // context since it's always going to refer to the local node. And we now have // multiple index builders, so it's doubly meaningless. Historical comment below // hints at same problem with the results of 'getStatus()' //TODO will show same status for each node, need to deal with that getStatus()}); } } return workers; } @Override public String getNDocuments() { return toWrap.getNDocuments(); } @Override public String getPDocuments() { return toWrap.getPDocuments(); } }; }
Example #29
Source File: InternalClusterInfoService.java From crate with Apache License 2.0 | 4 votes |
static void fillDiskUsagePerNode(Logger logger, List<NodeStats> nodeStatsArray, ImmutableOpenMap.Builder<String, DiskUsage> newLeastAvaiableUsages, ImmutableOpenMap.Builder<String, DiskUsage> newMostAvaiableUsages) { boolean traceEnabled = logger.isTraceEnabled(); for (NodeStats nodeStats : nodeStatsArray) { if (nodeStats.getFs() == null) { logger.warn("Unable to retrieve node FS stats for {}", nodeStats.getNode().getName()); } else { FsInfo.Path leastAvailablePath = null; FsInfo.Path mostAvailablePath = null; for (FsInfo.Path info : nodeStats.getFs()) { if (leastAvailablePath == null) { assert mostAvailablePath == null; mostAvailablePath = leastAvailablePath = info; } else if (leastAvailablePath.getAvailable().getBytes() > info.getAvailable().getBytes()) { leastAvailablePath = info; } else if (mostAvailablePath.getAvailable().getBytes() < info.getAvailable().getBytes()) { mostAvailablePath = info; } } String nodeId = nodeStats.getNode().getId(); String nodeName = nodeStats.getNode().getName(); if (traceEnabled) { logger.trace( "node: [{}], most available: total disk: {}, available disk: {} / least available: total disk: {}, available disk: {}", nodeId, mostAvailablePath.getTotal(), leastAvailablePath.getAvailable(), leastAvailablePath.getTotal(), leastAvailablePath.getAvailable()); } if (leastAvailablePath.getTotal().getBytes() < 0) { if (traceEnabled) { logger.trace( "node: [{}] least available path has less than 0 total bytes of disk [{}], skipping", nodeId, leastAvailablePath.getTotal().getBytes()); } } else { newLeastAvaiableUsages.put( nodeId, new DiskUsage( nodeId, nodeName, leastAvailablePath.getPath(), leastAvailablePath.getTotal().getBytes(), leastAvailablePath.getAvailable().getBytes())); } if (mostAvailablePath.getTotal().getBytes() < 0) { if (traceEnabled) { logger.trace( "node: [{}] most available path has less than 0 total bytes of disk [{}], skipping", nodeId, mostAvailablePath.getTotal().getBytes()); } } else { newMostAvaiableUsages.put( nodeId, new DiskUsage( nodeId, nodeName, mostAvailablePath.getPath(), mostAvailablePath.getTotal().getBytes(), mostAvailablePath.getAvailable().getBytes())); } } } }
Example #30
Source File: NodeService.java From crate with Apache License 2.0 | 4 votes |
public NodeStats stats() { return new NodeStats(transportService.getLocalNode(), System.currentTimeMillis(), monitorService.fsService().stats()); }