public static List<Rule> loadRules(final String path, List<String> enabledRules) throws IOException {

        final Path root = ResourceUtils.getPath(path);

        Map<String, Boolean> formedEnabledRules = enabledRules
                .stream()
                .map(rule -> {
                    rule = rule.trim();
                    if (rule.startsWith("/")) {
                        rule = rule.substring(1);
                    }
                    if (!rule.endsWith(".yaml") && !rule.endsWith(".yml")) {
                        return rule + "{.yaml,.yml}";
                    }
                    return rule;
                })
                .collect(Collectors.toMap(rule -> rule, $ -> false));
        List<Rule> rules;
        try (Stream<Path> stream = Files.walk(root)) {
            rules = stream
                    .filter(it -> formedEnabledRules.keySet().stream()
                                    .anyMatch(rule -> {
                                        boolean matches = FileSystems.getDefault().getPathMatcher("glob:" + rule)
                                                .matches(root.relativize(it));
                                        if (matches) {
                                            formedEnabledRules.put(rule, true);
                                        }
                                        return matches;
                                    }))
                    .map(pathPointer -> {
                        // Use relativized file path without suffix as the rule name.
                        String relativizePath = root.relativize(pathPointer).toString();
                        String ruleName = relativizePath.substring(0, relativizePath.lastIndexOf("."));
                        return getRulesFromFile(ruleName, pathPointer);
                    })
                    .filter(Objects::nonNull)
                    .collect(Collectors.toList()) ;
        }

        if (formedEnabledRules.containsValue(false)) {
            List<String> rulesNotFound = formedEnabledRules.keySet().stream()
                    .filter(rule -> !formedEnabledRules.get(rule))
                    .collect(Collectors.toList());
            throw new UnexpectedException("Some configuration files of enabled rules are not found, enabled rules: " + rulesNotFound);
        }
        return rules;
    }
Rules is factory to instance {@link Rule} from a local file.
oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/prometheus/rule/Rules.java