Splunk Dev

Pyton SDK custom command runing distributed instead of local only

FritzWittwer
Path Finder

I have written a generating custom command which generates just one event containing the session token and the search head it runs. This two parameters are then passed to another custom command which runs distributed on the indexers and needs them to call back to the search head.

I am on Splunk Enterprise, Version: 8.0.3 with Splunk Python SDK 1.6.12, single search head and 96 node indexer cluster.

The python script of the command starts with

 

from __future__ import absolute_import, division, print_function, unicode_literals

import os,sys
import time

splunkhome = os.environ['SPLUNK_HOME']
sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'searchcommands_app', 'lib'))
from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option, validators


@Configuration(streaming=True, local=True)
class callbackconnection(GeneratingCommand): 
 .......

 

 


The definition of the command in commands.conf is:

 

[callbackconnection]
filename = callbackconnection.py
# python.version=python3
chunked = true

 

 


This command runs fine while using python 2.x but as soon as python.version=python3 is active in the definition of the command in commands.conf, the command gets distributed to the indexers an returns 97 results.

I tried various  @configuration(....) settings, but with python 3 the command is always distributed to the indexers.

Labels (2)
0 Karma

thellmann
Splunk Employee
Splunk Employee

In addition to the above, I would recommend updating to 1.6.14+ of the Splunk Enterprise SDK for Python, since there are specific fixes for custom search commands in that version. 

0 Karma

thellmann
Splunk Employee
Splunk Employee

By "above" I meant "fk319 's post" - sorry. 

0 Karma

fk319
Builder
0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...