GithubHelp home page GithubHelp logo

spring-boot-jolokia's Introduction

Instructions to start Spring Boot with jolokia agent

When a Spring Boot application is deployed on Openshift using the openjdk java 1.8 S2I docker image, the jolokia agent is deployed within the image and, when the docker container is starter, then it is instrumented by the java -javaagent parameter. The HTTPS service exposed by Jolokia allows to access using the HTTP protocol the information about the MBeans created within the JVM.

The Jolokia service can be customized using the following parameters defined within the DeploymentConfig resource as env variables :

  • AB_JOLOKIA_USER = "jolokia"
  • AB_JOLOKIA_PASSWORD = "admin123"
  • AB_JOLOKIA_PASSWORD_RANDOM = "false"

Remark : The list of the paramters available is defined here

Run the project locally

mvn clean package
java -javaagent:jar/jolokia-jvm-1.3.7-agent.jar=config=etc/jolokia.properties -jar target/spring-boot-jolokia-1.0.0-SNAPSHOT.jar

Query the Jolokia Service

  • Get the Jolokia Info
curl -v -u jolokia:admin123 http://localhost:8778/jolokia/

or

http --auth jolokia:admin123 http://localhost:8778/jolokia/version
...

{
    "request": {
        "type": "version"
    },
    "status": 200,
    "timestamp": 1510659657,
    "value": {
        "agent": "1.3.7",
        "config": {
            "agentContext": "/jolokia",
            "agentId": "192.168.1.80-52647-2503dbd3-jvm",
            "agentType": "jvm",
            "debug": "false",
            "debugMaxEntries": "100",
            "discoveryEnabled": "true",
            "historyMaxEntries": "10",
            "maxCollectionSize": "0",
            "maxDepth": "15",
            "maxObjects": "0"
        },
        "info": {
            "product": "tomcat",
            "vendor": "Apache",
            "version": "8.5.23"
        },
        "protocol": "7.2"
    }
}
  • Get the Memory usage
http --auth jolokia:admin123 http://localhost:8778/jolokia/read/java.lang:type\=Memory/HeapMemoryUsage
HTTP/1.1 200 OK
...

{
    "request": {
        "attribute": "HeapMemoryUsage",
        "mbean": "java.lang:type=Memory",
        "type": "read"
    },
    "status": 200,
    "timestamp": 1510660614,
    "value": {
        "committed": 378535936,
        "init": 268435456,
        "max": 3817865216,
        "used": 132615736
    }
}

Deploy on OpenShift

oc new-project demo-jolokia
mvn clean package fabric8:deploy -Popenshift

Access Jolokia Https Service

  • Get the jolokia route endpoint
JOLOKIA_URL=$(oc get route spring-boot-monitoring-jolokia -o jsonpath='https://{.spec.host}')
  • Next issue a curl or httpie request
curl -k -u jolokia:admin123 $JOLOKIA_URL/jolokia/version

or

http --verify=no --auth jolokia:admin123 $JOLOKIA_URL/jolokia/version

Install manually the Jolokia service/route

  • Create Service/Route on Openshift
oc delete route/spring-boot-http-jolokia
oc delete svc/spring-boot-http-jolokia
oc create -f src/fabric8/jolokia-svc.yaml          
oc create -f src/fabric8/jolokia-route.yaml 

spring-boot-jolokia's People

Contributors

cmoulliard avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.