Search This Blog

Wednesday 11 January 2017

Configuring Spring Boot Actuator information in Pivotal Cloud Foundry 1.9 Applications Manager

With the release of Pivotal Cloud Foundry 1.9 we added "Spring Boot Actuator In PCF" through Applications Manager Web UI. In this example below I will show what config you need on your application side to get Apps Manager Web UI to show you this information.

Spring Boot Actuator exposes information about a running Spring Boot application via an http endpoint. Get useful diagnostics about an app programmatically using these RESTful APIs:  health, git commit, build information, and so on. Now, developers can view some of this data in PCF Apps Manager. It’s easier to debug and monitor your apps in production, since Apps Manager shows this diagnostics info in context.

The steps are are described here BUT the steps below are more detailed and provide a sample application to verify this with.

http://docs.pivotal.io/pivotalcf/1-9/console/spring-boot-actuators.html

1. Add the maven dependency "spring-boot-starter-actuator" to your pom.xml
  
<dependencies>
    <dependency> 
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>

2. Ensure your using Spring Boot 1.5 snapshots/release candidates/final as earlier versions won't work.
  
<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.5.0.BUILD-SNAPSHOT</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>

https://spring.io/blog/2017/01/06/spring-boot-1-5-0-rc1-available-now

3. Configure the Info Actuator as per link below

http://docs.pivotal.io/pivotalcf/1-9/console/spring-boot-actuators.html#info-endpoint

Note: It will differ depending on if your using Maven or Gradle

Ensure you add this property for GIT integration in your YML file or properties file, YML example

management:
  info:
    git:
      mode: full

4. The following demo below has the required setup for verification application , clone and push to CF as shown below.

Note: review pom.xml for everything that is needed for this to work

https://github.com/papicella/SpringBootPCFPas

$ git clone https://github.com/papicella/SpringBootPCFPas.git
$ mvn package
$ cf push -f manifest-inmemory-db.yml

....

0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
1 of 1 instances running

App started


OK

App pas-springboot-pcf was started using this command `CALCULATED_MEMORY=$($PWD/.java-buildpack/open_jdk_jre/bin/java-buildpack-memory-calculator-2.0.2_RELEASE -memorySizes=metaspace:64m..,stack:228k.. -memoryWeights=heap:65,metaspace:10,native:15,stack:10 -memoryInitials=heap:100%,metaspace:100% -stackThreads=300 -totMemory=$MEMORY_LIMIT) && JAVA_OPTS="-Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh $CALCULATED_MEMORY -Djava.security.egd=file:///dev/urando" && SERVER_PORT=$PORT eval exec $PWD/.java-buildpack/open_jdk_jre/bin/java $JAVA_OPTS -cp $PWD/. org.springframework.boot.loader.JarLauncher`

Showing health and status for app pas-springboot-pcf in org pivot-papicella / space development as papicella@pivotal.io...
OK

requested state: started
instances: 1/1
usage: 1G x 1 instances
urls: pas-springboot-pcf-squireless-clicha.cfapps.pez.pivotal.io
last uploaded: Wed Jan 11 03:59:24 UTC 2017
stack: cflinuxfs2
buildpack: java-buildpack=v3.10-offline-https://github.com/cloudfoundry/java-buildpack.git#193d6b7 java-main java-opts open-jdk-like-jre=1.8.0_111 open-jdk-like-memory-calculator=2.0.2_RELEASE spring-auto-reconfiguration=1.10.0_RELEASE

     state     since                    cpu      memory         disk           details
#0   running   2017-01-11 03:00:18 PM   207.1%   489.9M of 1G   161.7M of 1G

5. View the application in Application Manager UI as shown below and you will see that a Spring Icon appears next to the application name



More Screen Shots





More Information

http://docs.pivotal.io/pivotalcf/1-9/console/spring-boot-actuators.html

No comments: