Splunk Dev

StreamingCommand Inappropriately Removes Leading Spaces

malvidin
Communicator

I can find a way to get results from a StreamingCommand to retain leading spaces. It doesn't matter if the field was fine before the app, it is gone afterward. Or even if the field wasn't processed by the command.

 

| makeresults
| eval test1 = "  "
| eval test2 = urldecode("%20%20")
| eval ok_here = if(test1==test2 AND len(test1) == 2, "true", "false")
| eval value_for_command = "nothing_special"
| customstreamingcommand field=value_for_command
| eval still_ok_here = if(test1==test2 AND len(test1) == 2, "true", "false")

In this simple case, "still_ok_here"  is false, but the same test was true before the command.

 

 

Labels (1)
0 Karma

malvidin
Communicator

I found a solution, but the problem may not be with the SDK. The SDK reads the data passed from the search command, but Splunk strips the data when passed back to Splunk.

The workaround is to modify the SDK 'splunklib.searchcommands' CSV dialect to pass the data back with csv.QUOTE_ALL in internals.py. Although this is not recommended by Splunk, it is likely preferable to modifying other Splunk internals.

malvidin
Communicator

csv.QUOTE_NONNUMERIC also works, with potentially less overhead that csv.QUOTE_ALL

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...