簡體   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