@Test
    public void testExcludeNamesRegex() throws IllegalExpressionException {
        AlarmRule alarmRule = new AlarmRule(null);
        alarmRule.setAlarmRuleName("endpoint_percent_rule");
        alarmRule.setExpression("sum(endpoint_percent < 1000) >= 1");
        alarmRule.getIncludeMetrics().add("endpoint_percent");
        alarmRule.setPeriod(10);
        alarmRule.setMessage(
            "Response time of service instance {name} is more than 1000ms in 2 minutes of last 10 minutes");
        alarmRule.setExcludeNamesRegex("Service\\_2(\\d)+");
        alarmRule.setTags(new HashMap<String, String>() {{
            put("key", "value");
        }});
        RunningRule runningRule = new RunningRule(alarmRule, null);

        DateTime startTime = DateTime.now();
        long timeInPeriod1 = TimeBucket.getMinuteTimeBucket(startTime.minusMinutes(6).getMillis());
        long timeInPeriod2 = TimeBucket.getMinuteTimeBucket(startTime.minusMinutes(4).getMillis());
        long timeInPeriod3 = TimeBucket.getMinuteTimeBucket(startTime.minusMinutes(1).getMillis());

        runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod1, 70));
        runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod2, 70));
        runningRule.in(getMetaInAlarm(223), getMetrics(timeInPeriod3, 74));

        // check at startTime - 1
        Assertions.assertEquals(1, runningRule.check().size());

        // check at startTime
        runningRule.moveTo(startTime.toLocalDateTime());
        Assertions.assertEquals(1, runningRule.check().size());

        // check at startTime + 6
        runningRule.moveTo(startTime.plusMinutes(6).toLocalDateTime());
        Assertions.assertEquals(0, runningRule.check().size());
    }
Running rule is the core of how does alarm work.
<p>
So in this test, we need to simulate a lot of scenario to see the reactions.
oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRuleTest.java