提交 a17de070 编写于 作者: P peng-yongsheng

Application metric alarm.

上级 82771cc6
......@@ -22,8 +22,7 @@ package org.apache.skywalking.apm.collector.analysis.alarm.define.graph;
* @author peng-yongsheng
*/
public class AlarmGraphIdDefine {
public static final int SERVICE_METRIC_TRANSFORM_GRAPH_ID = 500;
public static final int INSTANCE_METRIC_TRANSFORM_GRAPH_ID = 501;
public static final int APPLICATION_METRIC_TRANSFORM_GRAPH_ID = 502;
public static final int ALARM_METRIC_AGGREGATION_GRAPH_ID = 503;
public static final int SERVICE_METRIC_ALARM_GRAPH_ID = 500;
public static final int INSTANCE_METRIC_ALARM_GRAPH_ID = 501;
public static final int APPLICATION_METRIC_ALARM_GRAPH_ID = 502;
}
......@@ -24,23 +24,22 @@ package org.apache.skywalking.apm.collector.analysis.alarm.define.graph;
public class AlarmWorkerIdDefine {
public static final int SERVICE_METRIC_ALARM_ASSERT_WORKER_ID = 500;
public static final int SERVICE_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 501;
public static final int SERVICE_METRIC_ALARM_REMOTE_WORKER_ID = 500;
public static final int SERVICE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 500;
public static final int SERVICE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 500;
public static final int SERVICE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 500;
public static final int SERVICE_METRIC_ALARM_REMOTE_WORKER_ID = 502;
public static final int SERVICE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 503;
public static final int SERVICE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 504;
public static final int SERVICE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 505;
public static final int INSTANCE_METRIC_ALARM_ASSERT_WORKER_ID = 500;
public static final int INSTANCE_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 501;
public static final int INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID = 500;
public static final int INSTANCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 500;
public static final int INSTANCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 500;
public static final int INSTANCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 500;
public static final int INSTANCE_METRIC_ALARM_ASSERT_WORKER_ID = 510;
public static final int INSTANCE_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 511;
public static final int INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID = 512;
public static final int INSTANCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 513;
public static final int INSTANCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 514;
public static final int INSTANCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 515;
public static final int APPLICATION_METRIC_TRANSFORM_WORKER_ID = 504;
public static final int APPLICATION_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 505;
public static final int ALARM_METRIC_REMOTE_WORKER_ID = 506;
public static final int ALARM_METRIC_APPLICATION_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 507;
public static final int ALARM_METRIC_INSTANCE_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 508;
public static final int ALARM_METRIC_SERVICE_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 509;
public static final int ALARM_METRIC_AGGREGATION_WORKER_ID = 510;
public static final int APPLICATION_METRIC_ALARM_ASSERT_WORKER_ID = 520;
public static final int APPLICATION_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 521;
public static final int APPLICATION_METRIC_ALARM_REMOTE_WORKER_ID = 522;
public static final int APPLICATION_METRIC_ALARM_PERSISTENCE_WORKER_ID = 523;
public static final int APPLICATION_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 524;
public static final int APPLICATION_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 525;
}
......@@ -20,7 +20,7 @@ package org.apache.skywalking.apm.collector.analysis.alarm.provider;
import java.util.Properties;
import org.apache.skywalking.apm.collector.analysis.alarm.define.AnalysisAlarmModule;
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.ApplicationMetricTransformGraph;
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.application.ApplicationMetricAlarmGraph;
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.instance.InstanceMetricAlarmGraph;
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.service.ServiceMetricAlarmGraph;
import org.apache.skywalking.apm.collector.analysis.metric.define.AnalysisMetricModule;
......@@ -58,8 +58,8 @@ public class AnalysisAlarmModuleProvider extends ModuleProvider {
InstanceMetricAlarmGraph instanceMetricAlarmGraph = new InstanceMetricAlarmGraph(getManager(), workerCreateListener);
instanceMetricAlarmGraph.create();
ApplicationMetricTransformGraph applicationMetricTransformGraph = new ApplicationMetricTransformGraph(getManager(), workerCreateListener);
applicationMetricTransformGraph.create();
ApplicationMetricAlarmGraph applicationMetricAlarmGraph = new ApplicationMetricAlarmGraph(getManager(), workerCreateListener);
applicationMetricAlarmGraph.create();
}
......
/*
* 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.analysis.alarm.provider.worker.application;
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorker;
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorkerProvider;
import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
import org.apache.skywalking.apm.collector.configuration.service.IApplicationAlarmRuleConfig;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric;
/**
* @author peng-yongsheng
*/
public class ApplicationMetricAlarmAssertWorker extends AlarmAssertWorker<ApplicationMetric, ApplicationAlarm> {
private final IApplicationAlarmRuleConfig applicationAlarmRuleConfig;
public ApplicationMetricAlarmAssertWorker(ModuleManager moduleManager) {
super(moduleManager);
this.applicationAlarmRuleConfig = moduleManager.find(ConfigurationModule.NAME).getService(IApplicationAlarmRuleConfig.class);
}
@Override public int id() {
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_ASSERT_WORKER_ID;
}
@Override protected ApplicationAlarm newAlarmObject(String id, ApplicationMetric inputMetric) {
ApplicationAlarm applicationAlarm = new ApplicationAlarm(id + Const.ID_SPLIT + inputMetric.getApplicationId());
applicationAlarm.setApplicationId(inputMetric.getApplicationId());
return applicationAlarm;
}
@Override protected Double calleeErrorRateThreshold() {
return applicationAlarmRuleConfig.calleeErrorRateThreshold();
}
@Override protected Double callerErrorRateThreshold() {
return applicationAlarmRuleConfig.callerErrorRateThreshold();
}
@Override protected Double calleeAverageResponseTimeThreshold() {
return applicationAlarmRuleConfig.calleeAverageResponseTimeThreshold();
}
@Override protected Double callerAverageResponseTimeThreshold() {
return applicationAlarmRuleConfig.callerAverageResponseTimeThreshold();
}
public static class Factory extends AlarmAssertWorkerProvider<ApplicationMetric, ApplicationAlarm, ApplicationMetricAlarmAssertWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public ApplicationMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) {
return new ApplicationMetricAlarmAssertWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}
......@@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker;
package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.application;
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmGraphIdDefine;
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
......@@ -28,38 +28,51 @@ import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.graph.Next;
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.remote.RemoteModule;
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric;
/**
* @author peng-yongsheng
*/
public class ApplicationMetricTransformGraph {
public class ApplicationMetricAlarmGraph {
private final ModuleManager moduleManager;
private final WorkerCreateListener workerCreateListener;
public ApplicationMetricTransformGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
public ApplicationMetricAlarmGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
this.moduleManager = moduleManager;
this.workerCreateListener = workerCreateListener;
}
public void create() {
Graph<ApplicationMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.APPLICATION_METRIC_TRANSFORM_GRAPH_ID, ApplicationMetric.class);
graph.addNode(new ApplicationMetricTransformWorker.Factory(moduleManager).create(workerCreateListener));
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
Graph<ApplicationMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.APPLICATION_METRIC_ALARM_GRAPH_ID, ApplicationMetric.class);
graph.addNode(new ApplicationMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener))
.addNext(new ApplicationMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.APPLICATION_METRIC_ALARM_GRAPH_ID).create(workerCreateListener))
.addNext(new ApplicationMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
graph.toFinder().findNode(AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_REMOTE_WORKER_ID, ApplicationAlarm.class)
.addNext(new ApplicationMetricAlarmToListNodeProcessor())
.addNext(new ApplicationMetricAlarmListPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
link(graph);
}
private void link(Graph<ApplicationMetric> graph) {
GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.APPLICATION_METRIC_GRAPH_ID, ApplicationMetric.class)
.toFinder().findNode(MetricWorkerIdDefine.APPLICATION_MAPPING_AGGREGATION_WORKER_ID, ApplicationMetric.class)
.toFinder().findNode(MetricWorkerIdDefine.APPLICATION_METRIC_PERSISTENCE_WORKER_ID, ApplicationMetric.class)
.addNext(new NodeProcessor<ApplicationMetric, ApplicationMetric>() {
@Override public int id() {
return AlarmWorkerIdDefine.APPLICATION_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID;
}
@Override public void process(ApplicationMetric applicationMetric,
@Override public void process(ApplicationMetric instanceMetric,
Next<ApplicationMetric> next) {
graph.start(applicationMetric);
graph.start(instanceMetric);
}
});
}
......
......@@ -16,63 +16,46 @@
*
*/
package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker;
package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.application;
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.storage.table.alarm.AlarmMetric;
import org.apache.skywalking.apm.collector.storage.table.alarm.Layer;
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IApplicationAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList;
/**
* @author peng-yongsheng
*/
public class ApplicationMetricTransformWorker extends AggregationWorker<ApplicationMetric, AlarmMetric> {
public class ApplicationMetricAlarmListPersistenceWorker extends PersistenceWorker<ApplicationAlarmList> {
public ApplicationMetricTransformWorker(ModuleManager moduleManager) {
public ApplicationMetricAlarmListPersistenceWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return AlarmWorkerIdDefine.APPLICATION_METRIC_TRANSFORM_WORKER_ID;
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID;
}
@Override protected AlarmMetric transform(ApplicationMetric applicationMetric) {
AlarmMetric alarmMetric = new AlarmMetric(String.valueOf(applicationMetric.getApplicationId()));
alarmMetric.setLayer(Layer.APPLICATION.getValue());
alarmMetric.setObjectId(applicationMetric.getApplicationId());
alarmMetric.setApplicationId(applicationMetric.getApplicationId());
alarmMetric.setSourceValue(applicationMetric.getSourceValue());
alarmMetric.setTransactionCalls(applicationMetric.getTransactionCalls());
alarmMetric.setTransactionDurationSum(applicationMetric.getTransactionDurationSum());
alarmMetric.setTransactionErrorCalls(applicationMetric.getTransactionErrorCalls());
alarmMetric.setTransactionErrorDurationSum(applicationMetric.getTransactionErrorDurationSum());
alarmMetric.setBusinessTransactionCalls(applicationMetric.getBusinessTransactionCalls());
alarmMetric.setBusinessTransactionDurationSum(applicationMetric.getBusinessTransactionDurationSum());
alarmMetric.setBusinessTransactionErrorCalls(applicationMetric.getBusinessTransactionErrorCalls());
alarmMetric.setBusinessTransactionErrorDurationSum(applicationMetric.getBusinessTransactionErrorDurationSum());
alarmMetric.setMqTransactionCalls(applicationMetric.getMqTransactionCalls());
alarmMetric.setMqTransactionDurationSum(applicationMetric.getMqTransactionDurationSum());
alarmMetric.setMqTransactionErrorCalls(applicationMetric.getMqTransactionErrorCalls());
alarmMetric.setMqTransactionErrorDurationSum(applicationMetric.getMqTransactionErrorDurationSum());
alarmMetric.setTimeBucket(applicationMetric.getTimeBucket());
return alarmMetric;
@Override protected boolean needMergeDBData() {
return true;
}
public static class Factory extends AbstractLocalAsyncWorkerProvider<ApplicationMetric, AlarmMetric, ApplicationMetricTransformWorker> {
@SuppressWarnings("unchecked")
@Override protected IPersistenceDAO<?, ?, ApplicationAlarmList> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<ApplicationAlarmList, ApplicationMetricAlarmListPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public ApplicationMetricTransformWorker workerInstance(ModuleManager moduleManager) {
return new ApplicationMetricTransformWorker(moduleManager);
@Override public ApplicationMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new ApplicationMetricAlarmListPersistenceWorker(moduleManager);
}
@Override
......
/*
* 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.analysis.alarm.provider.worker.application;
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IApplicationAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
/**
* @author peng-yongsheng
*/
public class ApplicationMetricAlarmPersistenceWorker extends PersistenceWorker<ApplicationAlarm> {
public ApplicationMetricAlarmPersistenceWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_PERSISTENCE_WORKER_ID;
}
@Override protected boolean needMergeDBData() {
return true;
}
@SuppressWarnings("unchecked")
@Override protected IPersistenceDAO<?, ?, ApplicationAlarm> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<ApplicationAlarm, ApplicationMetricAlarmPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public ApplicationMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new ApplicationMetricAlarmPersistenceWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}
/*
* 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.analysis.alarm.provider.worker.application;
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService;
import org.apache.skywalking.apm.collector.remote.service.Selector;
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
/**
* @author peng-yongsheng
*/
public class ApplicationMetricAlarmRemoteWorker extends AbstractRemoteWorker<ApplicationAlarm, ApplicationAlarm> {
public ApplicationMetricAlarmRemoteWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_REMOTE_WORKER_ID;
}
@Override public Selector selector() {
return Selector.HashCode;
}
@Override protected void onWork(ApplicationAlarm message) throws WorkerException {
onNext(message);
}
public static class Factory extends AbstractRemoteWorkerProvider<ApplicationAlarm, ApplicationAlarm, ApplicationMetricAlarmRemoteWorker> {
public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) {
super(moduleManager, remoteSenderService, graphId);
}
@Override public ApplicationMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) {
return new ApplicationMetricAlarmRemoteWorker(moduleManager);
}
}
}
/*
* 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.analysis.alarm.provider.worker.application;
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
import org.apache.skywalking.apm.collector.core.graph.Next;
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList;
/**
* @author peng-yongsheng
*/
public class ApplicationMetricAlarmToListNodeProcessor implements NodeProcessor<ApplicationAlarm, ApplicationAlarmList> {
@Override public int id() {
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID;
}
@Override public void process(ApplicationAlarm applicationAlarm, Next<ApplicationAlarmList> next) {
String id = applicationAlarm.getLastTimeBucket() + Const.ID_SPLIT + applicationAlarm.getSourceValue()
+ Const.ID_SPLIT + applicationAlarm.getAlarmType()
+ Const.ID_SPLIT + applicationAlarm.getApplicationId();
ApplicationAlarmList applicationAlarmList = new ApplicationAlarmList(id);
applicationAlarmList.setApplicationId(applicationAlarm.getApplicationId());
applicationAlarmList.setSourceValue(applicationAlarm.getSourceValue());
applicationAlarmList.setAlarmType(applicationAlarm.getAlarmType());
applicationAlarmList.setTimeBucket(applicationAlarm.getLastTimeBucket());
applicationAlarmList.setAlarmContent(applicationAlarm.getAlarmContent());
next.execute(applicationAlarmList);
}
}
......@@ -49,10 +49,10 @@ public class InstanceMetricAlarmGraph {
public void create() {
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
Graph<InstanceMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.INSTANCE_METRIC_TRANSFORM_GRAPH_ID, InstanceMetric.class);
Graph<InstanceMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.INSTANCE_METRIC_ALARM_GRAPH_ID, InstanceMetric.class);
graph.addNode(new InstanceMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener))
.addNext(new InstanceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.INSTANCE_METRIC_TRANSFORM_GRAPH_ID).create(workerCreateListener))
.addNext(new InstanceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.INSTANCE_METRIC_ALARM_GRAPH_ID).create(workerCreateListener))
.addNext(new InstanceMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
graph.toFinder().findNode(AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID, InstanceAlarm.class)
......
......@@ -49,10 +49,10 @@ public class ServiceMetricAlarmGraph {
public void create() {
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
Graph<ServiceMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.SERVICE_METRIC_TRANSFORM_GRAPH_ID, ServiceMetric.class);
Graph<ServiceMetric> graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.SERVICE_METRIC_ALARM_GRAPH_ID, ServiceMetric.class);
graph.addNode(new ServiceMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener))
.addNext(new ServiceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.SERVICE_METRIC_TRANSFORM_GRAPH_ID).create(workerCreateListener))
.addNext(new ServiceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.SERVICE_METRIC_ALARM_GRAPH_ID).create(workerCreateListener))
.addNext(new ServiceMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
graph.toFinder().findNode(AlarmWorkerIdDefine.SERVICE_METRIC_ALARM_REMOTE_WORKER_ID, ServiceAlarm.class)
......
......@@ -19,6 +19,7 @@
package org.apache.skywalking.apm.collector.configuration;
import org.apache.skywalking.apm.collector.configuration.service.IApdexThresholdService;
import org.apache.skywalking.apm.collector.configuration.service.IApplicationAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.core.module.Module;
......@@ -35,6 +36,6 @@ public class ConfigurationModule extends Module {
}
@Override public Class[] services() {
return new Class[] {IApdexThresholdService.class, IServiceAlarmRuleConfig.class, IInstanceAlarmRuleConfig.class};
return new Class[] {IApdexThresholdService.class, IServiceAlarmRuleConfig.class, IInstanceAlarmRuleConfig.class, IApplicationAlarmRuleConfig.class};
}
}
/*
* 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.configuration.service;
import org.apache.skywalking.apm.collector.core.module.Service;
/**
* @author peng-yongsheng
*/
public interface IApplicationAlarmRuleConfig extends Service {
double calleeErrorRateThreshold();
double calleeAverageResponseTimeThreshold();
double callerErrorRateThreshold();
double callerAverageResponseTimeThreshold();
}
......@@ -20,7 +20,9 @@ package org.apache.skywalking.apm.collector.configuration;
import java.util.Properties;
import org.apache.skywalking.apm.collector.configuration.service.ApdexThresholdService;
import org.apache.skywalking.apm.collector.configuration.service.ApplicationAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IApdexThresholdService;
import org.apache.skywalking.apm.collector.configuration.service.IApplicationAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.InstanceAlarmRuleConfig;
......@@ -46,6 +48,7 @@ public class ConfigurationModuleProvider extends ModuleProvider {
this.registerServiceImplementation(IApdexThresholdService.class, new ApdexThresholdService());
this.registerServiceImplementation(IServiceAlarmRuleConfig.class, new ServiceAlarmRuleConfig());
this.registerServiceImplementation(IInstanceAlarmRuleConfig.class, new InstanceAlarmRuleConfig());
this.registerServiceImplementation(IApplicationAlarmRuleConfig.class, new ApplicationAlarmRuleConfig());
}
@Override public void start(Properties config) throws ServiceNotProvidedException {
......
/*
* 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.configuration.service;
/**
* @author peng-yongsheng
*/
public class ApplicationAlarmRuleConfig implements IApplicationAlarmRuleConfig {
@Override public double calleeErrorRateThreshold() {
return 10.00;
}
@Override public double calleeAverageResponseTimeThreshold() {
return 2000;
}
@Override public double callerErrorRateThreshold() {
return 10.00;
}
@Override public double callerAverageResponseTimeThreshold() {
return 3000;
}
}
/*
* 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;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList;
/**
* @author peng-yongsheng
*/
public interface IApplicationAlarmListPersistenceDAO<Insert, Update, DataImpl extends ApplicationAlarmList> extends IPersistenceDAO<Insert, Update, DataImpl> {
}
/*
* 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;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarm;
/**
* @author peng-yongsheng
*/
public interface IApplicationAlarmPersistenceDAO<Insert, Update, DataImpl extends ApplicationAlarm> extends IPersistenceDAO<Insert, Update, DataImpl> {
}
/*
* 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.table.alarm;
import org.apache.skywalking.apm.collector.core.data.Column;
import org.apache.skywalking.apm.collector.core.data.Data;
import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
/**
* @author peng-yongsheng
*/
public class ApplicationAlarm extends Data implements Alarm {
private static final Column[] STRING_COLUMNS = {
new Column(ApplicationAlarmTable.COLUMN_ID, new NonOperation()),
new Column(ApplicationAlarmTable.COLUMN_ALARM_CONTENT, new CoverOperation()),
};
private static final Column[] LONG_COLUMNS = {
new Column(ApplicationAlarmTable.COLUMN_LAST_TIME_BUCKET, new CoverOperation()),
};
private static final Column[] DOUBLE_COLUMNS = {};
private static final Column[] INTEGER_COLUMNS = {
new Column(ApplicationAlarmTable.COLUMN_ALARM_TYPE, new NonOperation()),
new Column(ApplicationAlarmTable.COLUMN_SOURCE_VALUE, new NonOperation()),
new Column(ApplicationAlarmTable.COLUMN_APPLICATION_ID, new NonOperation()),
};
private static final Column[] BOOLEAN_COLUMNS = {};
private static final Column[] BYTE_COLUMNS = {};
public ApplicationAlarm(String id) {
super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS);
}
@Override
public Integer getAlarmType() {
return getDataInteger(0);
}
@Override
public void setAlarmType(Integer alarmType) {
setDataInteger(0, alarmType);
}
@Override
public Integer getSourceValue() {
return getDataInteger(1);
}
@Override
public void setSourceValue(Integer sourceValue) {
setDataInteger(1, sourceValue);
}
public Integer getApplicationId() {
return getDataInteger(2);
}
public void setApplicationId(Integer applicationId) {
setDataInteger(2, applicationId);
}
@Override
public Long getLastTimeBucket() {
return getDataLong(0);
}
@Override
public void setLastTimeBucket(Long lastTimeBucket) {
setDataLong(0, lastTimeBucket);
}
@Override
public String getAlarmContent() {
return getDataString(1);
}
@Override
public void setAlarmContent(String alarmContent) {
setDataString(1, alarmContent);
}
}
/*
* 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.table.alarm;
import org.apache.skywalking.apm.collector.core.data.Column;
import org.apache.skywalking.apm.collector.core.data.Data;
import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
/**
* @author peng-yongsheng
*/
public class ApplicationAlarmList extends Data {
private static final Column[] STRING_COLUMNS = {
new Column(ApplicationAlarmListTable.COLUMN_ID, new NonOperation()),
new Column(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, new CoverOperation()),
};
private static final Column[] LONG_COLUMNS = {
new Column(ApplicationAlarmListTable.COLUMN_TIME_BUCKET, new NonOperation()),
};
private static final Column[] DOUBLE_COLUMNS = {};
private static final Column[] INTEGER_COLUMNS = {
new Column(ApplicationAlarmListTable.COLUMN_ALARM_TYPE, new NonOperation()),
new Column(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, new NonOperation()),
new Column(ApplicationAlarmListTable.COLUMN_APPLICATION_ID, new NonOperation()),
};
private static final Column[] BOOLEAN_COLUMNS = {};
private static final Column[] BYTE_COLUMNS = {};
public ApplicationAlarmList(String id) {
super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS);
}
public Integer getAlarmType() {
return getDataInteger(0);
}
public void setAlarmType(Integer alarmType) {
setDataInteger(0, alarmType);
}
public Integer getSourceValue() {
return getDataInteger(1);
}
public void setSourceValue(Integer sourceValue) {
setDataInteger(1, sourceValue);
}
public Integer getApplicationId() {
return getDataInteger(2);
}
public void setApplicationId(Integer applicationId) {
setDataInteger(2, applicationId);
}
public Long getTimeBucket() {
return getDataLong(0);
}
public void setTimeBucket(Long timeBucket) {
setDataLong(0, timeBucket);
}
public String getAlarmContent() {
return getDataString(1);
}
public void setAlarmContent(String alarmContent) {
setDataString(1, alarmContent);
}
}
/*
* 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.table.alarm;
import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable;
/**
* @author peng-yongsheng
*/
public class ApplicationAlarmListTable extends CommonMetricTable {
public static final String TABLE = "application_alarm_list";
public static final String COLUMN_ALARM_TYPE = "alarm_type";
public static final String COLUMN_ALARM_CONTENT = "alarm_content";
}
/*
* 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.table.alarm;
import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable;
/**
* @author peng-yongsheng
*/
public class ApplicationAlarmTable extends CommonMetricTable {
public static final String TABLE = "application_alarm";
public static final String COLUMN_ALARM_TYPE = "alarm_type";
public static final String COLUMN_LAST_TIME_BUCKET = "last_time_bucket";
public static final String COLUMN_ALARM_CONTENT = "alarm_content";
}
......@@ -24,7 +24,7 @@ import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable;
* @author peng-yongsheng
*/
public class ServiceAlarmListTable extends CommonMetricTable {
public static final String TABLE = "service_alarm";
public static final String TABLE = "service_alarm_list";
public static final String COLUMN_ALARM_TYPE = "alarm_type";
public static final String COLUMN_ALARM_CONTENT = "alarm_content";
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册