Giter VIP home page Giter VIP logo

embedded-jmxtrans's Introduction

embedded-jmxtrans

In process JMX metrics exporter. Inspired by the standalone version of jmxtrans but embedded inside your java process (e.g. Tomcat).

An in process JMX Exporter will solve the problem of remote JMX access in cloud-style and elastic environments where the IP address of the Java servers is unknown and where RMI-IIOP is disabled (e.g. Amazon Elastic Beanstalk, Cloudbees, ...).

Getting started

Getting started guide for Spring Framework enabled web applications.

Maven

Add embedded-jmxtrans dependency

<dependency>
    <groupId>org.jmxtrans.embedded</groupId>
    <artifactId>embedded-jmxtrans</artifactId>
    <version>1.0.12</version>
</dependency>

Spring Framework

Declare <jmxtrans:jmxtrans> in your Spring configuration :

<beans ...
       xmlns:jmxtrans="http://www.jmxtrans.org/schema/embedded"
       xsi:schemaLocation="...
		http://www.jmxtrans.org/schema/embedded http://www.jmxtrans.org/schema/embedded/jmxtrans-1.1.xsd">

    <jmxtrans:jmxtrans configuration-scan-period-in-seconds="30">
        <jmxtrans:configuration>classpath:jmxtrans.json</jmxtrans:configuration>
        <jmxtrans:configuration>classpath:org/jmxtrans/embedded/config/tomcat-6.json</jmxtrans:configuration>
        <jmxtrans:configuration>classpath:org/jmxtrans/embedded/config/jmxtrans-internals.json</jmxtrans:configuration>
        <jmxtrans:configuration>classpath:org/jmxtrans/embedded/config/jvm-sun-hotspot.json</jmxtrans:configuration>
    </jmxtrans:jmxtrans>
</beans>

Configure writers

Create src/main/resources/jmxtrans.json, add your mbeans and declare both ConsoleWriter (output to stdout) and GraphiteWriter

{
  "queries": [
      {
      "objectName": "cocktail:type=ShoppingCartController,name=ShoppingCartController",
      "resultAlias": "",
      "attributes": [
        {
          "name": "SalesRevenueInCentsCounter",
          "resultAlias": "sales.revenueInCentsCounter"
        }
      ]
    },
    {
      "objectName": "com.cocktail:type=CocktailService,name=cocktailService",
      "resultAlias": "cocktail.controller",
      "attributes": ["SearchedCocktailCount", "DisplayedCocktailCount", "SendCocktailRecipeCount"]
    }
  ],
  "outputWriters": [
    {
      "@class": "org.jmxtrans.embedded.output.ConsoleWriter"
    },
    {
      "@class": "org.jmxtrans.embedded.output.GraphiteWriter",
      "settings": {
        "host": "${graphite.host:localhost}",
        "port": "${graphite.port:2003}"
      }
    }
  ]
}

In this sample, Graphite host & port are defaulted to localhost:2003 and can be overwritten with system properties or environment variables, for example in $CATALINA_BASE/conf/catalina.properties.

Start application and check metrics

Check metrics in the Console

...
jvm.os.SystemLoadAverage 2.97265625 1358242428
tomcat.thread-pool.http-8080.currentThreadsBusy 0 1358242458
tomcat.manager.localhost._.activeSessions 0 1358242458
tomcat.servlet.__localhost_.jsp.processingTime 0 1358242458
tomcat.servlet.__localhost_.jsp.errorCount 0 1358242458
tomcat.servlet.__localhost_.jsp.requestCount 0 1358242458
cocktail.controller.SearchedCocktailCount 12 1358242458
...

Check metrics in Graphite

Graphite Screenshot

embedded-jmxtrans's People

Contributors

aymandf avatar cyrille-leclerc avatar ekilby avatar farnulfo avatar golorins avatar jaylemur avatar lookfirst avatar martinmulder avatar osx2000 avatar ryanlarson avatar scottcjohnson avatar yannrobert avatar

Watchers

 avatar  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.