Instance metric alarm.

This commit is contained in:
peng-yongsheng 2018-01-01 14:28:06 +08:00
parent 2d44d8a419
commit 82771cc60b
19 changed files with 770 additions and 96 deletions

View File

@ -29,8 +29,13 @@ public class AlarmWorkerIdDefine {
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 INSTANCE_METRIC_TRANSFORM_WORKER_ID = 502;
public static final int INSTANCE_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 503;
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 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;

View File

@ -21,7 +21,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.InstanceMetricTransformGraph;
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;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.core.module.Module;
import org.apache.skywalking.apm.collector.core.module.ModuleProvider;
import org.apache.skywalking.apm.collector.core.module.ServiceNotProvidedException;
import org.apache.skywalking.apm.collector.remote.RemoteModule;
import org.apache.skywalking.apm.collector.storage.StorageModule;
/**
* @author peng-yongsheng
@ -54,8 +55,8 @@ public class AnalysisAlarmModuleProvider extends ModuleProvider {
ServiceMetricAlarmGraph serviceMetricAlarmGraph = new ServiceMetricAlarmGraph(getManager(), workerCreateListener);
serviceMetricAlarmGraph.create();
InstanceMetricTransformGraph instanceMetricTransformGraph = new InstanceMetricTransformGraph(getManager(), workerCreateListener);
instanceMetricTransformGraph.create();
InstanceMetricAlarmGraph instanceMetricAlarmGraph = new InstanceMetricAlarmGraph(getManager(), workerCreateListener);
instanceMetricAlarmGraph.create();
ApplicationMetricTransformGraph applicationMetricTransformGraph = new ApplicationMetricTransformGraph(getManager(), workerCreateListener);
applicationMetricTransformGraph.create();
@ -67,6 +68,6 @@ public class AnalysisAlarmModuleProvider extends ModuleProvider {
}
@Override public String[] requiredModules() {
return new String[] {RemoteModule.NAME, AnalysisMetricModule.NAME, ConfigurationModule.NAME};
return new String[] {RemoteModule.NAME, AnalysisMetricModule.NAME, ConfigurationModule.NAME, StorageModule.NAME};
}
}

View File

@ -1,84 +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.analysis.alarm.provider.worker;
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.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.instance.InstanceMetric;
/**
* @author peng-yongsheng
*/
public class InstanceMetricTransformWorker extends AggregationWorker<InstanceMetric, AlarmMetric> {
public InstanceMetricTransformWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return AlarmWorkerIdDefine.INSTANCE_METRIC_TRANSFORM_WORKER_ID;
}
@Override protected AlarmMetric transform(InstanceMetric instanceMetric) {
AlarmMetric alarmMetric = new AlarmMetric(String.valueOf(instanceMetric.getApplicationId()));
alarmMetric.setLayer(Layer.INSTANCE.getValue());
alarmMetric.setObjectId(instanceMetric.getApplicationId());
alarmMetric.setApplicationId(instanceMetric.getApplicationId());
alarmMetric.setSourceValue(instanceMetric.getSourceValue());
alarmMetric.setTransactionCalls(instanceMetric.getTransactionCalls());
alarmMetric.setTransactionDurationSum(instanceMetric.getTransactionDurationSum());
alarmMetric.setTransactionErrorCalls(instanceMetric.getTransactionErrorCalls());
alarmMetric.setTransactionErrorDurationSum(instanceMetric.getTransactionErrorDurationSum());
alarmMetric.setBusinessTransactionCalls(instanceMetric.getBusinessTransactionCalls());
alarmMetric.setBusinessTransactionDurationSum(instanceMetric.getBusinessTransactionDurationSum());
alarmMetric.setBusinessTransactionErrorCalls(instanceMetric.getBusinessTransactionErrorCalls());
alarmMetric.setBusinessTransactionErrorDurationSum(instanceMetric.getBusinessTransactionErrorDurationSum());
alarmMetric.setMqTransactionCalls(instanceMetric.getMqTransactionCalls());
alarmMetric.setMqTransactionDurationSum(instanceMetric.getMqTransactionDurationSum());
alarmMetric.setMqTransactionErrorCalls(instanceMetric.getMqTransactionErrorCalls());
alarmMetric.setMqTransactionErrorDurationSum(instanceMetric.getMqTransactionErrorDurationSum());
alarmMetric.setTimeBucket(instanceMetric.getTimeBucket());
return alarmMetric;
}
public static class Factory extends AbstractLocalAsyncWorkerProvider<InstanceMetric, AlarmMetric, InstanceMetricTransformWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public InstanceMetricTransformWorker workerInstance(ModuleManager moduleManager) {
return new InstanceMetricTransformWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}

View File

@ -0,0 +1,85 @@
/*
* 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.instance;
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.IInstanceAlarmRuleConfig;
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.InstanceAlarm;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric;
/**
* @author peng-yongsheng
*/
public class InstanceMetricAlarmAssertWorker extends AlarmAssertWorker<InstanceMetric, InstanceAlarm> {
private final IInstanceAlarmRuleConfig instanceAlarmRuleConfig;
public InstanceMetricAlarmAssertWorker(ModuleManager moduleManager) {
super(moduleManager);
this.instanceAlarmRuleConfig = moduleManager.find(ConfigurationModule.NAME).getService(IInstanceAlarmRuleConfig.class);
}
@Override public int id() {
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_ASSERT_WORKER_ID;
}
@Override protected InstanceAlarm newAlarmObject(String id, InstanceMetric inputMetric) {
InstanceAlarm instanceAlarm = new InstanceAlarm(id + Const.ID_SPLIT + inputMetric.getInstanceId());
instanceAlarm.setApplicationId(inputMetric.getApplicationId());
instanceAlarm.setInstanceId(inputMetric.getInstanceId());
return instanceAlarm;
}
@Override protected Double calleeErrorRateThreshold() {
return instanceAlarmRuleConfig.calleeErrorRateThreshold();
}
@Override protected Double callerErrorRateThreshold() {
return instanceAlarmRuleConfig.callerErrorRateThreshold();
}
@Override protected Double calleeAverageResponseTimeThreshold() {
return instanceAlarmRuleConfig.calleeAverageResponseTimeThreshold();
}
@Override protected Double callerAverageResponseTimeThreshold() {
return instanceAlarmRuleConfig.callerAverageResponseTimeThreshold();
}
public static class Factory extends AlarmAssertWorkerProvider<InstanceMetric, InstanceAlarm, InstanceMetricAlarmAssertWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public InstanceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) {
return new InstanceMetricAlarmAssertWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker;
package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.instance;
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmGraphIdDefine;
import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine;
@ -28,32 +28,43 @@ 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.InstanceAlarm;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric;
/**
* @author peng-yongsheng
*/
public class InstanceMetricTransformGraph {
public class InstanceMetricAlarmGraph {
private final ModuleManager moduleManager;
private final WorkerCreateListener workerCreateListener;
public InstanceMetricTransformGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
public InstanceMetricAlarmGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
this.moduleManager = moduleManager;
this.workerCreateListener = workerCreateListener;
}
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.addNode(new InstanceMetricTransformWorker.Factory(moduleManager).create(workerCreateListener));
graph.addNode(new InstanceMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener))
.addNext(new InstanceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.INSTANCE_METRIC_TRANSFORM_GRAPH_ID).create(workerCreateListener))
.addNext(new InstanceMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
graph.toFinder().findNode(AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID, InstanceAlarm.class)
.addNext(new InstanceMetricAlarmToListNodeProcessor())
.addNext(new InstanceMetricAlarmListPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
link(graph);
}
private void link(Graph<InstanceMetric> graph) {
GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.INSTANCE_METRIC_GRAPH_ID, InstanceMetric.class)
.toFinder().findNode(MetricWorkerIdDefine.INSTANCE_METRIC_AGGREGATION_WORKER_ID, InstanceMetric.class)
.toFinder().findNode(MetricWorkerIdDefine.INSTANCE_METRIC_PERSISTENCE_WORKER_ID, InstanceMetric.class)
.addNext(new NodeProcessor<InstanceMetric, InstanceMetric>() {
@Override public int id() {
return AlarmWorkerIdDefine.INSTANCE_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID;

View File

@ -0,0 +1,66 @@
/*
* 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.instance;
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.IInstanceAlarmListPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmList;
/**
* @author peng-yongsheng
*/
public class InstanceMetricAlarmListPersistenceWorker extends PersistenceWorker<InstanceAlarmList> {
public InstanceMetricAlarmListPersistenceWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID;
}
@Override protected boolean needMergeDBData() {
return true;
}
@SuppressWarnings("unchecked")
@Override protected IPersistenceDAO<?, ?, InstanceAlarmList> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IInstanceAlarmListPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<InstanceAlarmList, InstanceMetricAlarmListPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public InstanceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new InstanceMetricAlarmListPersistenceWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.instance;
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.IInstanceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm;
/**
* @author peng-yongsheng
*/
public class InstanceMetricAlarmPersistenceWorker extends PersistenceWorker<InstanceAlarm> {
public InstanceMetricAlarmPersistenceWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_PERSISTENCE_WORKER_ID;
}
@Override protected boolean needMergeDBData() {
return true;
}
@SuppressWarnings("unchecked")
@Override protected IPersistenceDAO<?, ?, InstanceAlarm> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IInstanceAlarmPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<InstanceAlarm, InstanceMetricAlarmPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public InstanceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new InstanceMetricAlarmPersistenceWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}

View File

@ -0,0 +1,61 @@
/*
* 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.instance;
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.InstanceAlarm;
/**
* @author peng-yongsheng
*/
public class InstanceMetricAlarmRemoteWorker extends AbstractRemoteWorker<InstanceAlarm, InstanceAlarm> {
public InstanceMetricAlarmRemoteWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID;
}
@Override public Selector selector() {
return Selector.HashCode;
}
@Override protected void onWork(InstanceAlarm message) throws WorkerException {
onNext(message);
}
public static class Factory extends AbstractRemoteWorkerProvider<InstanceAlarm, InstanceAlarm, InstanceMetricAlarmRemoteWorker> {
public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) {
super(moduleManager, remoteSenderService, graphId);
}
@Override public InstanceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) {
return new InstanceMetricAlarmRemoteWorker(moduleManager);
}
}
}

View File

@ -0,0 +1,51 @@
/*
* 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.instance;
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.InstanceAlarm;
import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmList;
/**
* @author peng-yongsheng
*/
public class InstanceMetricAlarmToListNodeProcessor implements NodeProcessor<InstanceAlarm, InstanceAlarmList> {
@Override public int id() {
return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID;
}
@Override public void process(InstanceAlarm instanceAlarm, Next<InstanceAlarmList> next) {
String id = instanceAlarm.getLastTimeBucket() + Const.ID_SPLIT + instanceAlarm.getSourceValue()
+ Const.ID_SPLIT + instanceAlarm.getAlarmType()
+ Const.ID_SPLIT + instanceAlarm.getInstanceId();
InstanceAlarmList instanceAlarmList = new InstanceAlarmList(id);
instanceAlarmList.setApplicationId(instanceAlarm.getApplicationId());
instanceAlarmList.setInstanceId(instanceAlarm.getInstanceId());
instanceAlarmList.setSourceValue(instanceAlarm.getSourceValue());
instanceAlarmList.setAlarmType(instanceAlarm.getAlarmType());
instanceAlarmList.setTimeBucket(instanceAlarm.getLastTimeBucket());
instanceAlarmList.setAlarmContent(instanceAlarm.getAlarmContent());
next.execute(instanceAlarmList);
}
}

View File

@ -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.IInstanceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.core.module.Module;
@ -34,6 +35,6 @@ public class ConfigurationModule extends Module {
}
@Override public Class[] services() {
return new Class[] {IApdexThresholdService.class, IServiceAlarmRuleConfig.class};
return new Class[] {IApdexThresholdService.class, IServiceAlarmRuleConfig.class, IInstanceAlarmRuleConfig.class};
}
}

View File

@ -0,0 +1,34 @@
/*
* 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 IInstanceAlarmRuleConfig extends Service {
double calleeErrorRateThreshold();
double calleeAverageResponseTimeThreshold();
double callerErrorRateThreshold();
double callerAverageResponseTimeThreshold();
}

View File

@ -21,7 +21,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.IApdexThresholdService;
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;
import org.apache.skywalking.apm.collector.configuration.service.ServiceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.core.module.Module;
import org.apache.skywalking.apm.collector.core.module.ModuleProvider;
@ -43,6 +45,7 @@ public class ConfigurationModuleProvider extends ModuleProvider {
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
this.registerServiceImplementation(IApdexThresholdService.class, new ApdexThresholdService());
this.registerServiceImplementation(IServiceAlarmRuleConfig.class, new ServiceAlarmRuleConfig());
this.registerServiceImplementation(IInstanceAlarmRuleConfig.class, new InstanceAlarmRuleConfig());
}
@Override public void start(Properties config) throws ServiceNotProvidedException {

View File

@ -0,0 +1,41 @@
/*
* 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 InstanceAlarmRuleConfig implements IInstanceAlarmRuleConfig {
@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;
}
}

View File

@ -0,0 +1,28 @@
/*
* 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.InstanceAlarmList;
/**
* @author peng-yongsheng
*/
public interface IInstanceAlarmListPersistenceDAO<Insert, Update, DataImpl extends InstanceAlarmList> extends IPersistenceDAO<Insert, Update, DataImpl> {
}

View File

@ -0,0 +1,28 @@
/*
* 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.InstanceAlarm;
/**
* @author peng-yongsheng
*/
public interface IInstanceAlarmPersistenceDAO<Insert, Update, DataImpl extends InstanceAlarm> extends IPersistenceDAO<Insert, Update, DataImpl> {
}

View File

@ -0,0 +1,112 @@
/*
* 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 InstanceAlarm extends Data implements Alarm {
private static final Column[] STRING_COLUMNS = {
new Column(InstanceAlarmTable.COLUMN_ID, new NonOperation()),
new Column(InstanceAlarmTable.COLUMN_ALARM_CONTENT, new CoverOperation()),
};
private static final Column[] LONG_COLUMNS = {
new Column(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET, new CoverOperation()),
};
private static final Column[] DOUBLE_COLUMNS = {};
private static final Column[] INTEGER_COLUMNS = {
new Column(InstanceAlarmTable.COLUMN_ALARM_TYPE, new NonOperation()),
new Column(InstanceAlarmTable.COLUMN_SOURCE_VALUE, new NonOperation()),
new Column(InstanceAlarmTable.COLUMN_APPLICATION_ID, new NonOperation()),
new Column(InstanceAlarmTable.COLUMN_INSTANCE_ID, new NonOperation()),
};
private static final Column[] BOOLEAN_COLUMNS = {};
private static final Column[] BYTE_COLUMNS = {};
public InstanceAlarm(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);
}
public Integer getInstanceId() {
return getDataInteger(3);
}
public void setInstanceId(Integer instanceId) {
setDataInteger(3, instanceId);
}
@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);
}
}

View File

@ -0,0 +1,104 @@
/*
* 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 InstanceAlarmList extends Data {
private static final Column[] STRING_COLUMNS = {
new Column(InstanceAlarmListTable.COLUMN_ID, new NonOperation()),
new Column(InstanceAlarmListTable.COLUMN_ALARM_CONTENT, new CoverOperation()),
};
private static final Column[] LONG_COLUMNS = {
new Column(InstanceAlarmListTable.COLUMN_TIME_BUCKET, new NonOperation()),
};
private static final Column[] DOUBLE_COLUMNS = {};
private static final Column[] INTEGER_COLUMNS = {
new Column(InstanceAlarmListTable.COLUMN_ALARM_TYPE, new NonOperation()),
new Column(InstanceAlarmListTable.COLUMN_SOURCE_VALUE, new NonOperation()),
new Column(InstanceAlarmListTable.COLUMN_APPLICATION_ID, new NonOperation()),
new Column(InstanceAlarmListTable.COLUMN_INSTANCE_ID, new NonOperation()),
};
private static final Column[] BOOLEAN_COLUMNS = {};
private static final Column[] BYTE_COLUMNS = {};
public InstanceAlarmList(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 Integer getInstanceId() {
return getDataInteger(3);
}
public void setInstanceId(Integer instanceId) {
setDataInteger(3, instanceId);
}
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);
}
}

View File

@ -0,0 +1,30 @@
/*
* 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 InstanceAlarmListTable extends CommonMetricTable {
public static final String TABLE = "instance_alarm_list";
public static final String COLUMN_ALARM_TYPE = "alarm_type";
public static final String COLUMN_ALARM_CONTENT = "alarm_content";
}

View File

@ -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.table.alarm;
import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable;
/**
* @author peng-yongsheng
*/
public class InstanceAlarmTable extends CommonMetricTable {
public static final String TABLE = "instance_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";
}