use of org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm in project incubator-skywalking by apache.
the class AlarmService method loadApplicationAlarmList.
public Alarm loadApplicationAlarmList(String keyword, Step step, long startTimeBucket, long endTimeBucket, int limit, int from) throws ParseException {
logger.debug("keyword: {}, startTimeBucket: {}, endTimeBucket: {}, limit: {}, from: {}", keyword, startTimeBucket, endTimeBucket, limit, from);
Alarm alarm = applicationAlarmUIDAO.loadAlarmList(keyword, startTimeBucket, endTimeBucket, limit, from);
List<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings = applicationMappingUIDAO.load(step, startTimeBucket, endTimeBucket);
Map<Integer, Integer> mappings = new HashMap<>();
applicationMappings.forEach(applicationMapping -> mappings.put(applicationMapping.getMappingApplicationId(), applicationMapping.getApplicationId()));
alarm.getItems().forEach(item -> {
String applicationCode = applicationCacheService.getApplicationById(mappings.getOrDefault(item.getId(), item.getId())).getApplicationCode();
switch(item.getCauseType()) {
case SLOW_RESPONSE:
item.setTitle("Application " + applicationCode + RESPONSE_TIME_ALARM);
break;
case LOW_SUCCESS_RATE:
item.setTitle("Application " + applicationCode + SUCCESS_RATE_ALARM);
break;
}
});
return alarm;
}
use of org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm in project incubator-skywalking by apache.
the class InstanceAlarmEsUIDAO method loadAlarmList.
@Override
public Alarm loadAlarmList(String keyword, long startTimeBucket, long endTimeBucket, int limit, int from) throws ParseException {
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceAlarmTable.TABLE);
searchRequestBuilder.setTypes(InstanceAlarmTable.TABLE_TYPE);
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must().add(QueryBuilders.rangeQuery(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket));
if (StringUtils.isNotEmpty(keyword)) {
boolQueryBuilder.must().add(QueryBuilders.matchQuery(InstanceAlarmTable.COLUMN_ALARM_CONTENT, keyword));
}
searchRequestBuilder.setQuery(boolQueryBuilder);
searchRequestBuilder.setSize(limit);
searchRequestBuilder.setFrom(from);
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
SearchHit[] searchHits = searchResponse.getHits().getHits();
Alarm alarm = new Alarm();
alarm.setTotal((int) searchResponse.getHits().getTotalHits());
for (SearchHit searchHit : searchHits) {
AlarmItem alarmItem = new AlarmItem();
alarmItem.setId(((Number) searchHit.getSource().get(InstanceAlarmTable.COLUMN_INSTANCE_ID)).intValue());
alarmItem.setTitle((String) searchHit.getSource().get(InstanceAlarmTable.COLUMN_ALARM_CONTENT));
alarmItem.setContent((String) searchHit.getSource().get(InstanceAlarmTable.COLUMN_ALARM_CONTENT));
long lastTimeBucket = ((Number) searchHit.getSource().get(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET)).longValue();
alarmItem.setStartTime(TimeBucketUtils.INSTANCE.formatMinuteTimeBucket(lastTimeBucket));
alarmItem.setAlarmType(AlarmType.SERVER);
int alarmType = ((Number) searchHit.getSource().get(InstanceAlarmTable.COLUMN_ALARM_TYPE)).intValue();
if (org.apache.skywalking.apm.collector.storage.table.alarm.AlarmType.SLOW_RTT.getValue() == alarmType) {
alarmItem.setCauseType(CauseType.SLOW_RESPONSE);
} else if (org.apache.skywalking.apm.collector.storage.table.alarm.AlarmType.ERROR_RATE.getValue() == alarmType) {
alarmItem.setCauseType(CauseType.LOW_SUCCESS_RATE);
}
alarm.getItems().add(alarmItem);
}
return alarm;
}
Aggregations