My question is about how to set a token value in a django template taken from the results of a searchmanager job.
For example:
- Searchmanager runs a search across an index that provides a username field in the results
- Set token $username$ to the result of that search
- Use token in content block, use token in another searchmanager
I've tried something similar to this:
{% block content %}
...
<span id=testHTMLTag></span>
...
{% endblock content%}
{% block managers %}
{% searchmanager
id="current_username"
search='| rest /services/authentication/current-context | fields username'
%}
{% endblock managers %}
{% block js %}
<script>
require(["splunkjs/ready!"], function(mvc) {
var current_username = mvc.Components.getInstance("current_username");
var tokens = mvc.Components.getInstance("default");
document.getElementById('testHTMLTag').innerHTML = current_username.data("result");
tokens.set({
"username": var tokens = mvc.Components.getInstance("default")[0].username;
});
</script>
{% endblock js %}
The problem here is that I'm black box testing against the searchmanager results model since I've been unable to locate sufficient documentation that describes the results model object and how to interact with it.
I realize there are a lot of ways to skin the username cat, what I'm interested in is a more generic approach to extracting specific row/column data from a search and assigning it to tokens for use by other Splunk components.
I will also realize that I might be going down a huge rabbit hole with the obvious answer staring me right in the face. In short I would love to be able to do a ResultsValueSetter in the Web Framework.
Clears as mud?
Thanks, Chris