Spring-boot-admin: App status remains "UP" after app crashes - monitoring

Spring boot admin is a great tool to make the health and metrics of my spring boot application (in my case a web-server) available. I've followed the reference guide and could finally get it to run, with one exception though: The server doesn't seem to recognize if the client crashes/goes down.
For testing I currently use separate applications, both running on the same host. In the final version I plan to have multiple clients (running on separate IP addresses) to register with a single server running on its separate IP).
Server (a separate spring boot project)
pom.xml
...
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
</dependency>
...
application.properties:
server.port=8081
MyMain:
#Configuration
#EnableAutoConfiguration
#EnableAdminServer
public class MyMain {
public static void main(String[] args) {
SpringApplication.run(MyMain.class, args);
}
}
Client (my WebApp to be monitored):
pom.xml:
...
<!-- SPRING BOOT ADMIN (CLIENT) -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
...
application.properties:
server.port=8080
spring.boot.admin.url=http://localhost:8081
spring.boot.admin.client.management-url=http://localhost:8081
spring.boot.admin.client.service-url=http://localhost:8080
spring.boot.admin.client.name=my-rest-app
With this setup I can connect to http://localhost:8080 to get my web-app or to http://localhost:8081 to see the admin/monitoring UI. The status shows UP and I can browse the mem/heap/traces/...
The issue now is, that if I kill the web-app the status remains UP.
From the description I would have assumed that the server property spring.boot.admin.monitor.period is checking every 10s the status of the clients app.
Or, do I require the notification feature for this?

Try running the application through the command line from your project directory -
mvn spring-boot:run

It's simple.
spring.boot.admin.auto-deregistration=true
Set this in your application.properties.
Keep in mind, this only works when your application is terminated gracefully or using SIGTERM (kill -15 PID).
In case you kill your application, the app won't deregister itself because the context was not closed properly.
See more here- https://codecentric.github.io/spring-boot-admin/1.4.3/#spring-boot-admin-client

Related

HOST NOT RESOLVABLE seen ONLY for FIRST request with RemoteWebDriver

HOST NOT RESOLVABLE seen ONLY for FIRST request with selenium-server-standalone 2.41(Machine A) RemoteWebDriver, Firefox 28 on Machine B alone with hub and node on the same MACHINE B.
The debugging session is going on from two days with no concrete outcome. Can anyone please point us in the right direction?
Are we missing anything as part of setup here? What is the correct way to make use of selenium-server-standalone 2.41 with Firefox 28 for RemoteWebDriver usecase?
Maven Dependency
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server-standalone</artifactId>
<version>2.41.0</version>
</dependency>
SETUP AND EXECUTION DETAILS
We have two machines Machine A (ARM64) , Machine B(Linux X86).
The way we are making use of it now is as follows,
Machine A(Linux ARM64) is where RemoteWebDriver invocation occurs, selenium-server-standalone-2.41.0.jar is used.
Machine B(Linux x86), we have a running docker container acts as both hub and node, Expose 4444 port from CONTAINER to HOST MACHINE B
java -jar /u01/selenium/selenium-server-standalone-2.44.0.jar -role hub
java -jar /u01/selenium/selenium-server-standalone-2.44.0.jar -role node -hub http://localhost:4444/grid/register
Access the HOST:port from ARM based machine
OUTPUT SEEN
First connection results in WebDriver Exception, HOST NOT RESOLVABLE, however, subsequent connetions results in no expections, everything just works after first request failure. Here, Geckodriver is not used as we are making use of selenium 2.41, as per MOZ documention
https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html
CODE USED
The below code is executed from MACHINE A.
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class Main {
public static void main(String[] args) throws Exception {
DesiredCapabilities capability = DesiredCapabilities.firefox();
WebDriver driver = new RemoteWebDriver(new URL("http://<<MACHINEB>>:4444/wd/hub"), capability);
driver.manage().window().maximize();
driver.get("http://localhost:4444");
Thread.sleep(10000);
driver.close();
}
}
I guess the issue here is not with your Selenium code rather with the server you are calling. Probably it is initially "sleeping" and "wakes up" after it detects some request coming to it.

Duplicated port of child tasks in Spring Cloud Data Flow

When I launch new task (Spring Batch Job) using Spring Cloud Data Flow, I see that SCDF auto initialize Tomcat with some "random" ports but I do not know if there ports are created randomly or following any rule of the framework?
Therefore, I sometime have a trouble that "Web server failed to start. Port 123456 was already in use".
In conclusion, my questions are:
1) How does the framework choose ports for initializing? (randomly or by principle)?
2) Are there anyway to launch task effectively without duplicated ports(fixed configuration or method for choosing unused port at particular time)?
I don't think SCDF has anything to do with the port assignment etc.,
It is your task application that gets launched. You need to decide whether you really need the web dependency that brings in the tomcat to your application.
Assuming you use Spring Boot, you can either exclude the web starter dependency in your dependencies or pass the command line arg server.port=<?> to a specific port when launching the task (if you really need this task app to be a web app).

Tomcat web app not receiving requests sent through AWS ELB

I have 2 web applications that run on a single Tomcat in a docker container on an AWS EC2 instance. One web app is 100% angular static content and the other is a REST application. When I run the web apps on my laptop, everything runs fine. When I run the docker container on an EC2 instance and access the web apps directly using the public IP, everything runs fine. However, when I try to access the web apps through an ELB, requests for the static content are handled fine, but requests to the REST app fail with a 403. I can see the 403 error in the Tomcat access logs so I know they are being received by Tomcat. However the REST app logs show no evidence that the request was received. I added a filter to the REST app that logs all requests received, but it shows no evidence that the request was received when when sent through the ELB.
Any idea why this might be happening? Any suggestions for diagnosing?
My docker file ...
FROM tomcat:8.0
LABEL maintainer="rossmillsiphone#gmail.com"
ADD voteride-web.war /usr/local/tomcat/webapps/
ADD voteride-ws.war /usr/local/tomcat/webapps/
ADD mysql-connector-java-5.1.9.jar /usr/local/tomcat/lib/
ADD server.xml /usr/local/tomcat/conf/
ADD context.xml /usr/local/tomcat/conf/
ADD email.properties /usr/local/tomcat/lib/
ADD logging.properties /usr/local/tomcat/conf
EXPOSE 8080
CMD ["catalina.sh", "run"]
This article had the answer I needed: https://willwarren.com/2014/01/27/running-apache-tomcat-with-ssl-behind-amazon-elb/
Setting the connector like this resolved the issue and allowed the web app to be called when traffic came through the ELB.
<Connector
port="8080"
protocol="HTTP/1.1"
proxyPort="443"
scheme="https"
secure="true"
proxyName="mywebsite.com"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />

Using Spring-retry with Dropwizard

Is it possible to make use of spring-retry within dropwizard? Or, for that sake, is there something like spring-retry in dropwizard?
Not sure of wha spring retry does, but for client retries, you can configure retries for HttpClient
httpClient:
timeout: 500ms
retries: 3
The number of times to retry failed requests. Requests are only retried if they throw an exception other than InterruptedIOException, UnknownHostException, ConnectException, or SSLException.
See Dropwizard documenation
From Spring Batch - Reference Documentation, 9. Retry:
The retry functionality was pulled out of Spring Batch as of 2.2.0. It is now part of a new library, Spring Retry.
Spring Retry can be used independently of other Spring projects.
e.g. In a Maven project you can simply add the following in your POM:
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
<version>1.1.5.RELEASE</version>
</dependency>

Grails get stuck at "finished configuring Spring Security REST"

I type grails run-app and it begins to run, but it gets stuck on the message:
----------------------------------------
Current config:
baseDir: db/migration/global
env: DEVELOPMENT
dataSource: default
url: jdbc:postgresql://localhost:5432/mydbapp
username: postgres
schemas: public
----------------------------------------
Configuring Spring Security Core ...
... finished configuring Spring Security Core
Configuring Spring Security REST ...
... finished configuring Spring Security REST
It used to run fine like an hour ago. No strange logs or anything. Also, when hit ctrl+c in the terminal, grails will close, but when I run-app again, it will say something like:
Error Server failed to start for port 8080: Address already in use (Use --stacktrace to see the full trace)
Indicating that grails wasn't really terminated. Of course, I kill the app occupying 8080 and run-app again, but it's still getting stuck.
The port 8080 is been used for another thread. Try to find a java thread in your system that you don't recognize and stop it.
How to on windows
How to on Linux
In BuildConfig.groovy, change your apps port. Example:
grails.server.port.http = 8003
If you still get port in use, exit IntelliJ, goto Task Manager, sort by memory used, end any processes with IntelliJ or Grails.
If you are using liquibase database migration tool and if you somehow stopped it before it finishes it will put a lock at DATABASECHANGELOGLOCK table. Change it to LOCKED = false and it will start.

Resources