Friday, September 29, 2017

Find the hidden exception with the IntelliJ debugger

I was hacking some code and running tests and got:

  testA(org.acme.ATest)  Time elapsed: 0.114 sec  <<< ERROR!
   java.lang.RuntimeException: Could not inject members
   Caused by: java.lang.NullPointerException

No stack trace, no line number, nothing :-(

Attaching a debugger and making it stop on NPE also did not help, as this was slowing execution down to no avail.

Luckily IntelliJ IDEA has a nice feature to just log the exception when it happens. Just go to the breakpoint view in the Debugger and tick the respective checkbox

Bildschirmfoto 2017 09 29 um 16 16 46

You should also unmark the suspend checkbox as you don't want your porgram being interrupted all the time in places you don't want to know about (I had some hundreds of lines of NPEs within the JRE itself).

When you then attach the debugger to your process, you will see all NPEs along with the place they were thrown. And if the place is within your code, you can navigate to it via the log entry with one click.

I am sure other IDEs have a similar functionality.

Wednesday, June 14, 2017

Was tun ohne Wald?

Mein Beitrag zum Comic-Collab von Schlogger zum Thema Wald.

Comic collab wald


Thema für den 15. Juli: „Schmerzen“

Mit dabei im Juni 2017: (wird noch aktualisiert)

– Schlogger
Rainer Unsinn
Strichweise Diesig
Dramatized Depiction

Sunday, April 02, 2017

A beginners guide to DSL writing in Ruby

I wrote an article on writing (external) Domain Specific Languages in Ruby over at the Red Hat Developers Blog.

This is based on my two posts on Computed Metrics for HawkFX and A DSL for alert trigger definitions in Hawkular.

Monday, December 05, 2016

Hawkular at GrafanaCon

Grafanacon logo finalI had the pleasure to be invited to present the Hawkular eco-system at GrafanaCon 2016.

The venue for this 2-day conference was certainly not your everyday conference venue in a hotel ballroom or cinema, but a lot more heavy-metal:

And thus the sessions of the first day all happened in the on-board theatre which used to be one of the elevators that moved the aircrafts from the hangar to the flight deck.

IMG 20161130 092133
Former aircraft elevator

The sessions were kicked off by Torkel Odegaard, the creator of Grafana by giving some numbers about the growth and versions of Grafana and the community of users and contributors.

In the next session Kevin from Fermilab talked about lasers and how they are connected to Grafana (hint: monitoring of the huge infrastructure that monitors the collider experiments).

And then next was something that probably most have been waiting for: the official launch of Grafana 4 by Torkel. This included a demonstration of some new features like Alerting, where you can define alerts directly on a graph including a visual value-picker and a simulation mode. The announcements continued later by announcing the renaming of Raintank to GrafanaLabs and the completion of the Stack with Intel Snap, which was announcing its version 1.0 followed by Graphite doing the same

I am not going through all the sessions here, but still want to mention the presentation of Kyle Brandt, creator of Bosun alert engine. His talk was less of a product presentation, but rather a philosophical one on getting the communication right. If one engineer sets up an alert trigger and another one has to work on the fired alert, it is important that the later gets enough context to be able to quickly react to the alert.

The afterparty in the evening happened in a nearby bowling place. Those balls are a lot larger and heavier than those we use in Germany for Kegeln.

Intrepid by night

The second day had a format with 2 parallel sessions, which was a lot more "how-to" like, which included a good presentation by Brian Brazil of Promtheus fame and a nice (hi)story of monitoring at Sony PlayStation. My talk took place on the afternoon at 3pm. It went well and I got some good questions and feedback.

As this was the first day with better weather I also toured the flight deck and the bridge of the Intrepid

IMG 20161201 121049
Bridge of the Intrepid

IMG 20161201 121905
Lockheed A1

IMG 20161201 123151
Space Shuttle Enterprise

IMG 20161201 125541
View from the bridge

All talks were recorded and will be pushed online once the video team has edited in the slides. My Slides are available in the meantime from I will update this post once the recordings are online.

Tuesday, October 18, 2016

A DSL for Alert Trigger Definitions in Hawkular

Hawkular had for a while a UI with the possibility to set up Alert Triggers. As the name suggests are those triggers used to define conditions when an Alert is to be fired.

Since a while there is now the ManageIQ UI that allows to set up such triggers. And also Hawkular APM is now able to forward data into Alerting.

The other day I was doing some testing and a colleague asked me if I had already defined some triggers. I thought that I neither want to log into ManageIQ right now nor pass JSON structures via curl commands.

As I did some DSL work for metrics recently, I thought, why not set up a DSL for trigger definitions. This is work in progress right now and here are two examples

Set up a threshold trigger to fire when the value of _myvalue_ is > 3:

define trigger "MyTrigger"
 ( threshold "myvalue" > 3 )

Set up a trigger on availability when it is reported as DOWN. The trigger is not enabled.

define trigger "MyTrigger"
  ( availability "mymetric" is DOWN )

As with my metric DSL I am implementing this in Ruby with the help of Treetop. And likewise I am integrating this in HawkFX.

Inserting a definition

At the moment it is a very crude integration via entry points in the main menu. And the DSL itself is also far from ready. I consider this an experimentation space. If it turns our successful, it may be possible to take the grammar and directly integrate it into Hawkular-Alerts, so that one can directly POST a document with a DSL fragment, which then gets turned into the internal representation.

If you are looking for code, this is available in the alert_insert branch of HawkFX.

Tuesday, September 27, 2016

Computed metrics for HawkFX (updated)

Computed metrics are something I wanted to do for a very long time, already in RHQ, but never really got around it and sort of forgot about it again.

Lately I found a post that contained a DSL to do exactly this (actually you should read that post not because of the DSL, but because of the idea behind it).

After seeing this, I got the idea on what to do and to include this in HawkFX, my pet project, which is an explorer for Hawkular.

HawkFX screen shot
HawkFx with the input window for formulae, that shows a formula and also a parser error.
The orange chart shows Non-Heap used, the redish one the heap usage of a JVM.


Formulas are in a DSL that looks a bit like UPN, e.g. as in the following (I've shortened the metric ID for readability, more on them below):

(+ metric( "MI~...Heap Used" , "max")
   metric( "MI~...NonHeap Used", "max"))

to sum up two metrics (see also screenshot below). The 'metric' element gets two parameters, the metric id and also which of the aggregates that the server sends should be taken (in this case the max value) - this comes from the fact that we request the values to be put into 120 buckets by the server.

Or if you have the total amount of memory you could also subtract the used memory to get a graph of the remaining:

(- 1000000 metric( "MI~...NonHeap Used", "max"))

You could also get the total wait time for responses at a point in time when you multiply the average wait time with the number of visitors:

(* metric("MI~..ResponseTime","avg")

Computed total memory usage

Summing up the metrics for 'Heap Used' and 'NonHeap Used' as shown above would then give you a nice graph of the total memory consumption of a JVM:

Chart with computed metric
The green chart now shows to combined memory usage of Heap and Non-Heap, which is computed from the other two series. Orange and red are as above.

On metric IDs

Metric IDs are the IDs under which a metric is stored inside of Hawkular. The example here comes from an installation of Hawkular-services in Docker. If you just feed your metrics into Hawkular metrics, the IDs will looks like the ones you are using.

ID and path field
ID (upper) and path fields (lower) for a selected item in the tree

I have just pushed an update to HawkFX that provides the ID and path in their own fields at the bottom of the main window, so you can copy&paste them.


I will talk more about the parser in an upcoming article. For now it is a personal playground to also better understand what is doable here. If this turns out to be successful I can imagine that the DSL could directly be incorporated into Hawkular-metrics so that the rules are available to all metrics clients.

It would of course be cool to have an editor for the formulas that allows to interactively pick metric IDs etc, but I doubt that I will get to this any time soon.