From f75270b43a69760280bdfdc091c7eb65818c4d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E5=8B=87=E5=8D=87=20pengys?= <8082209@qq.com> Date: Tue, 4 Sep 2018 21:41:13 +0800 Subject: [PATCH] v6 startup successful. (#1625) * Fixed the startup failure cause by query protocol. * Fixed the bug of startup failure. --- .../alarm/provider/AlarmModuleProvider.java | 24 ++++------ .../src/main/resources/alarm-settings.yml | 44 +++++++++++++++++++ 2 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 oap-server/server-starter/src/main/resources/alarm-settings.yml diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java index b7533bce23..3c228a52a7 100644 --- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java +++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java @@ -18,15 +18,10 @@ package org.apache.skywalking.oap.server.core.alarm.provider; -import java.io.FileNotFoundException; -import java.io.Reader; -import org.apache.skywalking.oap.server.core.alarm.AlarmModule; -import org.apache.skywalking.oap.server.core.alarm.IndicatorNotify; -import org.apache.skywalking.oap.server.library.module.ModuleConfig; -import org.apache.skywalking.oap.server.library.module.ModuleDefine; -import org.apache.skywalking.oap.server.library.module.ModuleProvider; -import org.apache.skywalking.oap.server.library.module.ModuleStartException; -import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException; +import java.io.*; +import org.apache.skywalking.oap.server.core.CoreModule; +import org.apache.skywalking.oap.server.core.alarm.*; +import org.apache.skywalking.oap.server.library.module.*; import org.apache.skywalking.oap.server.library.util.ResourceUtils; public class AlarmModuleProvider extends ModuleProvider { @@ -43,26 +38,25 @@ public class AlarmModuleProvider extends ModuleProvider { } @Override public void prepare() throws ServiceNotProvidedException, ModuleStartException { - - } - - @Override public void start() throws ServiceNotProvidedException, ModuleStartException { Reader applicationReader; try { applicationReader = ResourceUtils.read("alarm-settings.yml"); } catch (FileNotFoundException e) { - throw new ModuleStartException("can't load alarm-settings.yml",e); + throw new ModuleStartException("can't load alarm-settings.yml", e); } RulesReader reader = new RulesReader(applicationReader); Rules rules = reader.readRules(); this.registerServiceImplementation(IndicatorNotify.class, new NotifyHandler(rules)); } + @Override public void start() throws ServiceNotProvidedException, ModuleStartException { + } + @Override public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException { } @Override public String[] requiredModules() { - return new String[0]; + return new String[] {CoreModule.NAME}; } } diff --git a/oap-server/server-starter/src/main/resources/alarm-settings.yml b/oap-server/server-starter/src/main/resources/alarm-settings.yml new file mode 100644 index 0000000000..5ea4ff5041 --- /dev/null +++ b/oap-server/server-starter/src/main/resources/alarm-settings.yml @@ -0,0 +1,44 @@ +# 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. + +rules: + # Rule unique name, must be ended with `_rule`. + endpoint_percent_rule: + # Indicator value need to be long, double or int + indicator-name: endpoint_percent + threshold: 75 + op: < + # The length of time to evaluate the metric + period: 10 + # How many times after the metric match the condition, will trigger alarm + count: 3 + # How many times of checks, the alarm keeps silence after alarm triggered, default as same as period. + silence-period: 10 + service_percent_rule: + indicator-name: service_percent + # [Optional] Default, match all services in this indicator + include-names: + - service_a + - service_b + threshold: 85 + op: < + period: 10 + count: 4 + +#webhooks: +# - http://127.0.0.1/notify/ +# - http://127.0.0.1/go-wechat/ + -- GitLab