private void autoMatchingServiceRelation() {
        List<Service> allServices = getMetadataQueryService().listAllServices()
                                                             .values()
                                                             .stream()
                                                             .flatMap(List::stream)
                                                             .collect(Collectors.toList());
        if (allServices.size() > 1) {
            for (int i = 0; i < allServices.size(); i++) {
                for (int j = i + 1; j < allServices.size(); j++) {
                    Service service = allServices.get(i);
                    Service comparedService = allServices.get(j);
                    String serviceLayer = service.getLayers().iterator().next();
                    String comparedServiceLayer = comparedService.getLayers().iterator().next();
                    Map<String, HierarchyDefinitionService.MatchingRule> lowerLayers = getHierarchyDefinition().get(
                        serviceLayer);
                    Map<String, HierarchyDefinitionService.MatchingRule> comparedLowerLayers = getHierarchyDefinition().get(
                        comparedServiceLayer);
                    if (lowerLayers != null && lowerLayers.get(comparedServiceLayer) != null) {
                        try {
                            if (lowerLayers.get(comparedServiceLayer)
                                           .getClosure()
                                           .call(service, comparedService)) {
                                autoMatchingServiceRelation(service.getName(), Layer.nameOf(serviceLayer),
                                                            comparedService.getName(),
                                                            Layer.nameOf(comparedServiceLayer)
                                );
                            }
                        } catch (Throwable e) {
                            log.error(
                                "Auto matching service hierarchy from service traffic failure. Upper layer {}, lower layer {}, closure{}",
                                serviceLayer,
                                comparedServiceLayer,
                                lowerLayers.get(comparedServiceLayer).getExpression(), e
                            );
                        }

                    } else if (comparedLowerLayers != null && comparedLowerLayers.get(serviceLayer) != null) {
                        try {
                            if (comparedLowerLayers.get(serviceLayer)
                                                   .getClosure()
                                                   .call(comparedService, service)) {
                                autoMatchingServiceRelation(
                                    comparedService.getName(),
                                    Layer.nameOf(comparedServiceLayer),
                                    service.getName(),
                                    Layer.nameOf(serviceLayer)
                                );
                            }
                        } catch (Throwable e) {
                            log.error(
                                "Auto matching service hierarchy from service traffic failure. Upper layer {}, lower layer {}, closure{}",
                                comparedServiceLayer,
                                serviceLayer,
                                comparedLowerLayers.get(serviceLayer).getExpression(), e
                            );
                        }
                    }
                }
            }
        }
    }
Build the hierarchy relation between the 2 instances. the `serviceLayer` and `relatedServiceLayer` hierarchy
relations should be defined in `config/hierarchy-definition.yml`.

@param upperInstanceName        the name of the upper instance
@param upperServiceName         the name of the upper service
@param upperServiceLayer        the layer of the upper service
@param lowerInstanceName the name of the lower related instance
@param lowerServiceName  the name of the lower related service
@param lowerServiceLayer the layer of the lower related service
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/hierarchy/HierarchyService.java