<?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: Need help with log having multiple occurrence of same field in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Need-help-with-log-having-multiple-occurrence-of-same-field/m-p/323028#M60147</link>
    <description>&lt;P&gt;@abishekmaggo, first occurrence of field4 is followed by field6 while the second occurrence of field4 is followed by field8. So maybe you can use that to your advantage.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| rex "field4=(?&amp;lt;field4&amp;gt;[^,]+),field6="
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 07 Apr 2018 16:23:32 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-04-07T16:23:32Z</dc:date>
    <item>
      <title>Need help with log having multiple occurrence of same field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Need-help-with-log-having-multiple-occurrence-of-same-field/m-p/323026#M60145</link>
      <description>&lt;P&gt;I have following logs where field4 is coming twice in each log line.&lt;/P&gt;

&lt;P&gt;Example:&lt;BR /&gt;
2018-04-06T23:01:36.264+0000 logLevel=INFO Response=(( filed1=XXX, field2=ZZZZ), field3=jeSession, field4=abc_xxx, field6=ddd.com, field6=)) field7=service1 field4=xyz_xxx field8=ser1&lt;BR /&gt;
2018-04-06T23:01:36.264+0000 logLevel=INFO Response=(( filed1=YYY, field2=ZZZZ1), field3=tuSession, field4=abc_yyy, field6=ccc.com, field6=)) field7=service2 field4=xyz_yyy field8=ser2&lt;/P&gt;

&lt;P&gt;How I can make sure it always pick first field4 for value (one with value as "acd_xxx", "abc_yyy"). I tried using mvindex but it works with multiple value in field itself (e.g. field4=xxx,yyy)&lt;/P&gt;

&lt;P&gt;I want to display count by first field4 only&lt;BR /&gt;&lt;BR /&gt;
index=XXXXX | eval res=mvindex(field4,0) | stats count by res&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:56:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Need-help-with-log-having-multiple-occurrence-of-same-field/m-p/323026#M60145</guid>
      <dc:creator>abishekmaggo</dc:creator>
      <dc:date>2020-09-29T18:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with log having multiple occurrence of same field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Need-help-with-log-having-multiple-occurrence-of-same-field/m-p/323027#M60146</link>
      <description>&lt;P&gt;hello there,&lt;/P&gt;

&lt;P&gt;i am positive there other ways to solve it, here is a quick one assuming your data looks always like your samples&lt;BR /&gt;
use the &lt;CODE&gt;|rex&lt;/CODE&gt; command to point only to your first &lt;CODE&gt;field4&lt;/CODE&gt; maybe something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = XXXXX
| rex "field3=\S+,\sfield4=(?&amp;lt;field4&amp;gt;\S+),"
| stats count by field4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;see link:&lt;BR /&gt;
&lt;A href="https://regex101.com/r/uMivWN/1"&gt;https://regex101.com/r/uMivWN/1&lt;/A&gt;&lt;BR /&gt;
note: my regex might not be the best one&lt;/P&gt;

&lt;P&gt;hope it helps&lt;/P&gt;</description>
      <pubDate>Sat, 07 Apr 2018 01:52:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Need-help-with-log-having-multiple-occurrence-of-same-field/m-p/323027#M60146</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-04-07T01:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with log having multiple occurrence of same field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Need-help-with-log-having-multiple-occurrence-of-same-field/m-p/323028#M60147</link>
      <description>&lt;P&gt;@abishekmaggo, first occurrence of field4 is followed by field6 while the second occurrence of field4 is followed by field8. So maybe you can use that to your advantage.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| rex "field4=(?&amp;lt;field4&amp;gt;[^,]+),field6="
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 Apr 2018 16:23:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Need-help-with-log-having-multiple-occurrence-of-same-field/m-p/323028#M60147</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-07T16:23:32Z</dc:date>
    </item>
  </channel>
</rss>

