We are using 2.1.3 version for spring cloud stream kafka streams -
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka-streams</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka-core</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-kafka</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
application.yml has property set -
management.health.binders.enabled = true
management.health.kafka.enabled = true
But we are still get the status as UNKNOWN for kafka binders -
"binders": {
"status": "UNKNOWN",
"details": {
"ktable": {
"status": "UNKNOWN"
},
"kstream": {
"status": "UNKNOWN"
},
"globalktable": {
"status": "UNKNOWN"
}
}
}
Appreciate any help on this.
The health indicators for Kafka Streams family of binders only went into the 2.2 line. Any chance you can upgrade to 2.2 from 2.1.3? Here is an application where the health indicators are working. This is using the 3.0 snapshots, but 2.2 also should work. When running this app, I am getting the output as below.
curl --silent http://localhost:8080/actuator/health/ | jq .
{
"status": "UP",
"components": {
"binders": {
"status": "UP",
"components": {
"globalktable": {
"status": "UP",
"details": {
"threadState": "RUNNING",
"standbyTasks": {},
"activeTasks": {
"partitions": [
"partition=0, topic=process-applicationId-KSTREAM-AGGREGATE-STATE-STORE-0000000003-repartition"
],
"taskId": "1_0"
},
"threadName": "process-applicationId-fa4e65eb-6060-43f0-94eb-4c4bf1497613-StreamThread-1"
}
},
"kstream": {
"status": "UP",
"details": {
"threadState": "RUNNING",
"standbyTasks": {},
"activeTasks": {
"partitions": [
"partition=0, topic=process-applicationId-KSTREAM-AGGREGATE-STATE-STORE-0000000003-repartition"
],
"taskId": "1_0"
},
"threadName": "process-applicationId-fa4e65eb-6060-43f0-94eb-4c4bf1497613-StreamThread-1"
}
},
"ktable": {
"status": "UP",
"details": {
"threadState": "RUNNING",
"standbyTasks": {},
"activeTasks": {
"partitions": [
"partition=0, topic=process-applicationId-KSTREAM-AGGREGATE-STATE-STORE-0000000003-repartition"
],
"taskId": "1_0"
},
"threadName": "process-applicationId-fa4e65eb-6060-43f0-94eb-4c4bf1497613-StreamThread-1"
}
}
}
},
"diskSpace": {
"status": "UP",
"details": {
...
}
},
"ping": {
"status": "UP"
}
}
}
Note - The issue mentioned in the comments below where multiple processor's health information is not shown is addressed in the latest snapshots of the binder (3.0.0) and will be available as part of RC1.
Related
I have a Spring boot application with actuator enabled so that I can use the /actuator/health URIs as probes. My application talks to redis, JMS and cosmos so those are checked as part of the health response.
When I run the application at my command prompt I get the following JSON response, with a HTTP 200 code indicating all is well.
{
"status": "UP",
"components": {
"cosmos": {
"status": "UP",...
},
"diskSpace": {
"status": "UP",...
},
"grpcChannel": {
"status": "UP",...
},
"jms": {
"status": "UP",...
}
},
"ping": {
"status": "UP"
},
"redis": {
"status": "UP",...
}
}
}
When I deploy the application to a K8S environment (Rancher locally or Azure in the cloud) the application knows it is now in a K8S environment and so adds some additional stuff to the health check. However while the main components are all UP - as for the local run - I now get a 503 Service Unavailable response code and the livenessState is DOWN and the readinessState is OUT_OF_SERVICE.
{
"status": "DOWN",
"components": {
"cosmos": {
"status": "UP",...
},
"diskSpace": {
"status": "UP",...
},
"grpcChannel": {
"status": "UP",...
},
"jms": {
"status": "UP",...
}
},
"livenessState": {
"status": "DOWN"
},
"ping": {
"status": "UP"
},
"readinessState": {
"status": "OUT_OF_SERVICE"
},
"redis": {
"status": "UP",
"details": {
"cluster_size": 3,
"slots_up": 16384,
"slots_fail": 0
}
}
},
"groups": [
"liveness",
"readiness"
]
}
What additional checks is the actuator doing when in K8S and what do I need to do for actuator to report it is all OK? Any suggestions as to how to troubleshoot the problem?
I have searched for more information on SO and the wider web, but cannot find anything that helps find out what the K8S checks are specifically looking for.
Thank you.
I make an API with Springboot
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<version>2.7.5</version>
</dependency>
#RepositoryRestResource
When i make a curl or http call in the browser, i get the data (an array of data):
curl -X 'GET' \
'http://localhost:8083/hospitals?page=0&size=20' \
-H 'accept: **application/hal+json**'
{
"_embedded": {
"hospitals": [
{
"latitude": 51.37999725341797,
"longitude": -0.40604206919670105,
"webSite": "",
"parentName": "Virgin Care Services Ltd",
"email": "",
"organisationID": 17970,
"organisationCode": "NDA07",
"organisationType": null,
"organisationName": "Walton Community Hospital - Virgin Care Services Ltd",
"address1": "",
"address2": "Rodney Road",
"address3": "",
"city": "Walton-on-Thames",
"county": "Surrey",
"postcode": "KT12 3LD",
"parentODSCode": "NDA",
"phone": "01932 414205",
"fax": "01932 253674",
"_links": {
"self": {
"href": "http://localhost:8083/hospitals/0"
},
"hospital": {
"href": "http://localhost:8083/hospitals/0"
},
"specialtiesServices": {
"href": "http://localhost:8083/hospitals/0/specialtiesServices"
}
}
},
{
"latitude": 51.31513214111328,
"longitude": -0.5562894940376282,
"webSite": "",
"parentName": "Virgin Care Services Ltd",
"email": "",
"organisationID": 17981,
"organisationCode": "NDA18",
"organisationType": null,
"organisationName": "Woking Community Hospital (Virgin Care)",
"address1": "",
"address2": "Heathside Road",
"address3": "",
"city": "Woking",
"county": "Surrey",
"postcode": "GU22 7HS",
"parentODSCode": "NDA",
"phone": "01483 715911",
"fax": "",
"_links": {
"self": {
"href": "http://localhost:8083/hospitals/2"
},
"hospital": {
"href": "http://localhost:8083/hospitals/2"
},
"specialtiesServices": {
"href": "http://localhost:8083/hospitals/2/specialtiesServices"
}
}
}
]
},
"_links": {
"first": {
"href": "http://localhost:8083/hospitals?page=0&size=2"
},
"self": {
"href": "http://localhost:8083/hospitals?page=0&size=2"
},
"next": {
"href": "http://localhost:8083/hospitals?page=1&size=2"
},
"last": {
"href": "http://localhost:8083/hospitals?page=100&size=2"
},
"profile": {
"href": "http://localhost:8083/profile/hospitals"
},
"search": {
"href": "http://localhost:8083/hospitals/search"
}
},
"page": {
"size": 2,
"totalElements": 201,
"totalPages": 101,
"number": 0
}
}
but when i use TestRestTemplate the body is empty.
It's work for single object but not for list of object.
ResponseEntity<PagedModel<Hospital>> pageResources;
ParameterizedTypeReference<PagedModel<Hospital>> responseType;
responseType = new ParameterizedTypeReference<PagedModel<Hospital>>() { };
pageResources = initResttemplate().exchange(getUrl(arg0),HttpMethod.GET,HttpEntity.EMPTY, responseType);
Assertions.assertNotNull(pageResources.getBody());
This is the content of the response in debug mode.
PagedModel { content: [], fallbackType: null, metadata: Metadata { number: 0, total pages: 11, total elements: 201, size: 20 }, links: }
What type of object i need to use for consume my list of object ?
I had the same problem before.
I read some more comments and documentation and found this solution for me.
You have to register the hypermedia support for the rest template.
Now a small code snippet adapted to your code.
public class TestClass {
#Autowired
public HypermediaRestTemplateConfigurer configurer;
public void myMethod(){
ResponseEntity<PagedModel<Hospital>> pageResources;
ParameterizedTypeReference<PagedModel<Hospital>> responseType;
responseType = new ParameterizedTypeReference<PagedModel<Hospital>>() { };
//configurer.registerHypermediaTypes() arround the RestTemplate not RestTestTemplate, else RestTestTemplate.getRestTemplate()
pageResources = configurer.registerHypermediaTypes(initResttemplate()).exchange(getUrl(arg0),HttpMethod.GET,HttpEntity.EMPTY, responseType);
Assertions.assertNotNull(pageResources.getBody());
}
}
Sometimes you need an extra annotation. But I did not need it in my case.
Here is the link if the code above does not work completely:
Spring HATEOS : Consider defining a bean of type 'org.springframework.hateoas.config.HypermediaRestTemplateConfigurer' in your configuration
I upgraded my apps from SpringBoot 2.1.18 to SpringBoot 2.5.7 and I see that health details such as diskSpace no longer show up in SpringBootAdmin UI after the upgrade. I am using SBA 2.0.0 and have not changed that.
The health endpoint still includes them, but the top level key has been renamed from details to components. I assumed that was what was confusing SBA, but even stranger my custom health indicator still displays in SBA despite this.
Any idea how I can solve this?
old
{
"status": "OUT_OF_SERVICE",
"details": {
"myCustomHealthIndicator": {
"status": "OUT_OF_SERVICE",
"details": {
"Reason": "Suspect State message received",
"StateText": "Connection failed; Channel disconnected"
}
},
"diskSpace": {
"status": "UP",
"details": {
"total": 107361579008,
"free": 94436716544,
"threshold": 10485760
}
},
"refreshScope": {
"status": "UP"
}
}
}
new
{
"status": "OUT_OF_SERVICE",
"components": {
"diskSpace": {
"status": "UP",
"details": {
"total": 107361579008,
"free": 100102447104,
"threshold": 10485760,
"exists": true
}
},
"livenessState": {
"status": "UP"
},
"ping": {
"status": "UP"
},
"readinessState": {
"status": "UP"
},
"myCustomHealthIndicator": {
"status": "OUT_OF_SERVICE",
"details": {
"Reason": "Suspect State message received",
"StateText": "Connection failed; Channel disconnected"
}
}
},
"groups": [
"liveness",
"readiness"
]
}
Solved by upgrading to Spring Boot Admin Server 2.5.4 ( de.codecentric:spring-boot-admin-starter-server:jar:2.5.4 )
I am trying to implement a new project with OpenAPI 3 and Java 16. Every time I am trying to build I am seeing errors due to internal dependencies.
This is the error I am seeing every time I try to build.
[JAVA] java.lang.reflect.InaccessibleObjectException: Unable to make public boolean java.util.Collections$EmptyMap.isEmpty() accessible
I just want to know if people have used OpenAPI 3 with Java 16 and if did what dependencies they have used.
I was curious and just created a Java 16 Spring Boot 2.5.2 application with spring-boot-starter-web via https://start.spring.io. Then I added a #RestController and this springdoc dependency:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<version>1.5.9</version>
</dependency>
At least that worked.
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost:8080",
"description": "Generated server url"
}
],
"paths": {
"/hello": {
"get": {
"tags": [
"my-controller"
],
"operationId": "hello",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
}
}
},
"components": {}
}
I am implementing my Alexa Home Skill using AWS Lambda.
Given the following request I receive when I try to detect new devices on Alexa Skil test page:
{directive={header={namespace=Alexa.Discovery, name=Discover, payloadVersion=3, messageId=0160c7e7-031f-47ee-a1d9-a23f38f87a9e}, payload={scope={type=BearerToken, token=...}}}}
I respond with the following:
{
"event": {
"payload": {
"endpoints": [
{
"displayCategories": [
"SMARTPLUG"
],
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3"
},
{
"type": "AlexaInterface",
"interface": "Alexa.PowerController",
"version": "3",
"properties": {
"retrievable": true,
"supported": [
{
"name": "powerState"
}
],
"proactivelyReported": true
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.EndpointHealth",
"version": "3",
"properties": {
"retrievable": true,
"supported": [
{
"name": "connectivity"
}
],
"proactivelyReported": true
}
}
],
"manufacturerName": "mirko.io",
"endpointId": "ca84ef6d-53b1-430a-8a5e-a62f174eac5e",
"description": "mirko.io forno (id: ca84ef6d-53b1-430a-8a5e-a62f174eac5e)",
"friendlyName": "forno"
}
]
},
"header": {
"payloadVersion": "3",
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"messageId": "c0555cc8-ad7a-4377-b310-9de9b9ab6282"
}
}
}
Despite that, for some reasons Alexa answers that it did not find any new device.
I may be mistaken but I am pretty sure it used to work before I decided to add the Alexa.EndpointHealth interface.
Your response object looks right to me, except the extra "endpoint" field.
"endpoint": {
"endpointId": "INVALID",
"scope": {
"type": "BearerToken",
"token": "INVALID"
}
}
There's no such field in the Alexa.Discovery documentation. Try removing it and see if it resolves the issue.