繁体   English   中英

向 prometheus 公开 spring 集成 amqp/jms 通道消息指标

[英]Expose spring integration amqp/jms channel messages metrics to prometheus

我正在尝试启用指标以将来自 spring-integration RabbitMq <=> MqSeries 网关的消息统计信息提供给 Prometheus。

文档声明通道必须扩展 AbstractMessageChannel 才能应用指标。 由于我对namespaces非常不舒服,我不确定这里是否是这种情况。
另外,我不明白如何添加 MeterRegistryBean (以及哪个。)以触发指标。
最终,我不明白如何使用它。 基本上,由于我对这里暗示的大多数框架都是新手,所以这里的文档缺少一个可以帮助我更好地理解它的示例。

这是我进行频道定义的方式:

    <!--    *** MQseries  ***       -->
    <!-- ========================== -->
    
    <bean id="jmsConnectionFactory" class="com.ibm.mq.jms.MQConnectionFactory" >
          <property...>
    </bean>
    
    <bean id="jmsConnectionFactory_cred"
        class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
        <property name="targetConnectionFactory" ref="jmsConnectionFactory" />
        <property...>
    </bean> 

    <bean id="connectionFactoryCaching" class="org.springframework.jms.connection.CachingConnectionFactory">
          <property name="targetConnectionFactory" ref="jmsConnectionFactory_cred" />
          <property...>
    </bean> 
    
    <bean id="jmsQueue" class="com.ibm.mq.jms.MQQueue" depends-on="jmsConnectionFactory">
          <property...>
    </bean>
    
    <bean id="fixedBackOff" class="org.springframework.util.backoff.FixedBackOff">
          <property...>
    </bean>
    
    
    <bean id="myListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer" >
        <property...>
        <property name="connectionFactory" ref="connectionFactoryCaching" />
        <property name="destination" ref="jmsQueue" />
    </bean>
    
    <int-jms:message-driven-channel-adapter id="jmsIn" container="myListener" channel="channelMQ_RMQ" error-channel="processChannel1"/>

    <!--    *** Rabbit  ***     -->
    <!-- ====================== -->

    <bean id="connectionAmqpFactoryDest" class="com.rabbitmq.client.ConnectionFactory">
          <property...>
    </bean>

    <!-- Attribute : addresses = List of addresses; e.g. host1,host2:4567,host3 - overrides host/port if supplied. -->
    <rabbit:connection-factory id="rabbitConnectionFactory" 
            connection-factory="connectionAmqpFactoryDest"
            addresses="..." ... />

    <bean id="simpleMessageConverter" class="org.springframework.amqp.support.converter.SimpleMessageConverter">
          <property...>
    </bean>     
    <rabbit:template    id="rabbitTemplate" 
                        connection-factory="rabbitConnectionFactory"  
                        mandatory="true" 
                        channel-transacted="true" 
                        message-converter="simpleMessageConverter"/>

    <int-amqp:outbound-channel-adapter  channel="channelMQ_RMQ" 
                                        ...
                                        amqp-template="rabbitTemplate" />
    

关于我该怎么做的任何想法?

Spring Integration metrics (as well as Spring JMS and Spring AMQP) are fully based on the Micrometer implementation: https://docs.spring.io/spring-integration/docs/current/reference/html/system-management.html#micrometer -整合 如果您使用一些最新的、受支持的 Spring 集成版本: https://spring.io/projects/spring-integration#learn ,这一切都很好。

如果您不使用 Spring Boot,那么您需要在应用程序上下文中声明一个MeterRegistry bean。 并且可能正是针对 Prometheus 的: https://micrometer.io/docs/registry/prometheus

If you are new to the framework, consider to move away from the XML configuration in favor of Java DSL: https://docs.spring.io/spring-integration/docs/current/reference/html/dsl.html#java-单机版

还要让自己熟悉 Spring Boot,它真的为我们自动配置了很多东西,甚至是 Prometheus 的MeterRegistryhttps://spring.io/projects/spring-boot

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM