use of org.elasticsearch.action.get.MultiGetResponse in project incubator-skywalking by apache.
the class CpuMetricEsUIDAO method getCPUTrend.
@Override
public List<Integer> getCPUTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
String tableName = TimePyramidTableNameBuilder.build(step, CpuMetricTable.TABLE);
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(durationPoints, new ElasticSearchClient.MultiGetRowHandler<DurationPoint>() {
@Override
public void accept(DurationPoint durationPoint) {
String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId;
this.add(tableName, CpuMetricTable.TABLE_TYPE, id);
}
});
List<Integer> cpuTrends = new LinkedList<>();
MultiGetResponse multiGetResponse = prepareMultiGet.get();
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
if (response.getResponse().isExists()) {
double cpuUsed = ((Number) response.getResponse().getSource().get(CpuMetricTable.COLUMN_USAGE_PERCENT)).doubleValue();
long times = ((Number) response.getResponse().getSource().get(CpuMetricTable.COLUMN_TIMES)).longValue();
cpuTrends.add((int) ((cpuUsed / times) * 100));
} else {
cpuTrends.add(0);
}
}
return cpuTrends;
}
use of org.elasticsearch.action.get.MultiGetResponse in project incubator-skywalking by apache.
the class GCMetricEsUIDAO method getGCTrend.
private List<Integer> getGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints, int gcPhrase) {
String tableName = TimePyramidTableNameBuilder.build(step, GCMetricTable.TABLE);
MultiGetRequestBuilder youngPrepareMultiGet = getClient().prepareMultiGet(durationPoints, new ElasticSearchClient.MultiGetRowHandler<DurationPoint>() {
@Override
public void accept(DurationPoint durationPoint) {
String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + gcPhrase;
add(tableName, GCMetricTable.TABLE_TYPE, id);
}
});
List<Integer> gcTrends = new LinkedList<>();
MultiGetResponse multiGetResponse = youngPrepareMultiGet.get();
for (MultiGetItemResponse itemResponse : multiGetResponse.getResponses()) {
if (itemResponse.getResponse().isExists()) {
long count = ((Number) itemResponse.getResponse().getSource().get(GCMetricTable.COLUMN_COUNT)).longValue();
long times = ((Number) itemResponse.getResponse().getSource().get(GCMetricTable.COLUMN_TIMES)).intValue();
gcTrends.add((int) (count / times));
} else {
gcTrends.add(0);
}
}
return gcTrends;
}
use of org.elasticsearch.action.get.MultiGetResponse in project incubator-skywalking by apache.
the class InstanceMetricEsUIDAO method getServerTPSTrend.
@Override
public List<Integer> getServerTPSTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE);
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(durationPoints, new ElasticSearchClient.MultiGetRowHandler<DurationPoint>() {
@Override
public void accept(DurationPoint durationPoint) {
String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue();
add(tableName, InstanceMetricTable.TABLE_TYPE, id);
}
});
List<Integer> throughputTrend = new LinkedList<>();
MultiGetResponse multiGetResponse = prepareMultiGet.get();
for (int i = 0; i < multiGetResponse.getResponses().length; i++) {
MultiGetItemResponse response = multiGetResponse.getResponses()[i];
if (response.getResponse().isExists()) {
long callTimes = ((Number) response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue();
throughputTrend.add((int) (callTimes / durationPoints.get(i).getSecondsBetween()));
} else {
throughputTrend.add(0);
}
}
return throughputTrend;
}
use of org.elasticsearch.action.get.MultiGetResponse in project incubator-skywalking by apache.
the class InstanceMetricEsUIDAO method getResponseTimeTrend.
@Override
public List<Integer> getResponseTimeTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE);
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(durationPoints, new ElasticSearchClient.MultiGetRowHandler<DurationPoint>() {
@Override
public void accept(DurationPoint durationPoint) {
String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue();
add(tableName, InstanceMetricTable.TABLE_TYPE, id);
}
});
List<Integer> responseTimeTrends = new LinkedList<>();
MultiGetResponse multiGetResponse = prepareMultiGet.get();
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
if (response.getResponse().isExists()) {
long callTimes = ((Number) response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue();
long errorCallTimes = ((Number) response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue();
long durationSum = ((Number) response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue();
long errorDurationSum = ((Number) response.getResponse().getSource().get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue();
long correctCallTimes = callTimes - errorCallTimes;
if (correctCallTimes != 0L) {
responseTimeTrends.add((int) ((durationSum - errorDurationSum) / correctCallTimes));
} else {
responseTimeTrends.add(0);
}
} else {
responseTimeTrends.add(0);
}
}
return responseTimeTrends;
}
use of org.elasticsearch.action.get.MultiGetResponse in project incubator-skywalking by apache.
the class ServiceMetricEsUIDAO method getServiceSLATrend.
@Override
public List<Integer> getServiceSLATrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE);
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(durationPoints, new ElasticSearchClient.MultiGetRowHandler<DurationPoint>() {
@Override
public void accept(DurationPoint durationPoint) {
String id = durationPoint.getPoint() + Const.ID_SPLIT + serviceId + Const.ID_SPLIT + MetricSource.Callee.getValue();
add(tableName, ServiceMetricTable.TABLE_TYPE, id);
}
});
List<Integer> trends = new LinkedList<>();
MultiGetResponse multiGetResponse = prepareMultiGet.get();
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
if (response.getResponse().isExists()) {
long calls = ((Number) response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue();
long errorCalls = ((Number) response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue();
trends.add((int) (((calls - errorCalls) / calls)) * 10000);
} else {
trends.add(10000);
}
}
return trends;
}
Aggregations