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!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...