Deployment Architecture

Custom Flash Module development

WayneClarke
Explorer

I am currently working on developing a number of custom flash modules. In which I have had limited success.

  1. Is there a list of required/recommended libraries for the action scripts.
  2. An example data input function (action script) to receive data from the web server.
  3. If possible a simple example module with un-compiled flash and action script files.

I am hoping to share the modules on splunkbase once finished.

Tags (1)

jgatt
Splunk Employee
Splunk Employee

When developing custom flash modules, you’re basically on your own. You will have to create custom module code to hold your swf (you won’t be able to use FlashWrapper since it has a lot of stuff that is specific to Splunk swfs). There are no Splunk ActionScript libraries to help you out here, but you don’t really need them anyway. All communication with Splunk can be done through the standard URLLoader class in Flash.

Flash communicates with Splunk via proxied REST endpoints. These are the same as the REST endpoints on splunkd, but they are served through splunkweb to get around the limitations of Flash not fully supporting REST. For example, the endpoint you will probably use exclusively is the results_preview endpoint:

http://<splunkhost>:<splunkwebport>/en-US/splunkd/search/jobs/<jobid>/results_preview/

You simply have to make a request from Flash to this endpoint with the appropriate parameters (see the REST documentation for specific parameters). The one parameter of interest for consuming data in Flash is the output_mode parameter. This parameter allows you to specify whether the data you receive is in xml, json, or csv format (I believe the default is xml if the parameter is not specified). Since Flash has built in support for XML, the xml output_mode is probably the easiest to use out of the box. However, it is also the heaviest. We use the csv format for our Flash modules since it is the lightest weight, but this requires a custom CSV parser to consume. Fortunately, CSV is not a difficult format to parse, so you can probably write a CSV parser yourself (or find a third party library). Also, Adobe makes an open source library that parses JSON, if you’re interested in using that format.

The only other advice I can give is the following:

Your module code (JavaScript) needs to do 4 things:

  1. Embed your swf.
  2. Pass your swf the base path for loading data. This can be done through an embed parameter using Splunk.util.make_url('/splunkd') to generate the appropriate path.
  3. Pass your swf the job id for loading data. This can be done by exposing an ExternalInterface method to allow the job id to be changed at any time. This method should be called from the onContextChange method in JavaScript.
  4. Tell your swf to load the data. This can be done by exposing another ExternalInterface method. This method should be called from the onContextChange, onJobProgress, and onJobDone methods in JavaScript.

Then, in Flash, you will simply construct a url like the one above by concatenating basePath + “/search/jobs/” + jobID + “/results_preview”, and make a request to that url (with whatever parameters you decide) when your loadData method is called.

If you can get that far you should be golden, and you can then create anything you want in Flash.

Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...