Health Check for Apache Kafka
Go to file
bvn13 167360566a Update for next development version 2022-06-30 12:07:02 +03:00
.mvn/wrapper Add maven wrapper and rename travis file 2019-04-26 17:03:44 +02:00
src added feature toggling for enabling/disabling 2022-06-30 12:06:07 +03:00
.editorconfig Add .editorconfig file for common code style 2019-10-28 10:57:03 +01:00
.gitignore Develop kafka health check 2019-03-28 16:35:14 +01:00
.travis.yml Fix travis ci issues 2019-09-10 10:54:20 +02:00
LICENSE Initial commit 2019-03-28 11:36:12 +01:00
README.md added feature toggling for enabling/disabling 2022-06-30 12:06:07 +03:00
changelog.md updated changelog 2022-06-28 22:27:19 +03:00
mvnw Add maven wrapper and rename travis file 2019-04-26 17:03:44 +02:00
mvnw.cmd Add maven wrapper and rename travis file 2019-04-26 17:03:44 +02:00
pom.xml Update for next development version 2022-06-30 12:07:02 +03:00

README.md

Kafka Health Check

Note. forked from deviceinsight/kafka-health-check due to long period of inactivity

This library provides a kafka health check for spring boot actuator.

Usage

Add the following dependency to your pom.xml

<dependency>
    <groupId>me.bvn13.kafka.health</groupId>
    <artifactId>kafka-health-check</artifactId>
    <version>1.5.5</version>
</dependency>

In the same maven module you can configure the topic, poll timeouts and the reception timeouts in the application.yaml

An example for an application.yaml is:

kafka:
  health:
    topic: health-checks
    sendReceiveTimeout: 2.5s
    pollTimeout: 200ms

The values shown are the defaults.

IMPORTANT: Make sure the configured health check topic exists!

@Bean
@ConfigurationProperties("kafka.health")
public KafkaHealthProperties kafkaHealthProperties() {
    return new KafkaHealthProperties();
}
@Bean
public KafkaConsumingHealthIndicator kafkaConsumingHealthIndicator(KafkaHealthProperties kafkaProperties,
        KafkaProperties processingProperties) {
    return new KafkaConsumingHealthIndicator(kafkaHealthProperties, processingProperties.buildConsumerProperties(),
            processingProperties.buildProducerProperties());
}

Now if you call the actuator endpoint actuator/health you should see the following output:

{
   "status" : "UP",
   "details" : {
      "kafkaConsuming" : {
         "status" : "UP"
      }
   }
}

Configuration

Property Default Description
kafka.health.enabled false Enabling kafka health check
kafka.health.topic health-checks Topic to subscribe to
kafka.health.sendReceiveTimeout 2.5s The maximum time, given as Duration, to wait for sending and receiving the message.
kafka.health.pollTimeout 200ms The time, given as Duration, spent fetching the data from the topic
kafka.health.cache.maximumSize 200 Specifies the maximum number of entries the cache may contain.

Releasing

Creating a new release involves the following steps:

  1. ./mvnw gitflow:release-start gitflow:release-finish
  2. git push origin master
  3. git push --tags
  4. git push origin develop

In order to deploy the release to Maven Central, you need to create an account at https://issues.sonatype.org and configure your account in ~/.m2/settings.xml:

<settings>
  <servers>
    <server>
      <id>ossrh</id>
      <username>your-jira-id</username>
      <password>your-jira-pwd</password>
    </server>
  </servers>
</settings>

The account also needs access to the project on Maven Central. This can be requested by another project member.

Then check out the release you want to deploy (git checkout x.y.z) and run ./mvnw deploy -Prelease.