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 Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...