[英]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 的
MeterRegistry
: https://spring.io/projects/spring-boot
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.