You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/10/02 16:33:35 UTC

[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #5615: Support group concept in the alarm core

kezhenxu94 commented on a change in pull request #5615:
URL: https://github.com/apache/skywalking/pull/5615#discussion_r498901948



##########
File path: docs/en/setup/backend/backend-alarm.md
##########
@@ -41,10 +43,16 @@ Such as in **percentile**, `value1` is threshold of P50, and `-, -, value3, valu
 backend deployment env time.
 - **Count**. In the period window, if the number of **value**s over threshold(by OP), reaches count, alarm
 should send.
+- **Only as condition**. Specify if the rule can send notfiy or just as an conditon of composite rule

Review comment:
       ```suggestion
   - **Only as condition**. Specify if the rule can send notification or just as an condition of composite rule
   ```

##########
File path: oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmRulesWatcher.java
##########
@@ -46,16 +48,24 @@
     private volatile Map<AlarmRule, RunningRule> alarmRuleRunningRuleMap;
     private volatile Rules rules;
     private volatile String settingsString;
+    @Getter
+    private volatile CompositeRuleEvaluator compositeRuleEvaluator;

Review comment:
       `compositeRuleEvaluator` is effectively `final`, and doesn't need `volatile`

##########
File path: oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/CompositeRuleEvaluator.java
##########
@@ -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.oap.server.core.alarm.provider;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.Multimaps;
+import lombok.AllArgsConstructor;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.alarm.AlarmMessage;
+import org.apache.skywalking.oap.server.core.alarm.provider.expression.Expression;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Evaluator composite rule using expression eval
+ *
+ * @since 8.2.0
+ */
+@AllArgsConstructor
+public class CompositeRuleEvaluator {
+
+    private Expression expression;
+
+    /**
+     * Evaluator composite rule
+     *
+     * @param compositeAlarmRules compositeRules
+     * @param alarmMessages       triggered alarm messages
+     * @return
+     */
+    public List<AlarmMessage> evaluator(List<CompositeAlarmRule> compositeAlarmRules, List<AlarmMessage> alarmMessages) {

Review comment:
       Same as the comments above (the method and the class)

##########
File path: docs/en/setup/backend/backend-alarm.md
##########
@@ -60,6 +68,8 @@ rules:
     count: 3
     # How many times of checks, the alarm keeps silence after alarm triggered, default as same as period.
     silence-period: 10
+    # Specify if the rule can send notfiy or just as an conditon of composite rule

Review comment:
       ```suggestion
       # Specify if the rule can send notification or just as an condition of composite rule
   ```

##########
File path: oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/CompositeRuleEvaluator.java
##########
@@ -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.oap.server.core.alarm.provider;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.Multimaps;
+import lombok.AllArgsConstructor;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.alarm.AlarmMessage;
+import org.apache.skywalking.oap.server.core.alarm.provider.expression.Expression;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Evaluator composite rule using expression eval
+ *
+ * @since 8.2.0
+ */
+@AllArgsConstructor
+public class CompositeRuleEvaluator {
+
+    private Expression expression;
+
+    /**
+     * Evaluator composite rule
+     *
+     * @param compositeAlarmRules compositeRules
+     * @param alarmMessages       triggered alarm messages
+     * @return
+     */
+    public List<AlarmMessage> evaluator(List<CompositeAlarmRule> compositeAlarmRules, List<AlarmMessage> alarmMessages) {
+        final List<AlarmMessage> compositeRuleMessages = new ArrayList<>();
+        ImmutableListMultimap<String, AlarmMessage> messageMap = Multimaps.index(alarmMessages, alarmMessage -> Joiner.on(Const.ID_CONNECTOR).useForNull(Const.EMPTY_STRING).join(alarmMessage.getId0(), alarmMessage.getId1()));

Review comment:
       Super long, please break the line




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org