Getting Data In

Service item.update causes modular input to restart

aronsemle
New Member

In my modular input I want to update a configuration setting between runs so I don't poll for the same data again and again. The code I use to do this is below. It's using the splunklib.client library (https://docs.splunk.com/DocumentationStatic/PythonSDK/1.1/client.html#splunklib.client.Service.login) to make a REST connection to Splunk, using the session held by the modular input, it grabs the config section and calls item.update to update the query_param.

The call to item.update causes the entire modular input to reload... and in the logs I get a "Winsock error 10054", most likely because of the reload.

I'm on Splunk 8.0.1 running Python3. I can't find any documentation on this behavior. I tried not using the SESSION_TOKEN, and instead connecting with username/password, but same issue. I also tried adding service.logout at the end, but that code never executes. Is this expected?

            try:
                args = {'host':'localhost','port':SPLUNK_PORT,'token':SESSION_TOKEN}
                service = Service(**args)

                item = service.inputs.__getitem__(STANZA[len(APP_NAME) + 3:])
                item.update(query_params = dictionary_to_params(url_args))

            except Exception as e:
                logging.error("Error trying to update args: %s" % str(e))

One last note. In the logs I get the following warning. I assume this is being causes by the app restarting.

03-16-2020 08:52:25.232 -0400 WARN HttpListener - Socket error from 127.0.0.1:56292 while accessing /servicesNS/nobody/launcher/data/inputs/my_app/my_data_input/: Winsock error 10054

0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

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