-
Notifications
You must be signed in to change notification settings - Fork 41.2k
2.1.6 SPRING BOOT - Elasticsearch Healthcheck failure using Spring Actuator #19384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for getting in touch, but it feels like this is a question that would be better suited to StackOverflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug. The connection is refused in that other environment.
Feel free to reply with a link to your stackoverflow question. |
No problem, thank you. Here is the stack overflow URL: Regarding your first question, hmm... I believe we are using the ES REST client configured by Spring Boot. I'm a new intern so I didn't write the codebase and I'm new to Spring to be honest. I used an @Autowired annotation to inject the dependency (ESClient) into the IndexExists.java file. This is the code:
The ESClient class looks like this (constructor and method I used, don't want to list the other methods in it and clutter this post):
I didn't quite understand what you were suggesting in bullet point #2. I tested the Healthcheck monitor locally (i.e. after I added the "IndexExists.java" class and added the rest: uri: ['localhost:9200'] ) and it worked fine. I work at a company and this is a user story I was working on as an Intern, so we use Azure DevOps pipelines to build the image and "deploy to dev". Thus, this is where the first issue was encountered. The "deploy to dev" stage was infinitely looping or hanging for about 30minutes... And another software engineer at the company looked at the AWS logs with me (CloudWatch) and we saw the "connection refused" messages to Elasticsearch. And we could see the Load Balancer attempting to create more containers because it thought the health check failed. Thanks for the help thus far. |
OK, looks like I had a misconfigured properties in Application.yml that wasn't allowing connection for ElasticsearchRest to be Autoconfigured. You can refer to this in the stack overflow link https://stackoverflow.com/questions/59379279/2-1-6-spring-boot-elasticsearch-healthcheck-failurefailure above and the code is in one of the comments Brian wrote, also thanks again to @bclozel for his help |
Hi, I'm working at my company as a Software Engineering intern (show me mercy) and I was adding and health check feature to our Elasticsearch service. Simply, I utilized the Spring Actuator, like from this guide (bullet point 3.3 most specifically) Spring Actuator Healthcheck Guide
I simply created a new class, "IndexExists.java" and implemented the HealthIndicator() interface. We have an "Application.yml" file in the service/service-api/src/main/resources directory, so I went in there as-well and added the rest uri for both local and dev environments, per the advice of another more experienced Engineer I work with. I added the management details to be enabled at the top of the application.yml file and added the specific rest uri to the spring profile for dev like so:
Of course initially, I tested these changes ### locally and all was well. The health check endpoint, which is http://localhost:8080/globalSearch/actuator/health, returns a local JSON response like such, when using an API tool like POSTMAN:
Now, when pushing my code changes via git (git push of course) to the build pipeline, it indeed built successfully. However, we have a release pipeline which "Deploys to dev" and when I attempted to do this, this deployment produced the (error) logs below on AWS (Amazon Web Services) CloudWatch Logs below. Also, when running a GET request via POSTMAN to the dev url instance with the newly built Health endpoint, the JSON response is incorrect and not what the response I received locally (aka the correct response):
If you want to view the log errors in a image that might be easier to read the below, here is the link:
CloudWatch Logs Healthcheck Elasticsearch Failure
I did post on the AWS forums, StackOverlow, and did a little research and found other people having similar issues where they posted GitHub issue requests. Most people were saying things about the RestClient bean in the application is not picking up the configuration in application.yml. I can post any more information anyone needs if I can get some help. I'm just trying to narrow down what the issue is or work toward debugging. I'm relatively new to Spring, so I don't completely understand when people are talking about spring beans, application context, http etc... etc... but I'm willing to do anything to learn (I'm just a peasant intern :P )
Am I missing more configuration? Like do I need to define these properties (which I never did)?:
If anyone could help me, or point me in the correct direction, I'd greatly appreciate it!
The text was updated successfully, but these errors were encountered: