<?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: How to attain a list with all the fields in which a certain string appears? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390259#M113673</link>
    <description>&lt;P&gt;depends on if those fields are present in a single event or in multiple events.&lt;BR /&gt;
Please put the actual event details&lt;/P&gt;</description>
    <pubDate>Thu, 23 May 2019 19:06:06 GMT</pubDate>
    <dc:creator>koshyk</dc:creator>
    <dc:date>2019-05-23T19:06:06Z</dc:date>
    <item>
      <title>How to attain a list with all the fields in which a certain string appears?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390258#M113672</link>
      <description>&lt;P&gt;For example, given the fields and values:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1=A123
field2=baba
field3=A123B
field4=bA123
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want a list with the fields which contain the string "A123":&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1
field3
field4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 May 2019 18:30:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390258#M113672</guid>
      <dc:creator>msolgonza</dc:creator>
      <dc:date>2019-05-23T18:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to attain a list with all the fields in which a certain string appears?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390259#M113673</link>
      <description>&lt;P&gt;depends on if those fields are present in a single event or in multiple events.&lt;BR /&gt;
Please put the actual event details&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 19:06:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390259#M113673</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2019-05-23T19:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to attain a list with all the fields in which a certain string appears?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390260#M113674</link>
      <description>&lt;P&gt;The fields can be present in multiple events. Eg of events in a csv lookup format, if I wanted to match "A":&lt;/P&gt;

&lt;P&gt;field1, field2, field3, field4&lt;BR /&gt;
A, 0, 0, 0&lt;BR /&gt;
0, A, 0, 0&lt;BR /&gt;
0, 0, A, 0&lt;BR /&gt;
A, A, 0, 0&lt;BR /&gt;
0, A, A, 0&lt;BR /&gt;
A, 0, A, 0&lt;BR /&gt;
A, A, A, 0 &lt;/P&gt;

&lt;P&gt;Basically, it can be given in any order&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 19:13:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390260#M113674</guid>
      <dc:creator>msolgonza</dc:creator>
      <dc:date>2019-05-23T19:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to attain a list with all the fields in which a certain string appears?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390261#M113675</link>
      <description>&lt;P&gt;ah.ok. So the data above is in csv format? Is the columns limited like field1, 2 , 3 ,4 or is it random?&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 19:22:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390261#M113675</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2019-05-23T19:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to attain a list with all the fields in which a certain string appears?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390262#M113676</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults count=4 | streamstats count | eval field1=if(count&amp;lt;3,"A",0) | eval field2=if(count&amp;gt;3,"A",0) | eval field3=if(count==3,"A",0) | eval field4=0
| eval field_list=""
| foreach * [eval  field_list=if(match(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"A"),field_list+" "+"&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;",field_list)]
| makemv delim=" " field_list
| mvexpand field_list
| dedup field_list
| fields field_list
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Make results just makes some data to work with. Then we make an empty field list, that we will append field names to if they match your string. So &lt;CODE&gt;match(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"A")&lt;/CODE&gt; will evaluate as true when the CONTENT of the field matches "A". Then &lt;CODE&gt;field_list+" "+"&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;&lt;/CODE&gt; will append the NAME of the field to field_list. Otherwise the if statement just returns the previous field_list. &lt;/P&gt;

&lt;P&gt;After that line it's just some data manipulation. &lt;CODE&gt;| makemv delim=" " field_list&lt;/CODE&gt; will turn all your space delimited field_list variables into multivalues, &lt;CODE&gt;mvexpand&lt;/CODE&gt; expands them all to their own event, then &lt;CODE&gt;dedup&lt;/CODE&gt; gets rid of the duplicates. &lt;/P&gt;

&lt;P&gt;Hope that helps!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:39:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-attain-a-list-with-all-the-fields-in-which-a-certain/m-p/390262#M113676</guid>
      <dc:creator>aguthrie1190</dc:creator>
      <dc:date>2020-09-30T00:39:50Z</dc:date>
    </item>
  </channel>
</rss>

