Recently a customer asked for a specific section of an existing Foglight dashboard to be available as a drag and drop view in their custom dashboards. In this case they simply wanted to see the up/down arrow from the SLA dashboard to be available to them when they dragged a service onto the canvas.
Luckily, using WCF we’re able to quickly and easily create our own portlets for this, and in this tutorial I’ll show you how. In order to complete this tutorial you’ll need:
A Foglight Management Server, I’ve tested this on 5.5.8, it may not work with earlier versions.
Some prior knowledge of WCF will be helpful, but hopefully not essential
As always, I recommend you try this on a development Foglight server. Although we won’t be doing anything very dangerous be careful with what you do on production servers.
So lets begin. For this guide we’ll create a very basic up/down arrow based on the current availability of a service. Go over to configuration –> dashboards in your left hand menu (you’ll need to have dashboard designer role in Foglight to see this page).
If you haven’t seen this interface before, this is the WCF editor, and it’s the tool our developers use to build all of the interfaces in Foglight.
We will create a new module to hold our portlets, so in the top left section click the green plus symbol:
In the following dialog give your module a name, you also need to set a relevant role so that people can see your portlets (operator should be fine).
.
Once you have your module, click the larger plus icon to create a new view. From the menu open up “Common” and choose label. This will open a new label view in the right-hand portion of the screen. Give your label a name, click the “public” check box, and set the purpose to “portlet”. The Relevant Role should be populated from your module settings. When you’re done it should look something like this:
Click on the context tab, and add a new “input” (using the green plus icon). Give this a name of “SLP”. Click on the edit icon in the Data Type column to open the “select type” dialog box. type “FSMServiceLevelPolicy” into the search box to find the data type we require. Click it and choose save. By setting this we are telling Foglight that we will give this view a service level policy, and that we then want to display some data from that object in some way. (developers might like to think of these as arguments).
Next up is the configuration tab. This is where we tell Foglight what to do with the data we pass it. As this view is going to be a label we can either do something straight forward like text, or use a renderer to make that text look a little more interesting.
Click to edit the value of the Label property (it appears in bold as it is a required option). Choose “set to binding”->”context”.
In the next dialog, choose your SLP object from the input dropdown. When you click on the “path” box you will now see all the metrics and properties that belong to a service level policy. We want to use the current availability, so open up “availability”, open “current” and choose average.
At this point we could stop, the label will simply display the text value of this metric. We can make it a little more interesting with a Renderer which will change the text into a graphic representation. The button next to the renderer section, and inside the dialog choose management server –> System –> Indicator:availability.
When you are finished the dialog should look like this:
Now click save, and you have created your first portlet. To test it, create a new drag and drop dashboard, find a service in the data tab, and open it up to find its service level policy (as below).
Now drag your policy onto the canvas and select views, you should see your module in the left hand menu and be able to choose your new portlet.
Taking it further
Now that you’ve made your first (allbeit simple) portlet you may want to try something a little more fun, remember that any view can be made into a portlet as long as it is marked as “public” and has a context configured. To get you started I’ve packaged a number of these SLA portlets into a cartridge that you can get from the community garden on Foglight.org.
If you would like to know more about WCF generally a good place to start is the ONline tutorial guide which you can find in the Foglight help tab. If you have any questions, please leave a comment below, or better yet post it to the Foglight Community where we’ll be glad to help you.