When onsite with customers I regularly get asked about the quickest way to export data or alarms to 3rd party reporting tools or data warehouses from Foglight. Whilst Foglight provides a number of interfaces for getting data in or out, one of my favourites is the Export Component.
The Export Component is an element of WCF that provides URL access to data in an XML format – perfect for consumption by most reporting tools. The components are built in a similar way to row-oriented tables in WCF (the dashboard framework of Foglight), and in this tutorial I’ll give a quick overview of how to build an alarms export.
You can see more information in the official WCF reference guide, here.
To build your export component you will need:
- - A working Foglight Server (FMS) (if you don’t have one of these, this might not be the blog for you…)
- - The Dashboard Creator role
- - A working knowledge of WCF is beneficial, but hopefully I’ll explain enough to get you through if you don’t have one.
-
1: Access Definitions.
To do anything with WCF you need to access the definitions panel (the fully functioning dashboard IDE that is bundled with Foglight). You can find this under “configuration – definitions”
-
2: choose a module, create a view
The top left panel will show all the available modules in your management server. By default a module called “my definitions” will be selected, which is your own private working area. I’ll be building my module here. In the lower left panel there is a drop down with component types in it, select “view” and click the green plus to create a new one.
-
3: choose Export Component
The next popup shows all the available view types, including charts, graphs, reports, tables, and in this case the export component. Note that each one has a handy explanation and visual example to help you choose. Open up “Others” and choose “export component”
-
On the right hand panel, you’ll now get your new view, ready for configuration.
4: Fill in basic info
Now we need to give our view a name, and I’ve also given it the dashboard purpose here, although that isn’t essential.
-
5: Give the view some data
Now things get interesting, a key concept in WCF is context. This probably requires its own blog post, but for the purpose of this article, think of context as the set of data you want your view to populate itself with. If you’ve ever done any development work, you might find it helpful to think of context as the arguments you pass to a method. If you haven’t ever done any development, then that probably doesn’t help at all…
I’m going to tell my view to use some alarm data. In order to get the data to the view we would ordinarily build a query to collect the data from the database, but luckily someone has already built one of those for us that we can borrow.
So, click on the context tab, and in the additional section add a new row, called “allAlarms” and in the “value” column choose “set to binding”->”query”
- In the next popup we need to find the query we’re borrowing, which is located in the “alarms” module and called “current alarms”. Once you’ve chosen it, click set.
-
Now you can move on to telling the view how to display the data.
6: Configure the View
In the configuration tab, you need to tell the view to use the context we just set. click the “value” column in the “rows” row and choose “Context”
- In the popup choose “allAlarms” as the input key
-
What we just did was tell the view that each row of our table is going to use one of the alarms from the list we just passed to it. The next step is to tell it what data to use from each alarm in the columns (in programming terms, we’re building a loop).
Open up the Columns section, add a new column (the green plus sign) and give your column an ID by clicking the “value” column (the ID will be used in the final XML document). Then click the set the value to “context”
- In the popup, set the input key to “currentRow” (Remember, we’re looping through each alarm, so we’re telling it to get data from whichever is the current alarm)
- Then set the path to tell the view which data to display from the alarm in this column (I’ve chosen the alarm severity in this example)
- You can repeat that process to add as many columns as you like:
-
In this example I’ve also added a title for my view (at the bottom of the screen)
7: Test & Consume
When you are done adding columns, hit save and then test and you will be able to see a fully rendered version of your data:
-
You’ll be able to click the links on xml data or schema to see the XML version of your data.
Note that if you grab the view ID of your component (called the reference ID in the definitions panel) you can access the xml directly using the following URL (this example is the last 4 hours)
http://[URL of FMS]/console/xml/[VIEW ID HERE]?timeRange=last%3A4.hour%3Braw
An example XML document can be found here:
Conclusion:
Hopefully you managed to follow through on this, alarms are only a starting point for the export component. Any data held within foglight can be exported and reused in other tools in any way you need. If you have any questions, comments, or examples of components please leave a comment, and I’ll get back to you asap!
I’ve also posted a companion video to this tutorial to youtube:
(Please visit the site to view this video)
https://www.youtube.com/watch?v=bipgyjpioqo
Lee.