Kafka messaging with spring boot
management.endpoints.web.exposure.include=*
http://localhost:8080/actuator
management.endpoints.web.exposure.exclude=info,beans
management.endpoints.enabled-by-default=false
Format
management.endpoint.{EndpointName}.enabled=true/false
Example
management.endpoint.health.enabled=true
http://localhost:8080/actuator/health
management.endpoint.health.show-details=ALWAYS
Format
management.endpoint.health.group.{group-name}.include=ping,diskSpace
Example\
management.endpoint.health.group.health-group.include=ping,diskSpace
Format
http://localhost:8080/actuator/health/{group-name}
Example:
http://localhost:8080/actuator/health/health-group
management.endpoints.web.base-path=/manage
Example:
http://localhost:8080/actuator/health/health-group
Format:\
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.{endpoint}={mapped-path}
Example:\
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=healthcheck
We need to implement HealthIndicator interface
@Component
public class KafkaHealthIndicator implements HealthIndicator {
@Override
public Health health() {
if(isKafkaHealthy()) {
return Health.up().withDetail("Kafka", "Healthy").build();
}
return Health.down().withDetail("Kafka", "Unhealthy").build();
}
}
import java.util.HashMap;
@Endpoint(id = "custom")
@Component
public class CustomActEndpoint {
@ReadOperation
public Map<String, String> customEndpoint(String id) {
Map<String, String> map = new HashMap<>();
map.put("id", id);
return map;
}
}
Access the custom endpoint with:
http://localhost:8080/actuator/custom
docker pull prom/prometheus
docker run -d --name=prometheus -p 9090:9090 -v {path_of_prometheus.yml_file}:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml