Search in sources :

Example 1 with DurationPoint

use of org.apache.skywalking.apm.collector.storage.utils.DurationPoint 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;
}
Also used : MultiGetItemResponse(org.elasticsearch.action.get.MultiGetItemResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) LinkedList(java.util.LinkedList) MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) ElasticSearchClient(org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint)

Example 2 with DurationPoint

use of org.apache.skywalking.apm.collector.storage.utils.DurationPoint 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;
}
Also used : MultiGetItemResponse(org.elasticsearch.action.get.MultiGetItemResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) LinkedList(java.util.LinkedList) MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) ElasticSearchClient(org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint)

Example 3 with DurationPoint

use of org.apache.skywalking.apm.collector.storage.utils.DurationPoint 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;
}
Also used : MultiGetItemResponse(org.elasticsearch.action.get.MultiGetItemResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) LinkedList(java.util.LinkedList) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint) MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) ElasticSearchClient(org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint)

Example 4 with DurationPoint

use of org.apache.skywalking.apm.collector.storage.utils.DurationPoint 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;
}
Also used : MultiGetItemResponse(org.elasticsearch.action.get.MultiGetItemResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) LinkedList(java.util.LinkedList) MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) ElasticSearchClient(org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint)

Example 5 with DurationPoint

use of org.apache.skywalking.apm.collector.storage.utils.DurationPoint 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;
}
Also used : MultiGetItemResponse(org.elasticsearch.action.get.MultiGetItemResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) ElasticSearchClient(org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint)

Aggregations

DurationPoint (org.apache.skywalking.apm.collector.storage.utils.DurationPoint)17 ElasticSearchClient (org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient)8 MultiGetItemResponse (org.elasticsearch.action.get.MultiGetItemResponse)8 MultiGetRequestBuilder (org.elasticsearch.action.get.MultiGetRequestBuilder)8 MultiGetResponse (org.elasticsearch.action.get.MultiGetResponse)8 LinkedList (java.util.LinkedList)4 ResponseTimeTrend (org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend)2 ThroughputTrend (org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend)2 HashMap (java.util.HashMap)1 IMemoryMetricUIDAO (org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO)1 Application (org.apache.skywalking.apm.collector.storage.ui.application.Application)1 SLATrend (org.apache.skywalking.apm.collector.storage.ui.common.SLATrend)1 AlarmTrend (org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend)1 CPUTrend (org.apache.skywalking.apm.collector.storage.ui.server.CPUTrend)1 GCTrend (org.apache.skywalking.apm.collector.storage.ui.server.GCTrend)1 MemoryTrend (org.apache.skywalking.apm.collector.storage.ui.server.MemoryTrend)1