Merge pull request #810 from peng-yongsheng/feature/loadAlarmList
Provide the loadAlarmList query.
This commit is contained in:
commit
7cbed1bb62
|
|
@ -18,8 +18,10 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.core.util;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -59,6 +61,13 @@ public enum TimeBucketUtils {
|
|||
return Long.valueOf(timeStr);
|
||||
}
|
||||
|
||||
public String formatMinuteTimeBucket(long minuteTimeBucket) throws ParseException {
|
||||
SimpleDateFormat minuteDateFormat = new SimpleDateFormat("yyyyMMddHHmm");
|
||||
Date date = minuteDateFormat.parse(String.valueOf(minuteTimeBucket));
|
||||
SimpleDateFormat parsedMinuteDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
return parsedMinuteDateFormat.format(date);
|
||||
}
|
||||
|
||||
public long minuteToHour(long minuteBucket) {
|
||||
return minuteBucket / 100;
|
||||
}
|
||||
|
|
@ -86,8 +95,4 @@ public enum TimeBucketUtils {
|
|||
public long secondToMonth(long secondBucket) {
|
||||
return secondBucket / 100 / 100 / 100 / 100;
|
||||
}
|
||||
|
||||
public enum TimeBucketType {
|
||||
SECOND, MINUTE, HOUR, DAY, MONTH
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceDay
|
|||
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceHourMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
|
||||
|
|
@ -112,6 +113,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceM
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO;
|
||||
|
|
@ -119,6 +121,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO;
|
||||
|
|
@ -257,6 +260,10 @@ public class StorageModule extends Module {
|
|||
classes.add(ISegmentDurationUIDAO.class);
|
||||
classes.add(ISegmentUIDAO.class);
|
||||
classes.add(IServiceReferenceMetricUIDAO.class);
|
||||
|
||||
classes.add(IApplicationAlarmUIDAO.class);
|
||||
classes.add(IInstanceAlarmUIDAO.class);
|
||||
classes.add(IServiceAlarmUIDAO.class);
|
||||
}
|
||||
|
||||
private void addAlarmDAO(List<Class> classes) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.dao.ui;
|
||||
|
||||
import java.text.ParseException;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IApplicationAlarmUIDAO extends DAO {
|
||||
|
||||
Alarm loadAlarmList(String keyword, long start, long end, int limit, int from) throws ParseException;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.dao.ui;
|
||||
|
||||
import java.text.ParseException;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IInstanceAlarmUIDAO extends DAO {
|
||||
|
||||
Alarm loadAlarmList(String keyword, long start, long end, int limit, int from) throws ParseException;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.dao.ui;
|
||||
|
||||
import java.text.ParseException;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IServiceAlarmUIDAO extends DAO {
|
||||
|
||||
Alarm loadAlarmList(String keyword, long start, long end, int limit, int from) throws ParseException;
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.storage.ui.alarm;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -27,6 +28,10 @@ public class Alarm {
|
|||
private List<AlarmItem> items;
|
||||
private int total;
|
||||
|
||||
public Alarm() {
|
||||
this.items = new LinkedList<>();
|
||||
}
|
||||
|
||||
public List<AlarmItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,52 @@ public class AlarmItem {
|
|||
private String startTime;
|
||||
private AlarmType alarmType;
|
||||
private CauseType causeType;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public AlarmType getAlarmType() {
|
||||
return alarmType;
|
||||
}
|
||||
|
||||
public void setAlarmType(AlarmType alarmType) {
|
||||
this.alarmType = alarmType;
|
||||
}
|
||||
|
||||
public CauseType getCauseType() {
|
||||
return causeType;
|
||||
}
|
||||
|
||||
public void setCauseType(CauseType causeType) {
|
||||
this.causeType = causeType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceDay
|
|||
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceHourMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
|
||||
|
|
@ -121,6 +122,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceM
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO;
|
||||
|
|
@ -128,6 +130,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO;
|
||||
|
|
@ -216,6 +219,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceD
|
|||
import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceHourMetricEsPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceMinuteMetricEsPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceMonthMetricEsPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationAlarmEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationComponentEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationMappingEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationMetricEsUIDAO;
|
||||
|
|
@ -223,6 +227,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationReferenc
|
|||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.CpuMetricEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.GCMetricEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.GlobalTraceEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.InstanceAlarmEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.InstanceEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.InstanceMetricEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.MemoryMetricEsUIDAO;
|
||||
|
|
@ -230,6 +235,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.ui.MemoryPoolMetricEsU
|
|||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.NetworkAddressEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentDurationEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceAlarmEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceMetricEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceNameServiceEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceReferenceEsMetricUIDAO;
|
||||
|
|
@ -420,6 +426,10 @@ public class StorageModuleEsProvider extends ModuleProvider {
|
|||
this.registerServiceImplementation(ISegmentDurationUIDAO.class, new SegmentDurationEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IServiceReferenceMetricUIDAO.class, new ServiceReferenceEsMetricUIDAO(elasticSearchClient));
|
||||
|
||||
this.registerServiceImplementation(IApplicationAlarmUIDAO.class, new ApplicationAlarmEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IInstanceAlarmUIDAO.class, new InstanceAlarmEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IServiceAlarmUIDAO.class, new ServiceAlarmEsUIDAO(elasticSearchClient));
|
||||
}
|
||||
|
||||
private void registerAlarmDAO() throws ServiceNotProvidedException {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.es.dao.ui;
|
||||
|
||||
import java.text.ParseException;
|
||||
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.apm.collector.core.util.StringUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmTable;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmItem;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmType;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.CauseType;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationAlarmEsUIDAO extends EsDAO implements IApplicationAlarmUIDAO {
|
||||
|
||||
public ApplicationAlarmEsUIDAO(ElasticSearchClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alarm loadAlarmList(String keyword, long start, long end, int limit, int from) throws ParseException {
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ApplicationAlarmTable.TABLE);
|
||||
searchRequestBuilder.setTypes(ApplicationAlarmTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
boolQueryBuilder.must().add(QueryBuilders.rangeQuery(ApplicationAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(start).lte(end));
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
boolQueryBuilder.must().add(QueryBuilders.matchQuery(ApplicationAlarmTable.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(searchHit.getId());
|
||||
alarmItem.setTitle((String)searchHit.getSource().get(ApplicationAlarmTable.COLUMN_ALARM_CONTENT));
|
||||
alarmItem.setContent((String)searchHit.getSource().get(ApplicationAlarmTable.COLUMN_ALARM_CONTENT));
|
||||
|
||||
long lastTimeBucket = ((Number)searchHit.getSource().get(ApplicationAlarmTable.COLUMN_LAST_TIME_BUCKET)).longValue();
|
||||
alarmItem.setStartTime(TimeBucketUtils.INSTANCE.formatMinuteTimeBucket(lastTimeBucket));
|
||||
alarmItem.setAlarmType(AlarmType.APPLICATION);
|
||||
|
||||
int alarmType = ((Number)searchHit.getSource().get(ApplicationAlarmTable.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.es.dao.ui;
|
||||
|
||||
import java.text.ParseException;
|
||||
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.apm.collector.core.util.StringUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmTable;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmItem;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmType;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.CauseType;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceAlarmEsUIDAO extends EsDAO implements IInstanceAlarmUIDAO {
|
||||
|
||||
public InstanceAlarmEsUIDAO(ElasticSearchClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alarm loadAlarmList(String keyword, long start, long end, 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(start).lte(end));
|
||||
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(searchHit.getId());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.es.dao.ui;
|
||||
|
||||
import java.text.ParseException;
|
||||
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.apm.collector.core.util.StringUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.alarm.ServiceAlarmTable;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmItem;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmType;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.CauseType;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceAlarmEsUIDAO extends EsDAO implements IServiceAlarmUIDAO {
|
||||
|
||||
public ServiceAlarmEsUIDAO(ElasticSearchClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alarm loadAlarmList(String keyword, long start, long end, int limit, int from) throws ParseException {
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ServiceAlarmTable.TABLE);
|
||||
searchRequestBuilder.setTypes(ServiceAlarmTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
boolQueryBuilder.must().add(QueryBuilders.rangeQuery(ServiceAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(start).lte(end));
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
boolQueryBuilder.must().add(QueryBuilders.matchQuery(ServiceAlarmTable.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(searchHit.getId());
|
||||
alarmItem.setTitle((String)searchHit.getSource().get(ServiceAlarmTable.COLUMN_ALARM_CONTENT));
|
||||
alarmItem.setContent((String)searchHit.getSource().get(ServiceAlarmTable.COLUMN_ALARM_CONTENT));
|
||||
|
||||
long lastTimeBucket = ((Number)searchHit.getSource().get(ServiceAlarmTable.COLUMN_LAST_TIME_BUCKET)).longValue();
|
||||
alarmItem.setStartTime(TimeBucketUtils.INSTANCE.formatMinuteTimeBucket(lastTimeBucket));
|
||||
alarmItem.setAlarmType(AlarmType.SERVICE);
|
||||
|
||||
int alarmType = ((Number)searchHit.getSource().get(ServiceAlarmTable.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -110,6 +110,7 @@ import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceDay
|
|||
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceHourMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
|
||||
|
|
@ -117,6 +118,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceM
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO;
|
||||
|
|
@ -124,6 +126,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO;
|
||||
|
|
@ -212,6 +215,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.srmp.ServiceReferenceD
|
|||
import org.apache.skywalking.apm.collector.storage.h2.dao.srmp.ServiceReferenceHourMetricH2PersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.srmp.ServiceReferenceMinuteMetricH2PersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.srmp.ServiceReferenceMonthMetricH2PersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationAlarmH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationComponentH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationMappingH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationMetricH2UIDAO;
|
||||
|
|
@ -219,6 +223,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationReferenc
|
|||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.CpuMetricH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.GCMetricH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.GlobalTraceH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.InstanceAlarmH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.InstanceH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.InstanceMetricH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.MemoryMetricH2UIDAO;
|
||||
|
|
@ -226,6 +231,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ui.MemoryPoolMetricH2U
|
|||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.NetworkAddressH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentDurationH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceAlarmH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceMetricH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceNameServiceH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceReferenceH2MetricUIDAO;
|
||||
|
|
@ -396,6 +402,10 @@ public class StorageModuleH2Provider extends ModuleProvider {
|
|||
this.registerServiceImplementation(ISegmentDurationUIDAO.class, new SegmentDurationH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IServiceReferenceMetricUIDAO.class, new ServiceReferenceH2MetricUIDAO(h2Client));
|
||||
|
||||
this.registerServiceImplementation(IApplicationAlarmUIDAO.class, new ApplicationAlarmH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IInstanceAlarmUIDAO.class, new InstanceAlarmH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IServiceAlarmUIDAO.class, new ServiceAlarmH2UIDAO(h2Client));
|
||||
}
|
||||
|
||||
private void registerAlarmDAO() throws ServiceNotProvidedException {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.dao.ui;
|
||||
|
||||
import java.text.ParseException;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationAlarmH2UIDAO extends H2DAO implements IApplicationAlarmUIDAO {
|
||||
|
||||
public ApplicationAlarmH2UIDAO(H2Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alarm loadAlarmList(String keyword, long start, long end, int limit, int from) throws ParseException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.dao.ui;
|
||||
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceAlarmH2UIDAO extends H2DAO implements IInstanceAlarmUIDAO {
|
||||
|
||||
public InstanceAlarmH2UIDAO(H2Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override public Alarm loadAlarmList(String keyword, long start, long end, int limit, int from) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.dao.ui;
|
||||
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceAlarmH2UIDAO extends H2DAO implements IServiceAlarmUIDAO {
|
||||
|
||||
public ServiceAlarmH2UIDAO(H2Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override public Alarm loadAlarmList(String keyword, long start, long end, int limit, int from) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ public class GraphQLHandler extends JettyHandler {
|
|||
.file("ui-graphql/server-layer.graphqls")
|
||||
.file("ui-graphql/service-layer.graphqls")
|
||||
.file("ui-graphql/trace.graphqls")
|
||||
.resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(), new ApplicationQuery(moduleManager))
|
||||
.resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(moduleManager), new ApplicationQuery(moduleManager))
|
||||
.resolvers(new OverViewLayerQuery(moduleManager), new ServerQuery(moduleManager), new ServiceQuery(moduleManager), new TraceQuery(moduleManager))
|
||||
.resolvers(new ConfigQuery(), new ConfigMutation())
|
||||
.dictionary(ConjecturalNode.class, VisualUserNode.class, ApplicationNode.class, ServiceNode.class)
|
||||
|
|
|
|||
|
|
@ -18,23 +18,53 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.ui.query;
|
||||
|
||||
import org.apache.skywalking.apm.collector.ui.graphql.Query;
|
||||
import java.text.ParseException;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmType;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Pagination;
|
||||
|
||||
import java.util.Collections;
|
||||
import org.apache.skywalking.apm.collector.ui.graphql.Query;
|
||||
import org.apache.skywalking.apm.collector.ui.service.AlarmService;
|
||||
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AlarmQuery implements Query {
|
||||
|
||||
public Alarm loadAlarmList(String keyword, AlarmType alarmType, Duration duration, Pagination paging) {
|
||||
Alarm alarm = new Alarm();
|
||||
alarm.setTotal(0);
|
||||
alarm.setItems(Collections.emptyList());
|
||||
return alarm;
|
||||
private final ModuleManager moduleManager;
|
||||
private AlarmService alarmService;
|
||||
|
||||
public AlarmQuery(ModuleManager moduleManager) {
|
||||
this.moduleManager = moduleManager;
|
||||
}
|
||||
|
||||
private AlarmService getAlarmService() {
|
||||
if (ObjectUtils.isEmpty(alarmService)) {
|
||||
this.alarmService = new AlarmService(moduleManager);
|
||||
}
|
||||
return alarmService;
|
||||
}
|
||||
|
||||
public Alarm loadAlarmList(String keyword, AlarmType alarmType, Duration duration,
|
||||
Pagination paging) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()) / 100;
|
||||
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()) / 100;
|
||||
|
||||
int limit = paging.getPageSize();
|
||||
int from = paging.getPageSize() * paging.getPageNum();
|
||||
|
||||
switch (alarmType) {
|
||||
case APPLICATION:
|
||||
return getAlarmService().loadApplicationAlarmList(keyword, start, end, limit, from);
|
||||
case SERVER:
|
||||
return getAlarmService().loadInstanceAlarmList(keyword, start, end, limit, from);
|
||||
case SERVICE:
|
||||
return getAlarmService().loadServiceAlarmList(keyword, start, end, limit, from);
|
||||
default:
|
||||
return new Alarm();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,18 +21,51 @@ package org.apache.skywalking.apm.collector.ui.service;
|
|||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceAlarmUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend;
|
||||
import org.apache.skywalking.apm.collector.storage.utils.DurationPoint;
|
||||
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AlarmService {
|
||||
|
||||
public AlarmService(ModuleManager moduleManager) {
|
||||
private final Logger logger = LoggerFactory.getLogger(AlarmService.class);
|
||||
|
||||
private final IApplicationAlarmUIDAO applicationAlarmUIDAO;
|
||||
private final IInstanceAlarmUIDAO instanceAlarmUIDAO;
|
||||
private final IServiceAlarmUIDAO serviceAlarmUIDAO;
|
||||
|
||||
public AlarmService(ModuleManager moduleManager) {
|
||||
this.applicationAlarmUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationAlarmUIDAO.class);
|
||||
this.instanceAlarmUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceAlarmUIDAO.class);
|
||||
this.serviceAlarmUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceAlarmUIDAO.class);
|
||||
}
|
||||
|
||||
public Alarm loadApplicationAlarmList(String keyword, long start, long end,
|
||||
int limit, int from) throws ParseException {
|
||||
logger.debug("keyword: {}, start: {}, end: {}, limit: {}, from: {}", keyword, start, end, limit, from);
|
||||
return applicationAlarmUIDAO.loadAlarmList(keyword, start, end, limit, from);
|
||||
}
|
||||
|
||||
public Alarm loadInstanceAlarmList(String keyword, long start, long end,
|
||||
int limit, int from) throws ParseException {
|
||||
logger.debug("keyword: {}, start: {}, end: {}, limit: {}, from: {}", keyword, start, end, limit, from);
|
||||
return instanceAlarmUIDAO.loadAlarmList(keyword, start, end, limit, from);
|
||||
}
|
||||
|
||||
public Alarm loadServiceAlarmList(String keyword, long start, long end,
|
||||
int limit, int from) throws ParseException {
|
||||
logger.debug("keyword: {}, start: {}, end: {}, limit: {}, from: {}", keyword, start, end, limit, from);
|
||||
return serviceAlarmUIDAO.loadAlarmList(keyword, start, end, limit, from);
|
||||
}
|
||||
|
||||
public AlarmTrend getApplicationAlarmTrend(Step step, long start, long end) throws ParseException {
|
||||
|
|
|
|||
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.ui.service;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.skywalking.apm.collector.cache.CacheModule;
|
||||
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceHealthService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(InstanceHealthService.class);
|
||||
|
||||
private final IGCMetricUIDAO gcMetricDAO;
|
||||
private final IInstanceUIDAO instanceDAO;
|
||||
private final IInstanceMetricUIDAO instanceMetricUIDAO;
|
||||
private final ApplicationCacheService applicationCacheService;
|
||||
|
||||
public InstanceHealthService(ModuleManager moduleManager) {
|
||||
this.gcMetricDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricUIDAO.class);
|
||||
this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
|
||||
this.instanceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricUIDAO.class);
|
||||
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
|
||||
}
|
||||
|
||||
public JsonObject getInstances(long timeBucket, int applicationId) {
|
||||
JsonObject response = new JsonObject();
|
||||
|
||||
// long[] timeBuckets = TimeBucketUtils.INSTANCE.getFiveSecondTimeBuckets(timeBucket);
|
||||
// long halfHourBeforeTimeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, -60 * 30);
|
||||
// List<Instance> instanceList = instanceDAO.getInstances(applicationId, halfHourBeforeTimeBucket);
|
||||
|
||||
JsonArray instances = new JsonArray();
|
||||
response.add("instances", instances);
|
||||
|
||||
// instanceList.forEach(instance -> {
|
||||
// response.addProperty("applicationCode", applicationCacheService.getApplicationById(applicationId));
|
||||
// response.addProperty("applicationId", applicationId);
|
||||
//
|
||||
// IInstanceMetricUIDAO.InstanceMetric performance = instanceMetricUIDAO.get(timeBuckets, instance.getInstanceId());
|
||||
//
|
||||
// JsonObject instanceJson = new JsonObject();
|
||||
// instanceJson.addProperty("id", instance.getInstanceId());
|
||||
// if (performance != null) {
|
||||
// instanceJson.addProperty("tps", performance.getCalls());
|
||||
// } else {
|
||||
// instanceJson.addProperty("tps", 0);
|
||||
// }
|
||||
//
|
||||
// int avg = 0;
|
||||
// if (performance != null && performance.getCalls() != 0) {
|
||||
// avg = (int)(performance.getDurationSum() / performance.getCalls());
|
||||
// }
|
||||
// instanceJson.addProperty("avg", avg);
|
||||
//
|
||||
// if (avg > 5000) {
|
||||
// instanceJson.addProperty("healthLevel", 0);
|
||||
// } else if (avg > 3000 && avg <= 5000) {
|
||||
// instanceJson.addProperty("healthLevel", 1);
|
||||
// } else if (avg > 1000 && avg <= 3000) {
|
||||
// instanceJson.addProperty("healthLevel", 2);
|
||||
// } else {
|
||||
// instanceJson.addProperty("healthLevel", 3);
|
||||
// }
|
||||
|
||||
// long heartBeatTime = TimeBucketUtils.INSTANCE.changeTimeBucket2TimeStamp(TimeBucketUtils.TimeBucketType.SECOND, instance.getHeartBeatTime());
|
||||
// long currentTime = TimeBucketUtils.INSTANCE.changeTimeBucket2TimeStamp(TimeBucketUtils.TimeBucketType.SECOND, timeBucket);
|
||||
//
|
||||
// if (currentTime - heartBeatTime < 1000 * 60 * 2) {
|
||||
// instanceJson.addProperty("status", 0);
|
||||
// } else {
|
||||
// instanceJson.addProperty("status", 1);
|
||||
// }
|
||||
//
|
||||
// IGCMetricUIDAO.GCCount gcCount = gcMetricDAO.getGCCount(timeBuckets, instance.getInstanceId());
|
||||
// instanceJson.addProperty("ygc", gcCount.getYoung());
|
||||
// instanceJson.addProperty("ogc", gcCount.getOld());
|
||||
//
|
||||
// instances.add(instanceJson);
|
||||
// });
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.ui.service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.util.Set;
|
||||
import org.apache.skywalking.apm.collector.core.UnexpectedException;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.Instance;
|
||||
import org.apache.skywalking.apm.network.proto.PoolType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceJVMService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(InstanceJVMService.class);
|
||||
|
||||
private final Gson gson = new Gson();
|
||||
|
||||
private final IInstanceUIDAO instanceDAO;
|
||||
private final ICpuMetricUIDAO cpuMetricDAO;
|
||||
private final IGCMetricUIDAO gcMetricDAO;
|
||||
private final IMemoryMetricUIDAO memoryMetricDAO;
|
||||
private final IMemoryPoolMetricUIDAO memoryPoolMetricDAO;
|
||||
private final IInstanceMetricUIDAO instanceMetricUIDAO;
|
||||
|
||||
public InstanceJVMService(ModuleManager moduleManager) {
|
||||
this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
|
||||
this.cpuMetricDAO = moduleManager.find(StorageModule.NAME).getService(ICpuMetricUIDAO.class);
|
||||
this.gcMetricDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricUIDAO.class);
|
||||
this.memoryMetricDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryMetricUIDAO.class);
|
||||
this.memoryPoolMetricDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryPoolMetricUIDAO.class);
|
||||
this.instanceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricUIDAO.class);
|
||||
}
|
||||
|
||||
public JsonObject getInstanceOsInfo(int instanceId) {
|
||||
Instance instance = instanceDAO.getInstance(instanceId);
|
||||
if (ObjectUtils.isEmpty(instance)) {
|
||||
throw new UnexpectedException("instance id: " + instanceId + " not exist.");
|
||||
}
|
||||
|
||||
return gson.fromJson(instance.getOsInfo(), JsonObject.class);
|
||||
}
|
||||
|
||||
public JsonObject getInstanceJvmMetric(int instanceId, Set<String> metricTypes, long timeBucket) {
|
||||
JsonObject metrics = new JsonObject();
|
||||
for (String metricType : metricTypes) {
|
||||
if (metricType.toLowerCase().equals(MetricType.cpu.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.gc.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.tps.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.resptime.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.nonheapmemory.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.permgen.name())) {
|
||||
metrics.add(MetricType.permgen.name(), memoryPoolMetricDAO.getMetric(instanceId, timeBucket, PoolType.PERMGEN_USAGE_VALUE));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.metaspace.name())) {
|
||||
metrics.add(MetricType.metaspace.name(), memoryPoolMetricDAO.getMetric(instanceId, timeBucket, PoolType.METASPACE_USAGE_VALUE));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.newgen.name())) {
|
||||
metrics.add(MetricType.newgen.name(), memoryPoolMetricDAO.getMetric(instanceId, timeBucket, PoolType.NEWGEN_USAGE_VALUE));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.oldgen.name())) {
|
||||
metrics.add(MetricType.oldgen.name(), memoryPoolMetricDAO.getMetric(instanceId, timeBucket, PoolType.OLDGEN_USAGE_VALUE));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.survivor.name())) {
|
||||
metrics.add(MetricType.survivor.name(), memoryPoolMetricDAO.getMetric(instanceId, timeBucket, PoolType.SURVIVOR_USAGE_VALUE));
|
||||
} else {
|
||||
throw new UnexpectedException("unexpected metric type");
|
||||
}
|
||||
}
|
||||
return metrics;
|
||||
}
|
||||
|
||||
public JsonObject getInstanceJvmMetrics(int instanceId, Set<String> metricTypes, long startTimeBucket,
|
||||
long endTimeBucket) {
|
||||
JsonObject metrics = new JsonObject();
|
||||
for (String metricType : metricTypes) {
|
||||
if (metricType.toLowerCase().equals(MetricType.cpu.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.gc.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.tps.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.resptime.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.nonheapmemory.name())) {
|
||||
} else if (metricType.toLowerCase().equals(MetricType.permgen.name())) {
|
||||
metrics.add(MetricType.permgen.name(), memoryPoolMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, PoolType.PERMGEN_USAGE_VALUE));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.metaspace.name())) {
|
||||
metrics.add(MetricType.metaspace.name(), memoryPoolMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, PoolType.METASPACE_USAGE_VALUE));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.newgen.name())) {
|
||||
metrics.add(MetricType.newgen.name(), memoryPoolMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, PoolType.NEWGEN_USAGE_VALUE));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.oldgen.name())) {
|
||||
metrics.add(MetricType.oldgen.name(), memoryPoolMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, PoolType.OLDGEN_USAGE_VALUE));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.survivor.name())) {
|
||||
metrics.add(MetricType.survivor.name(), memoryPoolMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, PoolType.SURVIVOR_USAGE_VALUE));
|
||||
} else {
|
||||
throw new UnexpectedException("unexpected metric type");
|
||||
}
|
||||
}
|
||||
|
||||
return metrics;
|
||||
}
|
||||
|
||||
public enum MetricType {
|
||||
cpu, gc, tps, resptime, heapmemory, nonheapmemory, permgen, metaspace, newgen,
|
||||
oldgen, survivor
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue