Archive

Splunk could not find a controller to import for the following module: "Splunk.Module.Test".

Explorer

I am working on a custom module that extends the SingleValue module. I couldn't get the custom module to work correctly by placing it in the appserver/modules directory so I moved it to the %SPLUNK_HOME%\share\splunk\search_mrsparkle\modules directory. The module is now throwing this error:

Splunk could not find a controller to import for the following module: "Splunk.Module.Test".

I created the following files: Test.js, Test.conf, and Test.html. Test.conf is a copy of the SingleValue.conf file. What do I need to change to get Test to extend SingleValue?

Test.js:

//put Module in the namespace if it isnt already there.
Splunk.namespace("Module");

Splunk.Module.Test = $.klass(Splunk.Module.SingleValue, {

});

Test.html

<%page args="module"/>
<div class="SingleValueHolder">
    <span class="singleLabel singleLabelBefore"></span>
    <span class="singleResult">...</span>
    <span class="singleLabel singleLabelAfter"></span>
</div>

Test.conf

[module]
# The JavaScript name of the module
className = Splunk.Module.Test

# The module class to subclass from
superClass = Splunk.Module.SingleValue

description = This module waits for the search to complete and then renders a single field from the first row of the results

[param:beforeLabel]
label = Label to display before the result
required = False
translate = string
default =

[param:afterLabel]
label = Label to display after the result
required = False
translate = string
default =

[param:field]
label = Field to display - Defaults to first field returned
required = False
default =

[param:additionalClass]
label = An optional additional css class name to add to the result container
required = False
default =

[param:classField]
label = Adds the value of the classField of the first result as an additional css class to the result container.  Pre-defined classes include 'severe', 'elevated', 'low', and 'None' (default).
required = False
default = 

[param:linkSearch]
label = Specify a valid complete search query to turn the result into a clickable link
required = False
default =

[param:linkView]
label = Specify which view to execute the linked search against
required = False
default = dashboard

[param:linkFields]
label = Specify whether to just link the result, or include labels.  To link the result and both labels, specify "result,beforeLabel,afterLabel"
required = False
default = result

[param:format]
label = Specifies the data formatting method to apply to the value.  Locale aware.  Defaults to none.
required = False
values = number,decimal,percent,none
Tags (1)
0 Karma

SplunkTrust
SplunkTrust

I agree that restarting SplunkWeb should make the error go away.

One word of general warning. I've found when writing custom modules, if you try and subclass any of the core Splunk modules besides from the base classes AbstractModule or DispatchingModule, SplunkWeb wont necessarily include the files in the right order. If it chooses to output your custom module code first and then the SingleValue module, things will break. The order it does choose is a little unpredictable from what I remember and varies from platform to platform and maybe even server to server. In the end I gave up and so Sideview Utils doesnt subclass from any modules except the two base classes.

While we're on the topic, within the Sideview Utils app, I created the HTML module specifically to obsolete SingleValue. You might want to pull Sideview Utils down and check it out; it might already have everything you need. There's decent documentation about all the modules and the techniques, but it's all contained within views inside the app itself, so it's a little unintuitive; you have to download the app first and only then decide if you want to use it. Cheers.

http://splunk-base.splunk.com/apps/22279/sideview-utils

0 Karma

New Member

I had the same error until I restarted splunk and then it went away. If not, just make sure you follow all the directions here: http://splunk-base.splunk.com/answers/6666/how-do-you-create-custom-modules

0 Karma