Getting Data In

Will Splunk run a modular input using system Python on a Universal Forwarder

LukeMurphey
Champion

If I have a modular input written in Python, will Splunk attempt to execute it on a Universal Forwarder if the host has Python installed?

1 Solution

LukeMurphey
Champion

Yes, it will.

Splunk will invoke the system's Python interpreter and run the modular input. Splunk's libraries will not be available (e.g. you won't be able to import splunk in Python) but the the forwarder will attempt to run the input just as it would on a Splunk install that was bundled with Python.

View solution in original post

LukeMurphey
Champion

Yes, it will.

Splunk will invoke the system's Python interpreter and run the modular input. Splunk's libraries will not be available (e.g. you won't be able to import splunk in Python) but the the forwarder will attempt to run the input just as it would on a Splunk install that was bundled with Python.

joshuapetitt
Path Finder

precisely "how" will splunk invoke the system's Python interpreter? I have python 3 and python 2 installed on the system, and the python calls python 3 because how how the PATH is setup. Can I somehow override to tell splunk which python to use?

0 Karma

LukeMurphey
Champion

@joshuapetit: I don't exactly know but I will suspect that Splunk is calling the first interpreter per the PATH setup. You might want to try setting the PATH such that other interpreter is first and seeing if Splunk uses that one instead.

0 Karma

joshuapetitt
Path Finder

Thanks for the reply, I'm trying to do that very thing. Although other parts of the system rely on python 3 being first in the PATH. Is there a way I can set the PATH variable for just the Universal Forwarder? Perhaps via a .conf file?

0 Karma

LukeMurphey
Champion

You should be able to set the PATH via splunk-launch.conf.

Alternatively, it could likely be tested just by doing a local install of Splunk to see if Splunk does indeed use the PATH. In that case, you could likely just sudo to root, adjust the path and then start Splunk manually to see which Python it uses.

0 Karma

joshuapetitt
Path Finder

I've edited the system PATH and Splunk does just call the first python that is found in the path. I'm trying now to set the path in splunk-launch.conf but am not having any success at this. I've started a new question about that here:

https://answers.splunk.com/answers/672234/splunk-universal-forwarder-how-to-set-path-environ.html

0 Karma
Get Updates on the Splunk Community!

Why You Can't Miss .conf25: Unleashing the Power of Agentic AI with Splunk & Cisco

The Defining Technology Movement of Our Lifetime The advent of agentic AI is arguably the defining technology ...

Deep Dive into Federated Analytics: Unlocking the Full Power of Your Security Data

In today’s complex digital landscape, security teams face increasing pressure to protect sprawling data across ...

Your summer travels continue with new course releases

Summer in the Northern hemisphere is in full swing, and is often a time to travel and explore. If your summer ...