提交 b6431900 编写于 作者: wu-sheng's avatar wu-sheng 提交者: 彭勇升 pengys

Add alarm timestamp. (#1741)

上级 9e208d04
......@@ -32,8 +32,12 @@
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>server-core</artifactId>
<version>6.0.0-alpha-SNAPSHOT</version>
<scope>compile</scope>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>library-util</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
......
......@@ -31,6 +31,7 @@ import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.IntValueHolder;
import org.apache.skywalking.oap.server.core.analysis.indicator.LongValueHolder;
import org.apache.skywalking.oap.server.core.source.Scope;
import org.apache.skywalking.oap.server.library.util.TimeBucketUtils;
import org.joda.time.LocalDateTime;
import org.joda.time.Minutes;
import org.joda.time.format.DateTimeFormat;
......@@ -148,6 +149,7 @@ public class RunningRule {
alarmMessage.setId0(meta.getId0());
alarmMessage.setId1(meta.getId1());
alarmMessage.setAlarmMessage(formatter.format(meta));
alarmMessage.setTimeBucket(TimeBucketUtils.INSTANCE.getTime(LocalDateTime.now()));
alarmMessageList.add(alarmMessage);
}
});
......
......@@ -29,4 +29,12 @@
<artifactId>library-util</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -18,8 +18,11 @@
package org.apache.skywalking.oap.server.library.util;
import java.text.*;
import java.util.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import org.joda.time.LocalDateTime;
/**
* @author peng-yongsheng
......@@ -54,6 +57,11 @@ public enum TimeBucketUtils {
return year * 10000000000L + month * 100000000 + day * 1000000 + hour * 10000 + minute * 100 + second;
}
public long getTime(LocalDateTime time) {
return time.getYear() * 10000000000L + time.getMonthOfYear() * 100000000 + time.getDayOfMonth() * 1000000
+ time.getHourOfDay() * 10000 + time.getMinuteOfHour() * 100 + time.getSecondOfMinute();
}
public String formatMinuteTimeBucket(long minuteTimeBucket) throws ParseException {
SimpleDateFormat minuteDateFormat = new SimpleDateFormat("yyyyMMddHHmm");
Date date = minuteDateFormat.parse(String.valueOf(minuteTimeBucket));
......
......@@ -14,29 +14,31 @@
# 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
# Sample alarm rules.
#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
# message: Successful rate of endpoint {name} is lower than 75%
# 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/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册