<?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 value with matching multiple fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283330#M85624</link>
    <description>&lt;P&gt;This inserts your sample data &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults 
| eval mydata=mvappend("domain=abc, server=abc_s1,status=running",
"domain=abc, server=abc_s2,status=shutdown",
"domain=xyz, server=xyz_s1,status=running",
"domain=xyz, server=xyz_s2,status=shutdown")
| mvexpand mydata 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This turns it into the requested chart-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=mydata "domain=(?&amp;lt;mydomain&amp;gt;[^,]*),\s*server=(?&amp;lt;myserver&amp;gt;[^_]*_(?&amp;lt;myinstance&amp;gt;[^,]+)),\s*status=(?&amp;lt;mystatus&amp;gt;.*)"
| chart first(mystatus) as status over mydomain by myinstance
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With the results looking like this - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mydomain  s1        s2        
abc       running   shutdown  
xyz       running   shutdown  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've assumed that your server names are constructed by domain name, an underscore, and the instance name.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2017 19:18:36 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-02-09T19:18:36Z</dc:date>
    <item>
      <title>extract value with matching multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283325#M85619</link>
      <description>&lt;P&gt;If i have events like below,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;domain=abc, sever=abc_s1,status=running
domain=abc, server=abc_s2,status=shutdown
domain=xyz, sever=xyz_s1,status=running
domain=xyz, server=xyz_s2,status=shutdown
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to create a table like below with new fields &lt;CODE&gt;instance1&lt;/CODE&gt; and &lt;CODE&gt;instance2&lt;/CODE&gt;, where instance1 should have the value of &lt;CODE&gt;status&lt;/CODE&gt; for &lt;CODE&gt;($domain)_s1&lt;/CODE&gt; .  and instance2 should have the value of &lt;CODE&gt;status&lt;/CODE&gt; for &lt;CODE&gt;$domain_s2&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;can be this achievable?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;domain            instance1    instance2
abc               running      shutdown
xyz               running      shutdown
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 15:29:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283325#M85619</guid>
      <dc:creator>bharathk5678</dc:creator>
      <dc:date>2017-02-09T15:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: extract value with matching multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283326#M85620</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search giving fields domain, server, status
| eval instance="instance".replace(server,"(.+)(\d)$","\2")
| chart values(status) over domain by instance
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 16:32:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283326#M85620</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-09T16:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: extract value with matching multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283327#M85621</link>
      <description>&lt;P&gt;got partial results.&lt;/P&gt;

&lt;P&gt;I am getting the output in like below format. but it's not showing two different columns with instance1 and instance2&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;domain    NULL&lt;BR /&gt;
abc         running&lt;BR /&gt;
xyz         running&lt;/EM&gt;             &lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 17:07:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283327#M85621</guid>
      <dc:creator>bharathk5678</dc:creator>
      <dc:date>2017-02-09T17:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: extract value with matching multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283328#M85622</link>
      <description>&lt;P&gt;This works fine based on your sample data (see this run anywhere sample). It seems the format of server is different causing the replace function to fail and return NULL. Could you provide some real sample values of the field server? Do they end with a number like in question?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval temp="abc,abc_s1,running abc,abc_s2,down xyz,xyz_s1,running xyz,xyz_s2,running" | table temp | makemv temp | mvexpand temp | rex field=temp "(?&amp;lt;domain&amp;gt;.+),(?&amp;lt;server&amp;gt;.+),(?&amp;lt;status&amp;gt;.+)" | fields - temp | eval instance="instance".replace(server,"(.+)(\d)$","\2") | chart values(status) over domain by instance
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 17:18:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283328#M85622</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-09T17:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: extract value with matching multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283329#M85623</link>
      <description>&lt;P&gt;also, is it "server" or "sever"?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 18:51:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283329#M85623</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-09T18:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: extract value with matching multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283330#M85624</link>
      <description>&lt;P&gt;This inserts your sample data &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults 
| eval mydata=mvappend("domain=abc, server=abc_s1,status=running",
"domain=abc, server=abc_s2,status=shutdown",
"domain=xyz, server=xyz_s1,status=running",
"domain=xyz, server=xyz_s2,status=shutdown")
| mvexpand mydata 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This turns it into the requested chart-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=mydata "domain=(?&amp;lt;mydomain&amp;gt;[^,]*),\s*server=(?&amp;lt;myserver&amp;gt;[^_]*_(?&amp;lt;myinstance&amp;gt;[^,]+)),\s*status=(?&amp;lt;mystatus&amp;gt;.*)"
| chart first(mystatus) as status over mydomain by myinstance
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With the results looking like this - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mydomain  s1        s2        
abc       running   shutdown  
xyz       running   shutdown  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've assumed that your server names are constructed by domain name, an underscore, and the instance name.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 19:18:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283330#M85624</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-09T19:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: extract value with matching multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283331#M85625</link>
      <description>&lt;P&gt;sry given wrong field name. now it's worked perfectly as expected.&lt;/P&gt;

&lt;P&gt;worked query:&lt;BR /&gt;
 &lt;EM&gt;your current search giving fields domain, server, status&lt;BR /&gt;
 | eval instance="instance".replace(server,"(.+)(\d)$","\2")&lt;BR /&gt;
 | chart values(status) over domain by instance&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 20:39:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-value-with-matching-multiple-fields/m-p/283331#M85625</guid>
      <dc:creator>bharathk5678</dc:creator>
      <dc:date>2017-02-09T20:39:09Z</dc:date>
    </item>
  </channel>
</rss>

