<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Extract Data From Event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184563#M53172</link>
    <description>&lt;P&gt;Hi thank you for coming back to me with this I really appreciate it.&lt;/P&gt;

&lt;P&gt;Your assumption is correct in that I'm trying to extract multiple empRef's from a single event, so I ran your script and it works perfectly.&lt;/P&gt;

&lt;P&gt;But when I tried to run this using my full script i.e. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="main" detail.responseMessage="*empRef*" | rex field=var "\"empRef\":\"(?&amp;lt;empRef&amp;gt;[^\"]*)\"" max_match=0
  | stats count by empRef
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the list of empRef's are not shown.&lt;/P&gt;

&lt;P&gt;Many thanks for all your help and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Wed, 26 Aug 2015 06:10:52 GMT</pubDate>
    <dc:creator>IRHM73</dc:creator>
    <dc:date>2015-08-26T06:10:52Z</dc:date>
    <item>
      <title>Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184554#M53163</link>
      <description>&lt;P&gt;Hi, I wonder whether someone can help me please.&lt;/P&gt;

&lt;P&gt;I have multiple events which include the following piece of information "empRef\":\"012/A12345\" in the middle of the event.&lt;/P&gt;

&lt;P&gt;Could someone perhaps tell me please how it's possible to extract this piece of information from the event data.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris &lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 06:40:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184554#M53163</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-08-24T06:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184555#M53164</link>
      <description>&lt;P&gt;I can't really tell what comes before and after that piece of information you want to extract, but I think what you're looking for is &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.5/SearchReference/Regex"&gt;Regex&lt;/A&gt;.&lt;BR /&gt;
If your data looks something like that:&lt;BR /&gt;
...abcde"empRef":"012/A12345"abcde...&lt;BR /&gt;
You should be able to make a Regular Expression that will extract that exect piece from the rest.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 06:48:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184555#M53164</guid>
      <dc:creator>liorfink</dc:creator>
      <dc:date>2015-08-24T06:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184556#M53165</link>
      <description>&lt;P&gt;You need to use the rex command&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.5/SearchReference/rex"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.5/SearchReference/rex&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=_raw "\"empRef\":\"(?&amp;lt;empRef&amp;gt;[^\"]*)\"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;(disclaimer: regex untested!)&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 07:39:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184556#M53165</guid>
      <dc:creator>pwmcity</dc:creator>
      <dc:date>2015-08-24T07:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184557#M53166</link>
      <description>&lt;P&gt;Hi @pwmcity, thank you very much for this. I'll be able to work with this.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 07:44:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184557#M53166</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-08-24T07:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184558#M53167</link>
      <description>&lt;P&gt;HI @liorfink, thank you very much for taking the time to come  back to me with this.&lt;/P&gt;

&lt;P&gt;Kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 07:45:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184558#M53167</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-08-24T07:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184559#M53168</link>
      <description>&lt;P&gt;Did it work? What's the error?&lt;/P&gt;

&lt;P&gt;regex appears to work: &lt;A href="https://regex101.com/r/uP9iB9/1"&gt;https://regex101.com/r/uP9iB9/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2015 08:12:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184559#M53168</guid>
      <dc:creator>pwmcity</dc:creator>
      <dc:date>2015-08-25T08:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184560#M53169</link>
      <description>&lt;P&gt;Hi intially, I received an unbalanced quotes error message, so I inserted a " at the end of the regex which removed the error.&lt;/P&gt;

&lt;P&gt;I then add &lt;CODE&gt;| stats count by empRef&lt;/CODE&gt; to the end of the search because I am just wanting to create a list of the empRef field values, and although the search runs and the events are shown, no list is being created.&lt;/P&gt;

&lt;P&gt;My apologies for the novice type problem.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris &lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2015 08:22:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184560#M53169</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-08-25T08:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184561#M53170</link>
      <description>&lt;P&gt;Hi I'm not sure whether this is of help, but I've managed to get the 'Field Extractor' working and have come up with the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (?=[^e]*(?:empRef|e.*empRef))^(?:[^\\\n]*\\){7}"(?P&amp;lt;REF&amp;gt;[^\\]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem I have is that I'm not sure how to incorporate this into my search.&lt;/P&gt;

&lt;P&gt;I've tried &lt;CODE&gt;rex " (?=[^e]*(?:empRef|e.*empRef))^(?:[^\\\n]*\\){7}"(?P[^\\]+)"&lt;/CODE&gt; but I receive a parser error.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2015 09:18:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184561#M53170</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-08-25T09:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184562#M53171</link>
      <description>&lt;P&gt;Not sure what's going on there, but your regex has gotten overly complicated!&lt;/P&gt;

&lt;P&gt;Is it that you're trying to capture multiple empRef in a single event? The Rex command defaults to 1, so you can set that with max_match=0 for unlimited.&lt;/P&gt;

&lt;P&gt;I put your example string into splunk, to see if it was the way splunk handles double-quotes... but that's not the case and it worked fine, it produces a field 'var' with your example data, and a field 'empRef' with the expected 2 values&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal
| eval var="[{\"friendlyName\":\"\",\"empRef\":\"012/AB00000\"},{\"friendlyName\":\"\",\"empRef\":\"023/AB11111\"}]"
| rex field=var "\"empRef\":\"(?&amp;lt;empRef&amp;gt;[^\"]*)\"" max_match=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Aug 2015 00:06:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184562#M53171</guid>
      <dc:creator>pwmcity</dc:creator>
      <dc:date>2015-08-26T00:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184563#M53172</link>
      <description>&lt;P&gt;Hi thank you for coming back to me with this I really appreciate it.&lt;/P&gt;

&lt;P&gt;Your assumption is correct in that I'm trying to extract multiple empRef's from a single event, so I ran your script and it works perfectly.&lt;/P&gt;

&lt;P&gt;But when I tried to run this using my full script i.e. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="main" detail.responseMessage="*empRef*" | rex field=var "\"empRef\":\"(?&amp;lt;empRef&amp;gt;[^\"]*)\"" max_match=0
  | stats count by empRef
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the list of empRef's are not shown.&lt;/P&gt;

&lt;P&gt;Many thanks for all your help and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2015 06:10:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184563#M53172</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-08-26T06:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184564#M53173</link>
      <description>&lt;P&gt;Hi @pwmcity, I'm really very sorry to trouble you with this again, but I just wondered whether you may have had a chance to look at my last comment and the problems I'm still having with extracting the data.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2015 06:53:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184564#M53173</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-08-28T06:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184565#M53174</link>
      <description>&lt;P&gt;It could be an issue with mv .... the problem is that since there are multiple empRef values per event, it means now you have a 'multivalue' field. If you look up the available mv commands (&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Commandsbycategory"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Commandsbycategory&lt;/A&gt;) and search for mv ... you'll see a few commands there.&lt;/P&gt;

&lt;P&gt;You could try &lt;CODE&gt;| mvexpand empRef | stats count by empRef&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Aside from that, have you gone into verbose mode and checked to see if your empRef field is actually being populated?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2015 00:16:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184565#M53174</guid>
      <dc:creator>pwmcity</dc:creator>
      <dc:date>2015-09-01T00:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Data From Event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184566#M53175</link>
      <description>&lt;P&gt;Hi @pwmcity, thank you very much for coming back to me with this and my apologies for not replying sooner. The empRef is definitely being populated so I'll have a look at the documentation you highlighted. &lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 06:19:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Data-From-Event/m-p/184566#M53175</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-09-23T06:19:57Z</dc:date>
    </item>
  </channel>
</rss>

