TIPS & TRICKS

So you want to write an app

With the previous setup, here’s what I want for my app:

A dashboard with a couple pretty pictures and some top N lists
Saved searches for advanced users to explore further
It should work for all my users with whatever indexes they have access to

I’m going to start with the sample_app template available in Manager and add what I want. Then I’ll clean up the sample stuff I don’t need. So the first step is to create a new app in Manager->Apps. Give it a name and an optional label and select “sample_app” as the template. I don’t have any additional files to upload now, so I’ll leave that alone. Save and I’m back to the list of installed apps.

On the filesystem, a bunch of things just happened. The directory MyGreatApp was created, containing a complete app structure and sample files, enough to have a functioning app. These files are all based on simplified XML that hides much of the complexity of the underlying full XML format. This makes it easier to build views, but has limitations. (For more on this see the docs: Simple Dashboards)

Some highlights:

MyGreatApp/appserver/static contains the app’s css and images. There are a bunch of basic images provided that can be used or replaced.

MyGreatApp/default contains the conf files that make up my app. This includes app.conf, where the app name, author, description and version are set.

MyGreatApp/default/data/ui/nav contains the XML file that define your menus. There is a default.xml ready to be customized.

MyGreatApp//default/data/ui/views contains XML files that define your views. The several provided sample_*.xml files can be edited, or new ones created.

If you switch to the new app (by exiting Manager back to where I was and using the App menu in the top right) it has dashboards and various kinds of searches already. If you save a search of your own while you are in this app, it will end up in the Searches->unclassified searches menu.

You can create a new empty dashboard with Actions-> Create new dashboard and add saved searches to it. Simple drag and drop dashboards are a quick way to make pretty pictures. It’s just a new view, and you can make one of your own in any app you have permission to. Like the saved searches, it will be private unless you set it to be accessible by others. If you don’t like your app, delete its directory from the filesystem directly and restart.

Next I’ll get into where it is possible to make changes to these files directly and where you should use the UI.

Splunk
Posted by

Splunk

Join the Discussion