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!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...