Lee Farrar and I work on the Foglight field team in the UK. Today I'd like to tell you about a little known feature of Foglight that I think could be very useful for a lot of you; RSS feeds. Foglight's WCF technology makes it nice and simple for users to create their own dashboards and views, and few are as simple to put together as an RSS feed.
As ever, there are a couple of pre-reqs for building a feed, so you will need:
- Something you want to monitor (I'll be using a service, but you could use anything)
- Dashboard designer or cartridge developer role
- Something to consume RSS feeds (not absolutely necessary, but sort of useful...)
In this post I'll be focusing on building a feed, I won't be going into too much detail about WCF or services, so if you haven't come across them before it might be worth checking some of the other great posts out on Foglight.org first or checking the Foglight documentation.
Here's one I made earlier.
In true TV style, Foglight ships with a feed built in for all current alarms in the system. If you'd like to see the end result of today's' blog, you can go to configuration -> feeds to see it, or head to http://:8080/console/feed/system:core_alarms.28 in your browser.
Prepare your data.
A feed can be a list of any data objects, in this example, I'm going to create a feed of alarms for my Tasty Snacks service. In order to get your data into a feed you need to build a WCF Query. Luckily, Foglight ships with a number of built in queries and we'll be able to leverage one of those today (more on that later)
So without further ado, lets build a feed. Head on over to Configuration->definitions, in here you probably want to create your own module to work in if you haven't already. When that is setup, add a new view, choose "others->Syndication Feed".
Give your feed a name, and set its purpose to "feed". If you want your feed to show up in the "feeds" dashboard you should also set your feed to "public" and give it a relevant role. It also makes sense to remove the "timerange" context in this example as well. Once that is done, click on Configuration.
There's a few things to setup in here, first of all give your feed title and description (these are straight forward localized strings).
Then we tell Foglight what data we're going to use in our feed, as we mentioned earlier I want my feed to be a list of alarms in my Tasty Snacks service, there is a nice query built in for that, so I'll choose "Query", then pick my "Get Outstanding aggregateAlarms for TopologyObject" query (this query does what it says, and returns all the alarms for a given topology object, remember that any data in Foglight descends from TopologyObject).
This query takes a parameter, which is the topology object you wish to get alarms from, so I'll pop my service in there by clicking on data:
Then drilling down through services, all services, until I find the one I'm after:
When you've worked through those steps, the popup should look like the below:
When we're done, click Ok, and we're ready to setup the fields for our feed. If you haven't already, click on "Show advanced properties" at the top of the configuration page, this will revel a couple of extra fields for you.
The feed will iterate through each row returned by the query we just setup, and now we choose which fields to write to the feed on each iteration. For my example, I've picked my hostname, the alert message, the created date, and the severity of the alert (see the screenshot above for the completed configuration screen). The process for each of these is the same.
Choose "context", then in the popup use the "currentItem" as the input key, and pick your field from the Path input. In the below example I navigate the model to find the host that the alert originated from.
Once you have chosen your fields (the minimum you need are title and description for each item in the feed) you can click on "Test" and you should see something like the below:
Although this looks like any other dashboard in Foglight, this is actually a feed, you can access it by visiting http://:8080/console/feed/ (reference ID is available from the right hand panel when you save your feed.), and if you visit configuration -> feeds you should find your feed appears in there. You can now add this feed to your favourite reader.
Although the examples shown have all discussed feeds of alarms, there are lots more interesting use cases for feeds in Foglight, for example a feed of new hosts that have checked in but don't have agents deployed yet.