<?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 Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133549#M36463</link>
    <description>&lt;P&gt;I have csv data indexed in Splunk. The fields are unique, but have some patterns:&lt;/P&gt;

&lt;P&gt;As an example, the following first row are fields and values in the following rows. I'm making up the content here for illustration purposes.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1_name   field2_name   field3_name   field4_name ............fieldn_name                   
book          pen           paper         pencil
laptop        gold          pen           pencil
pen           paper         pencil        fan          
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to add a wildcard into the fields' names during a search as you notice there is a pattern in the field names.&lt;/P&gt;

&lt;P&gt;I want to search for "Give me all the events containing "pen" of all the fields"&lt;/P&gt;

&lt;P&gt;The search would be some thing like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=csv   index=myindex | search  field*_name="pen"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it appears splunk only allows to have wildcard for the field values and not the field names?  Is there a way to add a wildcard into the field names?? &lt;/P&gt;

&lt;P&gt;I don't want to use "_raw" event searching.  &lt;/P&gt;</description>
    <pubDate>Sat, 11 Apr 2015 20:24:07 GMT</pubDate>
    <dc:creator>splunknewbie05</dc:creator>
    <dc:date>2015-04-11T20:24:07Z</dc:date>
    <item>
      <title>Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133549#M36463</link>
      <description>&lt;P&gt;I have csv data indexed in Splunk. The fields are unique, but have some patterns:&lt;/P&gt;

&lt;P&gt;As an example, the following first row are fields and values in the following rows. I'm making up the content here for illustration purposes.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1_name   field2_name   field3_name   field4_name ............fieldn_name                   
book          pen           paper         pencil
laptop        gold          pen           pencil
pen           paper         pencil        fan          
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to add a wildcard into the fields' names during a search as you notice there is a pattern in the field names.&lt;/P&gt;

&lt;P&gt;I want to search for "Give me all the events containing "pen" of all the fields"&lt;/P&gt;

&lt;P&gt;The search would be some thing like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=csv   index=myindex | search  field*_name="pen"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it appears splunk only allows to have wildcard for the field values and not the field names?  Is there a way to add a wildcard into the field names?? &lt;/P&gt;

&lt;P&gt;I don't want to use "_raw" event searching.  &lt;/P&gt;</description>
      <pubDate>Sat, 11 Apr 2015 20:24:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133549#M36463</guid>
      <dc:creator>splunknewbie05</dc:creator>
      <dc:date>2015-04-11T20:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133550#M36464</link>
      <description>&lt;P&gt;Hi splunknewbie05 &lt;BR /&gt;
Use this search code &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="myindex"    sourcetype="csv"   "pen" | table *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 Apr 2015 21:06:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133550#M36464</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2015-04-11T21:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133551#M36465</link>
      <description>&lt;P&gt;Hello! &lt;BR /&gt;
Since you need &lt;STRONG&gt;events&lt;/STRONG&gt; , not a &lt;STRONG&gt;statistic table&lt;/STRONG&gt;, i 'm going to propose a &lt;STRONG&gt;regular expression&lt;/STRONG&gt; instead of the &lt;STRONG&gt;fieldsummary&lt;/STRONG&gt; command wich is very interesting..&lt;BR /&gt;
I don't know how are your events, but i think this will help : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=csv index=myindex |rex "\s(?P&amp;lt;fields_Name&amp;gt;[^=]+)=pen"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;How does it work?&lt;/STRONG&gt;&lt;BR /&gt;
The &lt;STRONG&gt;rex&lt;/STRONG&gt; command will match all  &lt;STRONG&gt;pen&lt;/STRONG&gt; values of field1_name  field2_name field3_name field4_name .... ..... .........................fieldn_name  and will create a new field called &lt;STRONG&gt;fields_Name&lt;/STRONG&gt; which values are only fields having &lt;STRONG&gt;pen&lt;/STRONG&gt; as a value.&lt;BR /&gt;
So you will have only events with pen as the value of , field1_name  field2_name field3_name field4_name .... ..... .........................fieldn_name&lt;/P&gt;

&lt;P&gt;If you have indexed the &lt;STRONG&gt;tutorialdata.zip&lt;/STRONG&gt;,Take this as a template and see how it works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="tutorialdata.zip:*"|rex "\s(?P&amp;lt;field_Name&amp;gt;[^=]+)=7026"|stats count by field_Name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:30:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133551#M36465</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2020-09-28T19:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133552#M36466</link>
      <description>&lt;P&gt;I didn't get the answer I'm looking for.  The above answers still has wild card on the content. I'm looking for wild card on field names&lt;/P&gt;

&lt;P&gt;You can organize data in couple of following ways. &lt;/P&gt;

&lt;P&gt;Lets say I have State and percentage fields&lt;/P&gt;

&lt;P&gt;Table1:&lt;/P&gt;

&lt;P&gt;State   percentage&lt;BR /&gt;
A1        10&lt;BR /&gt;
B1        20&lt;BR /&gt;
A3        10&lt;BR /&gt;
A4        5&lt;BR /&gt;
C1        6&lt;/P&gt;

&lt;P&gt;Lets say I want to compute total of all A states percentage. &lt;BR /&gt;
You can  do a wild card on the content some thing like  "A*" and extract the percentages and compute total&lt;/P&gt;

&lt;P&gt;Lets organize the same table in other way&lt;BR /&gt;
State_A1_Percentage        State_B1_Percentage     State_ A3_Percentage    State_A4_Percentage       State_C1_Percentage&lt;BR /&gt;
      10                                                     20                              10                                     5                                          6&lt;/P&gt;

&lt;P&gt;Now if I want to compute all A states percentage, I can extract State_A1_Percentage,  State_ A3_Percentage, State_A4_Percentage and compute total.  &lt;/P&gt;

&lt;P&gt;What I'm asking is if there is a way to extract values using wild card  on field "State_A*_Percentage"&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:35:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133552#M36466</guid>
      <dc:creator>splunknewbie05</dc:creator>
      <dc:date>2020-09-28T19:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133553#M36467</link>
      <description>&lt;P&gt;If a regex is not a solution for you, then I dont know if what you're looking for exists.&lt;/P&gt;

&lt;P&gt;I'm not sure this is exactly the answer either, but you may want to have a look at the possibility to transform your data into key-value pairs. If idieally your lines after the first line contain a timestamp, you can let splunk read the data as&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(Event1)
[timestamp] field1_name = book field2_name = pen ...
(Event2)
[timestamp] field1_name = laptop field2_name = gold ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With this data, you could easily identify all your field names (and work with them, as I don't think just identifying them is what you are looking to do in the end).&lt;BR /&gt;
If this looks helpful, have a look at what &lt;CODE&gt;REPORT&lt;/CODE&gt; in props.conf (and the associated part in transforms.conf) does. Right now I can't pin down where in the docs you find that unfortunately, but if what I described above is moving in the right direction for you, I'll look it up further.&lt;BR /&gt;
Update: here are the docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.2/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 05:42:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133553#M36467</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-04-15T05:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133554#M36468</link>
      <description>&lt;P&gt;Try &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/Foreach"&gt;foreach&lt;/A&gt; if you are looking at fields (columns)&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 06:23:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133554#M36468</guid>
      <dc:creator>ramdaspr</dc:creator>
      <dc:date>2015-04-15T06:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133555#M36469</link>
      <description>&lt;P&gt;first call all your fields by same  field name to do this use rename command.&lt;BR /&gt;
after you can filter .&lt;/P&gt;

&lt;P&gt;try like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=csv index=myindex|rename field*_name as pen|where  pen="pen"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Apr 2015 07:41:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133555#M36469</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2015-04-15T07:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133556#M36470</link>
      <description>&lt;P&gt;Here is my new solution also with regular expressions. Since you are using a &lt;STRONG&gt;csv file&lt;/STRONG&gt; with headers, here is what you can do with i think.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=csv index=myindex |rex "(?&amp;lt;fields_Name&amp;gt;pen)"|stats count by fields_Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now let suppose that you have a csv like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;state percentage
A1        10
B1        20
A3        10
A2        4
C1        1
B2        12
C2        15
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the search to write&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    source="wildcard.csv"|rex "(?&amp;lt;fields_Name&amp;gt;[^\d])"|stats sum(percentage) by fields_Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Wich is giving the table bellow:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;       count
A        24
B        32
C        15
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 09:13:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133556#M36470</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-04-15T09:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133557#M36471</link>
      <description>&lt;P&gt;hi,&lt;BR /&gt;
For your question "Give me all the events containing "pen" of all the fields"&lt;BR /&gt;
try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; .....|foreach field* [eval newfield=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;]| where like(newfield, "pen%")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Apr 2015 12:04:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133557#M36471</guid>
      <dc:creator>btt</dc:creator>
      <dc:date>2015-04-15T12:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use a wildcard in field names when running a search? (ex: field*_name=X for field1_name, field2_name, etc)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133558#M36472</link>
      <description>&lt;P&gt;I've seen at least two other questions for this when one portion of the field name will be unknown, but I've never found an answer. You haven't found one by chance have you?&lt;/P&gt;

&lt;P&gt;My current question is at: &lt;A href="https://answers.splunk.com/answers/340010/how-to-search-over-a-field-when-its-json-and-has-m-1.html?minQuestionBodyLength=80"&gt;https://answers.splunk.com/answers/340010/how-to-search-over-a-field-when-its-json-and-has-m-1.html?minQuestionBodyLength=80&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2016 22:51:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-a-wildcard-in-field-names-when-running-a/m-p/133558#M36472</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2016-01-07T22:51:16Z</dc:date>
    </item>
  </channel>
</rss>

