简体   繁体   English

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

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

I am trying to enable metrics to feed message statistics from a spring-integration RabbitMq <=> MqSeries gateway into Prometheus.我正在尝试启用指标以将来自 spring-integration RabbitMq <=> MqSeries 网关的消息统计信息提供给 Prometheus。

The documentation states that the channel must extends AbstractMessageChannel in order the metrics to apply. 文档声明通道必须扩展 AbstractMessageChannel 才能应用指标。 Since I am quite uncomfortable with namespaces , I am not sure if this is the case here.由于我对namespaces非常不舒服,我不确定这里是否是这种情况。
Also, I don't understand how to add a MeterRegistryBean (and which one.) in order to trigger the metrics on.另外,我不明白如何添加 MeterRegistryBean (以及哪个。)以触发指标。
And eventually, I don't understand how to use it.最终,我不明白如何使用它。 Basically, since I am new to most of the framework implied here, the documentation here lacks an example that could help me understand it a little better.基本上,由于我对这里暗示的大多数框架都是新手,所以这里的文档缺少一个可以帮助我更好地理解它的示例。

Here's how I do my channel definition:这是我进行频道定义的方式:

    <!--    *** 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" />
    

Any idea on how I can do that?关于我该怎么做的任何想法?

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-integration . 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 -整合 That all is good if you use some of the latest, supported Spring Integration version: https://spring.io/projects/spring-integration#learn .如果您使用一些最新的、受支持的 Spring 集成版本: https://spring.io/projects/spring-integration#learn ,这一切都很好。

If you don't use Spring Boot, then you need to declare a MeterRegistry bean in the application context.如果您不使用 Spring Boot,那么您需要在应用程序上下文中声明一个MeterRegistry bean。 And probably the one exactly for Prometheus: https://micrometer.io/docs/registry/prometheus .并且可能正是针对 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-dsl . 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-单机版

Also make yourself familiar with Spring Boot which really auto-configurs for us many things, even a MeterRegistry for Prometheus: https://spring.io/projects/spring-boot还要让自己熟悉 Spring Boot,它真的为我们自动配置了很多东西,甚至是 Prometheus 的MeterRegistryhttps://spring.io/projects/spring-boot

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

相关问题 使用Spring Integration AMQP和RabbitMQ丢失和“未经处理”的消息 - Lost and “unacked” messages with Spring Integration AMQP and RabbitMQ Spring Integration,JMS入站通道适配器和事务 - Spring Integration, JMS Inbound channel adaptor and transactions Spring Integration JMS 消费者不消耗所有消息 - Spring Integration JMS Consumers not consuming all messages 如何向 Prometheus 公开 Dropwizard 指标 - How to expose Dropwizard Metrics to Prometheus Spring Integration AMQP通道错误处理程序自动确认 - spring integration amqp channel error handler auto ack RabbitMQ BasicAck 在控制台上提供通道关闭错误消息 - Spring AMQP - RabbitMQ BasicAck giving channel shutdown error messages on console - Spring AMQP Spring 集成:以列表形式获取频道中的消息 - Spring integration : Get messages in channel as List 使用选择器的Spring Integration JMS消息驱动的通道适配器 - spring integration JMS message driven channel adaptor using selector 将应用程序迁移到Spring Boot 2之后,无法将hystrix指标公开给/ actuator / prometheus - Can't expose hystrix metrics to /actuator/prometheus after migrating application to Spring boot 2 无法将 Flink 指标公开给 Prometheus - Can't expose Flink metrics to Prometheus
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM