Hi All,
I followed the example provided below to build a custom module that passes JSON data through
http://dev.splunk.com/view/SP-CAAADXY
This was all well and good and worked perfectly however I found that it did not perform post processing. For example if I have the following AdvancedXML (on pastebin due to crap formatting ui)
http://pastebin.com/KEsGEEQK
Now you can see I have a post processing search occurring. However the example does not handle post processing.
So after much stuffing around I analysed the SimpleResultsTable.py to see how it did it. See %SPLUNK_HOME%/share/splunk/search_mrsparkle/modules/results/SimpleResultsTable.py
Now I ended up with this
http://pastebin.com/YfVsu9g7
However it still doesn't perform the post process and I get all the results for sectionCode instead of the single one I am running
where sectionCode="g01"
on.
Notice in my advancedXML I am also performing a simple table and it works perfectly and only shows the subset of data.
Is there somewhere else I need to code in postprocessing?
Ok worked it out. I was missing a crucial part from the .js component
getResultParams: function($super) {
var params = $super(),
context = this.getContext(),
search = context.get("search"),
sid = search.job.getSearchId(),
postprocess = search.getPostProcess();
if (!sid) this.logger.error(this.moduleType, "Assertion Failed.");
params.sid = sid;
if (postprocess)
params.postprocess = postprocess;
return params;
},
Adding this initially didn't work however I realised my browser was probably caching this .js so I did a refresh while holding down shift and it started working again.
Ok worked it out. I was missing a crucial part from the .js component
getResultParams: function($super) {
var params = $super(),
context = this.getContext(),
search = context.get("search"),
sid = search.job.getSearchId(),
postprocess = search.getPostProcess();
if (!sid) this.logger.error(this.moduleType, "Assertion Failed.");
params.sid = sid;
if (postprocess)
params.postprocess = postprocess;
return params;
},
Adding this initially didn't work however I realised my browser was probably caching this .js so I did a refresh while holding down shift and it started working again.
Great job figuring this out. For busting the cache, you can also hit http://localhost:8000/en-US/_bump and click the bump button.
On further investigation using firebug it appears some parameters are being tacked onto SimpleResultsTable that are not added to my custom one.
Where do these come from and how do I get these added to my custom script?
OOPS you already figured this out.
You can implement getResultParams() - http://dev.splunk.com/view/SP-CAAAD58:
getResultParams: function($super) {
var params = $super();
params.foo = 'bar';
return params;
}
This will add &foo=bar to the query string of the request to your module controller. Note that the default implementation of getResultParams() (which is represented by $super) will populate host_app and client_app for you automagically.