Splunk Dev

Custom Command does not provide all fields from REST

benlc
Path Finder

I created a Custom Command to generate Events from a REST-API.

 

 

[cmdb]
filename = cmdb.py
generating = true
chunked = true
supports_multivalues = true

 

 

 

Command runs. The problem is that there are different field sets per Host, where I'm looping through. 

But I only get the fields where all the hosts have an entry. 

Example:

HostField aField b
fooValueValue
foobarValue 
barValueValue
fbarValue 

 

Field b will not show up in the Splunk Results List.

Code sample. I add the patch report only to those hosts, which have on.

 

 

if len(sorted_patch_report) > 0:
                     sorted_patch_report = (sorted_patch_report[0])

                     sorted_patch_report_renamed = {"Patching_" + str(key): val for key, val in sorted_patch_report.items()}

                     i.update(sorted_patch_report_renamed)
                     #self.logger.fatal(i)

                     yield dict(i)

                 else:
                 #except IndexError:
                      #sorted_patch_report = 'null'
                      self.logger.info("No patch report for "+i['fullQualifiedDomainName'])

                      #self.logger.fatal(i)
                      yield dict(i)

 

 

If I print the dict to logger I see all the fields.

Any Idea?

Labels (2)
0 Karma

tpavlik_splunk
Splunk Employee
Splunk Employee

Thanks for reporting this, we believe the issue has been addressed in version 1.6.18 of the Python SDK. After some discussion with the community on how to release the fix the consensus was to allow developers to opt-in to the fix (see https://github.com/splunk/splunk-sdk-python/issues/401).

Here's more details on how to opt-in to the fix by calling

self.add_field

within the search command: https://github.com/splunk/splunk-sdk-python#customization

0 Karma
Get Updates on the Splunk Community!

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...

Data Management Digest – November 2025

  Welcome to the inaugural edition of Data Management Digest! As your trusted partner in data innovation, the ...