How to create a live Dashboard in Grafana from Mainframe RESTful APIs.
By: Petr Klomfar
Tags: Visualisation, Rest Api, Performance, DevOps, Mainframe

How can I easily view the results of a mainframe performance run? How can I share these results with my team? This is my experience in solving this challenge.

To start with, I had the data accessible through RESTful interfaces, but I wanted to visualize it, easily correlate it, and then share it with my peers. “A picture says a thousand words”, they say. That led me to research how to display the data available and to best get the value my team might want.

Setting the record straight

You need to think about what performance analysis you want to perform and then determine what data to visualize, what information do you want to correlate, what questions will your team members ask?

CA Mainframe Application Tuner as a performance monitoring solution offers a nice command-line interface (CLI) that allows you to quickly pull performance information, but maybe that is not enough, or you would like to see it in a different way or present it to your peers more effectively. This is what you need to determine as you start off.

What I wanted to achieve as a user and consumer of the data was to have the data available with ease at any point through just a few simple clicks and more so to have them visually digestible. Yes, I could have explored writing a bulky Graphical User Interface, but for something essentially that simple such proof of concept is the way to go!

Research and requirements

Thorough research is where it all starts. You know what you want to visualize, but now what graphic visualization technology is best? I knew I wanted a graphical solution that could communicate with mainframe REST APIs, allowing authentication, being flexible and open source. So I have searched the internet comparing and contrasting available solutions. Grafana was my choice, a versatile, open-source graphical framework, that takes input through REST interfaces and satisfies all my initial requirements the best.

Never heard of Grafana? It is getting more and more traction wherever you look.

Fig.1 — quote of www.grafana.com

However. This is where I had hit a snag! After a deeper dive even in the case of Grafana, reaching the final solution had proven to be complicated and problems needed to be solved.

Problems and solutions

Hurdle #1 — A mediation between Grafana’s API and CA MAT REST API.

JSON plugin from simpod was chosen to serve as a Grafana data source. The MAT API implementation expects a GET communication method as opposed to the plugin’s POST.

Solution? A wrapper needed to be written.

Fig.2 — JSON plugin by simpod

Hurdle #2: Obtaining an AUTH token and passing it to the API.

Deeper and deeper into the evolution, problems lead to the creation of a node.js server that holds the deployed wrapper. Here’s how the AUTH token is obtained and how the server is initiated.

Fig.3 — app.js — a node.js server initiation

Fig.4 — Obtaining an AUTH token

Hurdle #3: Data format expected by Grafana API

As Grafana is a time series rendering solution, you have to create your own data source. For me, a series of Trials & Errors determined which parameters and which queries trigger the desired output. Here’s an example of data transformation to tabular format suiting a static data coming from CA MAT REST API.

Fig.5 — using object arrays to transform the data to Grafana’s format

Stitching together .env target URLs with a SWITCH case to route the logic and enable the Grafana dashboard creation.

Fig.6 — target URLs for CA MAT REST APIs

Fig.7 — Switch case for each query

Final solution and dashboards.

So what is the final solution?

Fig.8 –Final solution diagram

On top of the final architecture, as a Proof Of Concept, three Dashboards were presented. All of them are interlinked together on specific keys.

Fig.9 — POC Dashboards

A Performance Monitor List showing all CA MAT DB entries in chronological order.

A Profile details with an easy link to historical monitors for the same profile. Fig.10

A Monitor Details holding critical information for performance tuning, listing the monitor results based on MON_NUM (Monitor ID) within the CA MAT DB. Fig.11

Fig.10,11 — Profile and Monitor Dashboards

Next Steps? Team up with UX designers around improvements on the look. Enhance the POC and script over the individual historical monitor runs to see the trends aka construct a time series data out of static tabular format returned by multiple REST calls, this is where there is a vast amount of graphical content ready for Grafana users!

Whether the final data presentation is aimed at analysis or simply to communicate what your data has to offer, that is up to you and your implementation. The limit is only your imagination.

Feel free to share with me your trials and successes…

For more about CA MAT, see this article: Batch Performance Test on Commit with CA MAT — 3 steps

Check out other stories on the Modern Mainframe blogsite.