Search in sources :

Example 1 with AlarmTrend

use of org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend in project incubator-skywalking by apache.

the class AlarmService method getApplicationAlarmTrend.

public AlarmTrend getApplicationAlarmTrend(Step step, long startTimeBucket, long endTimeBucket, long startSecondTimeBucket, long endSecondTimeBucket) throws ParseException {
    List<Application> applications = instanceDAO.getApplications(startSecondTimeBucket, endSecondTimeBucket);
    List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
    List<IApplicationAlarmListUIDAO.AlarmTrend> alarmTrends = applicationAlarmListUIDAO.getAlarmedApplicationNum(step, startTimeBucket, endTimeBucket);
    Map<Long, Integer> trendsMap = new HashMap<>();
    alarmTrends.forEach(alarmTrend -> trendsMap.put(alarmTrend.getTimeBucket(), alarmTrend.getNumberOfApplication()));
    AlarmTrend alarmTrend = new AlarmTrend();
    durationPoints.forEach(durationPoint -> {
        if (applications.size() == 0) {
            alarmTrend.getNumOfAlarmRate().add(0);
        } else {
            alarmTrend.getNumOfAlarmRate().add((trendsMap.getOrDefault(durationPoint.getPoint(), 0) * 10000) / (applications.size()));
        }
    });
    return alarmTrend;
}
Also used : HashMap(java.util.HashMap) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint) Application(org.apache.skywalking.apm.collector.storage.ui.application.Application) AlarmTrend(org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend)

Aggregations

HashMap (java.util.HashMap)1 Application (org.apache.skywalking.apm.collector.storage.ui.application.Application)1 AlarmTrend (org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend)1 DurationPoint (org.apache.skywalking.apm.collector.storage.utils.DurationPoint)1