Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beanshell support to extend value field functionality #619

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Csaba-emnify
Copy link

@Csaba-emnify Csaba-emnify commented Jul 8, 2021

Hi @fstab and @tomwilkie,

This PR aims to add beanshell support for the jmx-exporter in order to enable the use of java-like code in the value field. This should make it possible to extract useful metrics out of exported MBeans, where the desired value is not of type boolean or cannot be matched against directly via different patterns, like values of type String and Array. An example of our use case is given below.

Our use case:
At EMnify we use the akka framework, which exports the number of unreachable nodes in a cluster as a list of comma separated addresses and the exported MBean is of type String. It would be very useful for monitoring, if we could see the number of unreachable nodes at any point in time. To get the length of the list, one pattern for each possible list-length is needed, with a hard-coded value corresponding to the length. Since the length of the list is not known, it is very cumbersome to keep adding patterns if more nodes join the cluster.

With these changes it should be possible to write something like:

- pattern: 'akka<type=Cluster><>Unreachable: (.*)'
    ...
    value: matches.get(1).split(",").length
    ...
    type: GAUGE

Instead of:

- pattern: 'akka<type=Cluster><>Unreachable: (akka\.tcp\:\/\/\w+\@\w+\:\w+\,{2})'
   ...
   value: 3
   ...
   type: GAUGE
- pattern: 'akka<type=Cluster><>Unreachable: (akka\.tcp\:\/\/\w+\@\w+\:\w+\,{1})'
   ...
   value: 2
   ...
   type: GAUGE
- pattern: 'akka<type=Cluster><>Unreachable: (akka\.tcp\:\/\/\w+\@\w+\:\w+)'
   ...
   value: 1
   ...
   type: GAUGE

As far as we tested, the changes are backwards-compatible which means users could keep using the syntax they already know.

Regards,
Csaba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants