I am running a custom python search command for custom alerting from Splunk which takes variables from the search query and using the map command to feed the set variables into the script.
I'll use the sendemail command as an example;
host="myserver" "OutOfMemory" | map search="| sendemail to="
[email protected]" subject=$host$ server="mailhost""
This works perfectly when run directly via the GUI search, however if I turn this into a ScheduledSearch using the same query it doesn't work. Splunk logs will indicate that it ran succesfully and didnt encounter any exceptions however my email does not get sent.
By turning the sendemail function to echo the output into a text file I can see that nothing happens either. What gets interesting is that if I replace $host$ with "myservername" and dont use any $variables$ it works!
I have tried escaping the strings passed to the python script directly within the script when extracting the variables though it has no affect.
subject=\"\'$host$\'\"
By double quoting the above it still works via the GUI, though when scheduled my email sends but with subject as inner quotes - \'\'
Indicating that the variable is either not being transformed or is replaced with nothing.
I have tried placing the entire search query again within the sub map search with no affect either...
Any suggestions would be great, otherwise I'll have to raise a support case.
Note: This is on a windows server.
... View more