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!

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 ...