@SuppressWarnings("unchecked")
    public List<MetricItemValue> getItemValues() throws InstanceNotFoundException, AttributeNotFoundException,
            ReflectionException, MBeanException, MalformedObjectNameException, ClassNotFoundException {
        StringBuilder beanName = new StringBuilder();
        beanName.append(MetricRegister.JMX_DOMAIN).append(MetricItemMBean.DOMAIN_SEPARATOR)
                .append("type=").append(domain)
                .append(MetricItemMBean.PROPERTY_SEPARATOR)
                .append("*");
        ObjectName objName = new ObjectName(beanName.toString());
        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        Set<ObjectInstance> mbeans = mbs.queryMBeans(objName, null);
        LOG.debug("getItemValues for domain:{},queryMBeans:{}", domain, mbeans);
        List<MetricItemValue> itemValues = new ArrayList<>();
        for (ObjectInstance mbean : mbeans) {
            String className = mbean.getClassName();
            Class<?> clazz = ClassUtils.getClass(className);
            if (ClassUtils.isAssignable(clazz, MetricItemMBean.class)) {
                ObjectName metricObjectName = mbean.getObjectName();
                String dimensionsKey = (String) mbs.getAttribute(metricObjectName,
                        MetricItemMBean.ATTRIBUTE_KEY);
                Map<String, String> dimensions = (Map<String, String>) mbs
                        .getAttribute(metricObjectName, MetricItemMBean.ATTRIBUTE_DIMENSIONS);
                Map<String, MetricValue> metrics = (Map<String, MetricValue>) mbs
                        .invoke(metricObjectName, MetricItemMBean.METHOD_SNAPSHOT, null, null);
                MetricItemValue itemValue = new MetricItemValue(dimensionsKey, dimensions, metrics);
                LOG.debug("MetricItemMBean get itemValue:{}", itemValue);
                itemValues.add(itemValue);
            } else if (ClassUtils.isAssignable(clazz, MetricItemSetMBean.class)) {
                ObjectName metricObjectName = mbean.getObjectName();
                List<MetricItem> items =
                        (List<MetricItem>) mbs.invoke(metricObjectName,
                                MetricItemMBean.METHOD_SNAPSHOT, null, null);
                /*
                 * ut will throw classCaseException if use MetricItem without Object
                 */
                for (Object itemT : items) {
                    if (itemT instanceof MetricItem) {
                        MetricItem item = (MetricItem) itemT;
                        String dimensionsKey = item.getDimensionsKey();
                        Map<String, String> dimensions = item.getDimensions();
                        Map<String, MetricValue> metrics = item.snapshot();
                        MetricItemValue itemValue = new MetricItemValue(dimensionsKey, dimensions, metrics);
                        LOG.debug("MetricItemSetMBean get itemValue:{}", itemValue);
                        itemValues.add(itemValue);
                    }
                }
            }
        }
        return itemValues;
    }
getItemValues

@return                              MetricItemValue List
@throws InstanceNotFoundException
@throws AttributeNotFoundException
@throws ReflectionException
@throws MBeanException
@throws MalformedObjectNameException
@throws ClassNotFoundException
inlong-common/src/main/java/org/apache/inlong/common/metric/MetricListenerRunnable.java