Splunk Search

How to set up an alert to send a certain field value based on a set of extracted values from an xml log file?

imsiva
New Member

Hi All,

I'm very new to Splunk. I would like to create an alert from my log file wherein i will first search for a string(log_InfoRequest) from the source file by which i will get the below LINES as a result. From this result i need to filter based on the condition. The condition is if value of the field in status tag is "X" and targetSystem tag is "target", send the value present in id tag 9999 in the same log file. I tried using xmlkv, xpath and some rex. However I'm not getting the desired output. I tried like below but in vain.

sourcetype="CommonLog" host="matrix*" source="/dir/Logging/Mylog.log" log_InfoRequest | xmlkv status=X AND xmlkv targetSystem=target 

my final output would should 9999

---- LINES---

2015/02/08 17:47:13:336,234rggq34-014B-4000-E000-4lnl45n42245,log_InfoRequest,Logging,< ? xml version="1.0" encoding="UTF-8" ? >
< lo:InfoRequestMsg xmlns:lo="http://services.com/Logging/Log" xmlns:ns0="wsdl.http://services.com/Logging/Log" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:me="wsdl.http://services.com/Logging/Log" xsi:type="me:InfoRequestMsg">
  < lo:Info >
    < InfoRequest xmlns:ns0="http://services.com/Logging/Log" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wr="http://www.innovate.com/xmlns/multipart/wrapper/6.0.0" >
      < sourceSystem > source < /sourceSystem >
      < targetSystem > target < /targetSystem >
      < transactionName > myTransaction < /transactionName >
      < ID > 9999 < /ID >
      < status > X < /status >
    < /InfoRequest >
  < /lo:Info >
0 Karma

somesoni2
Revered Legend

Try this

 sourcetype="CommonLog" host="matrix*" source="/dir/Logging/Mylog.log" log_InfoRequest | rex "targetSystem\s*\>(?<target>[^\<]+).*ID\s*\>(?<ID>[^\<]+).*status\s*\>(?<status>[^\<]+)" | where status="X" target="target" | table ID
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...