Friday, February 1, 2013

Collecting, Monitoring and Charting JBoss 7 metrics

JBoss AS 7 metrics

By default, the JBoss AS 7 metrics are available at 127.0.0.1 on two ports:

  • 9999 via the native management API,
  • 9990 via http.

Access is secured by the ManagementRealm, so you need to create a user and password, if you want to access the data via http. For more details take a look at $JBOSS_HOME/standalone/configuration/standalone.xml under the management element.

There are at least 2 ways to collect the JBoss AS 7 metrics in JBison, a web and JBoss Application Server monitoring service, highly available, with instant free email notifications and exportable data.

Since JBison needs to be able to connect to your JBoss AS instance, you will need to run it by passing -b PUBLIC_IP

  1. Expose the metrics through http with basic authentication

As already said, the interface is secured by the ManagementRealm. To create a user and password run the corresponding script in $JBOSS_HOME/bin:

./add-user.sh user passwd

By default the metrics are available at 127.0.0.1. This can be overridden by starting the server with

-Djboss.bind.address.management=PUBLIC_IP

where PUBLIC_IP is an IP address of your JBoss instance accessible from the internet.

You should receive a nice response in JSON format when navigating to:

http://PUBLIC_IP:9990/management/subsystem/datasources/data-source/ExampleDS/statistics/pool?include-runtime=true

These are the runtime metrics available for the ExampleDS datasource pool deployed out of the box with the standalone configuration.

For the jdbc metrics of that data source navigate to

http://PUBLIC_IP:9990/management/subsystem/datasources/data-source/ExampleDS/statistics/jdbc?include-runtime=true

To get statistics for the http connector open

http://PUBLIC_IP:9990/management/subsystem/web/connector/http?include-runtime=true
  1. Collect the metrics through the Native Management API and expose them via http through a proxy, deployed as a REST application

The idea is to instrument a JBoss Application Server to expose metrics in JSON format. I've created a sample web application available on github which provides datasource metrics via REST. Once deployed, the application collects metrics for a particular datasource via the Native Management API.

In this case, there is no need to pass

-Djboss.bind.address.management=PUBLIC_IP

The metrics are available at:

http://PUBLIC_IP:8080/buffalo/rest/datasource/ExampleDS

You can monitor a datasource deployed via a datasource descriptor. Deploy the following mysql-ds.xml file:

<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
 <datasource jndi-name="java:jboss/datasources/TestDS" pool-name="MySQLPool" enabled="true" use-java-context="true">
  <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
  <driver>mysql-connector-java-5.1.21.jar</driver>
  <pool>
   <max-pool-size>30</max-pool-size>
  </pool>
  <security>
   <user-name>root</user-name>
   <password></password>
  </security>
 </datasource>
</datasources>

and checkout its metrics at:

http://PUBLIC_IP:8080/buffalo/rest/datasource/TestDS/mysql-ds.xml

The application can be extended for example to aggregate multiple metrics, for example "AvailableCount", from all deployed datasources and expose them at once.

Collecting, monitoring, charting, alerting

So far so good, but where is the awesomeness in all of this? It is in JBison! Login and create a JSON monitor:

Copy/paste any of the sample URLs:

For each URL you will need a separate monitor. Each monitor is able to chart any metric you wish, or all of them via the "*" wildcard. For each metric you can define an alert that will be triggered if the condition is violated. Currently only email is available, but SMS notification is under development.

In this example an alert will be sent via email, if any of the metrics is less than zero or AvailableCount is less than 15.

A JSON monitor consists of a table showing its current state and a chart, which allows to show and hide particular metrics and also to display their values when pointing at a particular point in time:

In case a metric is violated, that event is made visible in the UI:

Besides this an email is sent:

Lekker!

Friday, October 2, 2009

Drools JBoss Rules 5.0 Developer's Guide book review

The Developer's Guide is the second book about Drools available from Packt. It nicely extends the Drools documentation showing a new point of view at almost all features.

Although it wasn't always easy to follow I definitely recommend this book to developers who either are starting their journey with this rule engine or are already familiar with Drools. Examples are not trivial 'hello world' applications. Especially my favorite Drools Fusion chapter about complex event processing is built up on quite advanced rules for a fraud detection system.

One chapter is dedicated to performance, which is a must-read for all who have to deal with a huge amount of rules and facts. It explains how to write rules to take advantage of node sharing and how to speed up fact propagation using parallel mode.

Another chapter is dedicated to a complete 3-tier JEE application. It's built up on Hibernate (for persistence), Bitronix transaction manager (for transactions), Spring MVC (for presentation) and obviously Drools (for business logic).

What's also worth to note is the test driven development style presented in almost all examples.

To sum it up, building rule based services is not an easy task. This book introduces the Drools rule engine and deals with almost all its capabilities - starting with the core engine functionality, going through decision tables, complex event processing and business process presentation ending with advanced topics covering performance and integration points with other systems.

Friday, July 24, 2009

Using rules to pick up rules - Selectors in Guvnor

When you build a package, all its assets are used to compile it. However you might want only a subset of your rules to go into a package. Moreover you might want to create different snapshots that include different set of rules. This article will show how to use the Selector feature available in Guvnor to build packages containing only these rules that satisfy user-defined constraints.

Wednesday, July 8, 2009

JMS – a new fact provider for Drools via Pipeline

The Drools Pipeline is a great tool that allows to put facts into the rule engine from the outside world. Currently supported stores are JMS queues and topics and text files. The format of the payload is almost free to choose, since out of the box you can use JAXB, XStream and the powerful Smooks transformer to convert your data into facts, which the rule engine is able to consume.
This article explains how to use Pipelines.

Monday, June 8, 2009

JBoss Drools Business Rules book review

It's quite difficult to get started with Drools, especially if you don't have experience in developing Java applications. You might imagine how steep the learning curve is for business analysts, who associates Java with an island or coffee. However this book is aimed at exactly this group of non-technical people, who have knowledge how business runs, but don't know how or simply don't have the tools to persist it and 'transfer it to the world of computers'.

Most chapters are kept on a really basic level if it comes to writing Java code. On the other hand it's sufficient to get started. Moreover all used tools are open source software, which means you can use it for free.

This book goes through almost all parts of Drools, especially the most important for business people like Guvnor, the application for authoring rules, DSLs allowing to write rules in plain English as well as support for the business analyst's most favorite tool: Excel spreadsheets.

The author even introduces typical developers' tools like Eclipse, however I would recommend to go through an updated guide about installing the Eclipse plugin available in the Drools docs. A new requirement, that did not make it into this book, is to set up the Drools rule engine.

There's a chapter I like very much. It makes very clear that testing rules is an important part of the development cycle and introduces three different ways to achieve full coverage of all written rules. The inquisitive reader might also have a look at the QA Analyzer, a quite new and powerful feature available in Guvnor.

One chapter is definitely intended for Java developers - about deploying Drools applications in real world scenarios. The business people will still be able to follow, since the author keeps things easy and doesn't go to deep into details, however I would love to read more about this topic.

The last two chapters about rule engine concepts and the newest features are a must-read for all those people who have read the Drools docs, but still need a different point of view to fully understand how Drools works. This topic is very important in my opinion, since it lets you write your rules more effectively.

What I didn't like was the use of IE and Excel. Same results could be achieved with open source software, too. But that's a minor one ;)

All in all, definitely a guide for non technical users, but also for developers, who have given the Drools docs a (second and third) try and still require a helping hand to sort it out how this Drools thing works and how to use it properly.

Sunday, May 24, 2009

Drools5 is out - there's also a book!

Drools 5 is available for download. The corresponding svn tag is http://anonsvn.labs.jboss.com/labs/jbossrules/tags/5.0.1.26597.FINAL/. You can read the announcement on the Drools blog.

FWIW, there's also a book available released by Pack Publishing. It covers basics, like getting the software, setting up the Eclipse IDE and making your first steps with Guvnor(a web application for authoring and managing rules) as well as more advanced concepts like support for a domain specific language, tools for rules testing and the internals of the Drools rule engine.

You can read more about this book on their website and chapter 4, "Guided Rules with the Guvnor" is available for free. It's a quick introduction to start with Guvnor. It begins with building a data model in Eclipse, goes through building a business rule with the guided editor and ends with running a test scenario.

Monday, August 18, 2008

Tuning Guvnor

Guvnor is the business rules management system in Drools 5. When you deploy it out of the box, you get an unsecured web application that stores data in Jackrabbit’s embedded Derby database.
This article explains how to tune Guvnor deployed on JBoss Application Server 4.2.3. It's available in English and German.