All Apps and Add-ons

how to split events?

deeptha1992
New Member

I have configured REST API and I am getting data into splunk in XML format. But all the data as a single event it is showing and it contains more that 3000 lines in my event. I want to split the event by job id, ie. each job id should have separate events. How it possible?
Thanks in advance.

0 Karma

pruthvikrishnap
Contributor

You will have to create a custom response handler in vi /opt/splunk/etc/apps/Restta/bin/responsehandler.py, something like this basing on the data you are querying.
class AlarmHandler:

     def __init__(self,**args):
         pass

     def __call__(self, response_object,raw_response_output,response_type,req_args,endpoint):
         if response_type == "xml": 
             import xml.etree.ElementTree as ET
             alarm_list = ET.fromstring(encodeXMLText(raw_response_output))
             for alarm in alarm_list:
                 alarm_xml_str = ET.tostring(alarm, encoding='utf8', method='xml')
                 print_xml_stream(alarm_xml_str)               

         else:
             print_xml_stream(raw_response_output) 
0 Karma

chli_splunk
Splunk Employee
Splunk Employee

If you use REST API input, unfortunately it only supports JSON. You can try to:
1. Check if it's possible to get JSON response rather than XML. Some REST endpoint accepts parameters like ?format=json in the URL
2. Switch to Python code input in AoB. You need to right some basic Python codes to send request, then parse the XML and do whatever you want before indexing them.

0 Karma

burwell
SplunkTrust
SplunkTrust

Can you provide sample data? Do you have time stamps per job?

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...