I figured I’d share a quick post on how to use Spring Boot Actuator with Spring Cloud Stream microservices as it might be useful for others (And me when I want to set this up again in a month! ?). This allows you to make simple GET requests to see config, state, and stats about your bindings and channels for monitoring or troubleshooting purposes.
- Include
spring-boot-starter-actuator
andspring-boot-starter-web
in your pom for your Cloud Stream microservice (you can also add them via Spring Initializr if you’re using that).
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
- Enable in your application config. You can include items one at a time (like bindings below or use the “*” to include anything available). Don’t expose all of this in production without researching it more!
spring:
jackson:
serialization:
indent-output: true
management:
endpoints:
web:
exposure:
include:
- bindings
- "*"
server:
port: 8081
- Start your app and run a query!
A few that I find useful:
- Find your bindings: http://localhost:8081/actuator/bindings
- Query a specific binding: http://localhost:8081/actuator/bindings/<binding_name>
- Find available channels: http://localhost:8081/actuator/channels
- See the Integration Graph (this includes stats, such as message counts) http://localhost:8081/actuator/integrationgraph
Example response for my input binding (http://localhost:8081/actuator/bindings/input)
{
"bindingName" : "input",
"name" : "input",
"group" : "consumerGroup",
"pausable" : false,
"state" : "running",
"extendedInfo" : {
"bindingDestination" : "SolaceConsumerDestination{queueName='input.consumerGroup'}",
"ExtendedConsumerProperties" : {
"autoStartup" : true,
"concurrency" : 5,
"instanceCount" : 1,
"maxAttempts" : 3,
"backOffInitialInterval" : 1000,
"backOffMaxInterval" : 10000,
"backOffMultiplier" : 2.0,
"defaultRetryable" : true,
"extension" : {
"prefix" : "",
"provisionDurableQueue" : true,
"provisionSubscriptionsToDurableQueue" : true,
"queueAccessType" : 0,
"queuePermission" : 2,
"queueDiscardBehaviour" : null,
"queueMaxMsgRedelivery" : null,
"queueMaxMsgSize" : null,
"queueQuota" : null,
"queueRespectsMsgTtl" : null,
"anonymousGroupPostfix" : "anon",
"polledConsumerWaitTimeInMillis" : 100,
"requeueRejected" : false,
"queueAdditionalSubscriptions" : [ "topic/>", "a/*/c" ],
"autoBindDmq" : false,
"provisionDmq" : true,
"dmqAccessType" : 0,
"dmqPermission" : 2,
"dmqDiscardBehaviour" : null,
"dmqMaxMsgRedelivery" : null,
"dmqMaxMsgSize" : null,
"dmqQuota" : null,
"dmqRespectsMsgTtl" : null,
"republishedMsgTtl" : null
}
}
},
"input" : true
}
Hope that’s helpful!
-Marc