Splunk Search

Can I get field extraction for XML data that is a data field in a JSON event?

wfrankl2
Explorer

I have event data coming into Splunk as JSON, that's all fine and works great, but one of the fields they are going to use is XML. Is there a way to get the XML field extracted from that? Right now it puts the XML as the value in a data field, but they want to search on values in the XML.

snippet

ThreadId:  9 
    TransactionDataXML:  <TransactionDataXML><Input><Extensions><SourceSystem>application</SourceSystem></Extensions></Input><Output><StorePolicyPacketServiceResponse><ResponseCode>0</ResponseCode><ResponseDetails><TransactionId>091ef6c7-7d6b-4374-ac6b-8ec67abc6a96</TransactionId><ElapsedTime>30080</ElapsedTime><MachineId>server</MachineId><OriginalRequest><Extensions><SourceSystem>application</SourceSystem></Extensions></OriginalRequest></ResponseDetails></StorePolicyPacketServiceResponse></Output></TransactionDataXML> 
    TransactionDateTime:  2016-01-28T14:38:36.729986-05:00 
0 Karma

somesoni2
Revered Legend

Try something like this (run anywhere sample)

| gentimes start=-1 | eval _raw="{
    \"LogName\": \"ExampleLog\",
    \"CorrelationId\": \"f879095a-0109-4235-8ba8-218f43f27220\",
    \"LoggingLevel\": \"All\",
    \"ThreadId\": \"9\",
    \"LocalTimeStamp\": \"2016-01-28T14:38:36.748986-05:00\",
    \"AccessModeName\": \"ABC\",
    \"AgentCode\": \"00000\",
    \"AgentPrefixCode\": \"CA\",
    \"ApplicationName\": \"UQ\",
    \"ChannelCode\": \"DI\",
    \"CIFCommonSchemaVersionNbr\": \"V0200\",
    \"CIFGeneratedSchemaId\": \"05c0b8a4-2954-4fb7-a6ae-def569bd4b63\",
    \"CIFSoftwareVersionNbr\": \"1.2\",
    \"DataCenterLocationText\": \"None\",
    \"InstrumentationLogDateTime\": \"/Date(1454070556298)/\",
    \"LoggingComputerSystemName\": \"mycomputer\",
    \"LoggingLevelName\": \"Critical\",
    \"MessageText\": \"Hello world\",
    \"OperatingEnvironmentName\": \"Development\",
    \"PartyLogonIdTypeName\": \"None\",
    \"TransactionDataXML\": \"<application><GUID>0091ef6c7-7d6b-4374-ac6b-8ec67abc6a9630080</GUID><name>Test</name></application>\",
    \"TransactionDateTime\": \"2016-01-28T14:38:36.729986-05:00\",
    \"CIFSchemaValidationErrors\": [
        \"AccessModeName should be 10 characters\"
    ],
    \"CIFSchemaValidated\": true,
    \"Custom1\": \"Custom1Value\",
    \"EventId\": 0,
    \"CIFUniqueMessageId\": \"f879095a-0109-4235-8ba8-218f43f27220\"
}" | table _raw | spath| spath input=TransactionDataXML

alemarzu
Motivator
0 Karma

wfrankl2
Explorer

I will check it out. I tried to give a snippet of the code but it removed all formatting. I will give it another try.

{"LogName":"ExampleLog","CorrelationId":"f879095a-0109-4235-8ba8-218f43f27220","LoggingLevel":"All","ThreadId":"9","LocalTimeStamp":"2016-01-28T14:38:36.748986-05:00","AccessModeName":"ABC","AgentCode":"00000","AgentPrefixCode":"CA","ApplicationName":"UQ","ChannelCode":"DI","CIFCommonSchemaVersionNbr":"V0200","CIFGeneratedSchemaId":"05c0b8a4-2954-4fb7-a6ae-def569bd4b63","CIFSoftwareVersionNbr":"1.2","DataCenterLocationText":"None","InstrumentationLogDateTime":"/Date(1454070556298)/","LoggingComputerSystemName":"mycomputer","LoggingLevelName":"Critical","MessageText":"Hello world","OperatingEnvironmentName":"Development","PartyLogonIdTypeName":"None","TransactionDataXML":"application0091ef6c7-7d6b-4374-ac6b-8ec67abc6a9630080serverapplication","TransactionDateTime":"2016-01-28T14:38:36.729986-05:00","CIFSchemaValidationErrors":["AccessModeName should be 10 characters"],"CIFSchemaValidated":true,"Custom1":"Custom1Value","EventId":0,"CIFUniqueMessageId":"f879095a-0109-4235-8ba8-218f43f27220"}
0 Karma

wfrankl2
Explorer

It removes my xml formatting when I paste it in. the TransactiondataXML is the field where the data would be.

0 Karma
Get Updates on the Splunk Community!

Now Available: Cisco Talos Threat Intelligence Integrations for Splunk Security Cloud ...

At .conf24, we shared that we were in the process of integrating Cisco Talos threat intelligence into Splunk ...

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Easily Improve Agent Saturation with the Splunk Add-on for OpenTelemetry Collector

Agent Saturation What and Whys In application performance monitoring, saturation is defined as the total load ...