Display state of Business Service in Grafana

Business Service state in Grafana

grafana0

This brief tutorial describes how to visualize the state of a Business Service defined in OpenNMS. First of all you have to access the Web-UI of your OpenNMS instance to lookup the Business Service Id. You can achieve this by selecting your Business Service in the Topology UI. The info panel on the left side of the screen will show a Technical Details section with the vertex Id starting with bsm:BusinessService:. The following number after the colon is your Business Service Id.

Install AJAX plugin

The described solution triggers a ReST-request against your OpenNMS instance to query the state of your Business Service. To achieve this install the AJAX Panel for Grafana by Ryan McKinley.

Add the panel

Now choose a dashboard and add a panel. Hit Choose Visualization and select the AJAX visualization. Let’s assume your OpenNMS instance is reachable via

https://your.opennms.instance/opennms

and the Id of your chosen Business Service is

123456

So, your AJAX panel must use the URL

https://your.opennms.instance/opennms/api/v2/business-services/123456

Enter the following options:

You do not need to specify any parameters but add the authorization header for your OpenNMS instance in the Headers (via javascript) section. You can use online tools (e.g. Basic-Authentication-Header-Generator) to generate this header for your credentials.

In the Display section select the mode Angular Template and add the following code to the Angular Template textbox:

<div align='center'>
<span style="display:{{ response['operational-status']=='INDETERMINATE'?'inline':'none' }};background:#999000;color:#ffffff;padding:10px;">{{ response['operational-status'] }}</span>
<span style="display:{{ response['operational-status']=='NORMAL'?'inline':'none' }};background:#336600;color:#ffffff;padding:10px;">{{ response['operational-status'] }}</span>
<span style="display:{{ response['operational-status']=='WARNING'?'inline':'none' }};background:#ffcc00;color:#ffffff;padding:10px;">{{ response['operational-status'] }}</span>
<span style="display:{{ response['operational-status']=='MINOR'?'inline':'none' }};background:#ff9900;color:#ffffff;padding:10px;">{{ response['operational-status'] }}</span>
<span style="display:{{ response['operational-status']=='MAJOR'?'inline':'none' }};background:#ff3300;color:#ffffff;padding:10px;">{{ response['operational-status'] }}</span>
<span style="display:{{ response['operational-status']=='CRITICAL'?'inline':'none'}};background:#cc0000;color:#ffffff;padding:10px;">{{ response['operational-status'] }}</span>
</div>
4 Likes

That’s pretty cool. Can we pull a list of Business Services into a Grafana template, and then feed it into a repating panel to show the status of all services?

Indeed! That would be awesome!
But you would need id:name pairs that can be inserted in template. I’m not aware that Grafana can handle variables pairs.

1 Like

We should have a maintenance mode for BSMs. Would be impressive in the dashboard to see this state.

Right now we have only scheduled outages for nodes that can affect BSMs in some way.

This is a nice visualization and an inspired idea. Thanks!

I always add a link into each box that points to the current BSM alarms. It’s basically an alarm search for the BSM name.
So if the BSM is not green, we can easily navigate to the alarm page. And since the BSM events are more verbose and provide details about the event reason it is really nice to have.

If someone wants to write an automation to generate the dashboard, he/she should also add those links :slight_smile: