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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...