Getting Data In

ERROR ExecProcessor - message from "script.py" Error: cannot serialize {json}

manudbc
Explorer

Hi,
I have a Script which download a Json, it look like:
def stream_events(self, inputs, ew):
ew.log("INFO","Adding data")
for input_name, input_item in inputs.inputs.iteritems():
api = input_item["api"]

                        try:
                                r = requests.get("URL".format(api))
                                t = json.loads(r.content)
                        except Exception as e:
                                ew.log("ERROR", "Error: %s" % str(e))

                        try:
                                for elements in t['notifications']:
                                        logevent = Event()
                                        logevent.stanza = input_name
                                        logevent.data = elements
                                        ew.write_event(logevent)
                        except Exception as e:
                                ew.log("ERROR", "Error: %s" % str(e))

And I having thaths error in index= "__internals":
ERROR ExecProcessor - message from "script.py" Error: cannot serialize {json}

How can I solve It?

Tags (2)
0 Karma
1 Solution

manudbc
Explorer

Solved
It was a problem in this line:
logevent.data = elements

Solved line:
logevent.data = json.dumps(elements, sort_keys=True, separators=(',',':'))

View solution in original post

0 Karma

manudbc
Explorer

Solved
It was a problem in this line:
logevent.data = elements

Solved line:
logevent.data = json.dumps(elements, sort_keys=True, separators=(',',':'))

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security: Your Command Center for PCI DSS Compliance

Every security professional knows the drill. The PCI DSS audit is approaching, and suddenly everyone's asking ...

Developer Spotlight with Guilhem Marchand

From Splunk Engineer to Founder: The Journey Behind TrackMe    After spending over 12 years working full time ...

Cisco Catalyst Center Meets Splunk ITSI: From 'Payments Are Down' to Root Cause in ...

The Problem: When Networks and Services Don't Talk Payment systems fail at a retail location. Customers are ...