<?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: Splunk search with wildcard in field name in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687837#M234592</link>
    <description>&lt;P&gt;You can't "add case-insensitivity". Field names are case-sensitive in Splunk by design (so Dev and DEV are two different fields and you can have both of them in your event).&lt;/P&gt;&lt;P&gt;You can try some ugly hacks to "normalize" field case like&lt;/P&gt;&lt;PRE&gt;| foreach * &lt;BR /&gt;   [ | eval field=lower("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;") &lt;BR /&gt;     | eval {field}=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; &lt;BR /&gt;     | eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=null() &lt;BR /&gt;     | eval field=null() ]&lt;/PRE&gt;&lt;P&gt;But this is really, really ugly. And if you have two similar but differently-cased field names, only one of them will be retained, other one(s) will be overwritten.&lt;/P&gt;&lt;P&gt;Of course you can "limit" this to just some pattern by doing conditional evals (but it gets even uglier than this because you have to add an &lt;EM&gt;if&lt;/EM&gt; matching the field name to most of those evals so it's getting really spaghetti).&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2024 08:15:43 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2024-05-17T08:15:43Z</dc:date>
    <item>
      <title>Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687529#M234486</link>
      <description>&lt;P&gt;I need to see all events with fields that have "PROD*" in name, e.g. "PROD deploy", "PROD update", etc.&lt;BR /&gt;`index=myIndex sourcetype=mySourceType "PROD*"="*"` doesn't work&lt;BR /&gt;..and if event has "PROD*" in field name I need to get the value&lt;BR /&gt;How is it possible?&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 18:30:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687529#M234486</guid>
      <dc:creator>kagarlickij</dc:creator>
      <dc:date>2024-05-14T18:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687547#M234495</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach PROD*
  [| eval keep=if(isnull(keep) AND isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), 1, keep)]
| where keep==1&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 May 2024 22:47:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687547#M234495</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-14T22:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687552#M234497</link>
      <description>&lt;P&gt;Also, if you have lots of events that do NOT have fields called PROD anything and your event data must have PROD as a term in the data, then you can help filter only those events that have PROD in the data with TERM(PROD)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myIndex sourcetype=mySourceType TERM(PROD)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 23:50:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687552#M234497</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-05-14T23:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687559#M234501</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;gave some good ideas for obtaining streams of events. &amp;nbsp;I want to note that "&lt;SPAN&gt; if event has "PROD*" in field name I need to get the value" can have different meanings depending on what you want to do with the keys and values. &amp;nbsp;If all you want is to list all values of each key, it can be as simple as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myIndex sourcetype=mySourceType
| stats values(Prod*) as Prod*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 04:35:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687559#M234501</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-05-15T04:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687567#M234505</link>
      <description>&lt;P&gt;A bit of additional explanation on this (all other comments in this thread so far are valid).&lt;/P&gt;&lt;P&gt;1. If you search by field value, you have to explicitly name the field. There is no wildcard functionality as such. There simply isn't. So &lt;EM&gt;field=*whatever*wildcarded*value*you*can*think*of&lt;/EM&gt;&amp;nbsp; is a formally valid search condition (even though it might not be the best one from performance point of view), your idea of &lt;EM&gt;PROD*=*&lt;/EM&gt; would (if asterisk was allowed in field name; I'm pretty sure it isn't) search for a field called literally &lt;EM&gt;PROD*&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;2. Even if there was a way to do so, this type of search (as well as any search for non-indexed field value beginning with a with an asterisk) is the worst possible idea performance-wise. Since Splunk cannot limit the set of processed events to some values, it has to parse all events from a given search time range (possibly limited by other search conditions) to find out if there is such field present in your events at all. It might be very, very costly in terms of CPU time.&lt;/P&gt;&lt;P&gt;If your field(s) can be "anchored" to some static, delimited at least at the beginning with a breaker, text within the event, you can help Splunk by limiting your events by adding a proper search term in the initial search.&lt;/P&gt;&lt;P&gt;That's why it's best to combine&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt; 's solution with &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; 's way of limiting the events you're searching from.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 06:49:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687567#M234505</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-05-15T06:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687586#M234512</link>
      <description>&lt;P&gt;What I need to do is: Select all events that have `PROD*` in field name &lt;STRONG&gt;and&lt;/STRONG&gt; calculate number of events that have `SUCCESS` value in `RESULT` field&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 08:40:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687586#M234512</guid>
      <dc:creator>kagarlickij</dc:creator>
      <dc:date>2024-05-15T08:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687615#M234517</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&amp;nbsp;Many thanks, it shows all events with `PROD*` filed names&lt;/P&gt;&lt;P&gt;How can I get all events without&amp;nbsp;`PROD*` filed names please?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 12:44:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687615#M234517</guid>
      <dc:creator>kagarlickij</dc:creator>
      <dc:date>2024-05-15T12:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687616#M234518</link>
      <description>&lt;LI-CODE lang="markup"&gt;| fields - PROD*&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 15 May 2024 12:45:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687616#M234518</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-15T12:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687626#M234520</link>
      <description>&lt;P&gt;&lt;SPAN&gt;`&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=myIndex sourcetype=mySourceType | fields - PROD*&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;` still displays events with and without `PROD*` fields.. Am I doing smtg wrong?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 16:33:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687626#M234520</guid>
      <dc:creator>kagarlickij</dc:creator>
      <dc:date>2024-05-15T16:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687647#M234524</link>
      <description>&lt;P&gt;It is not clear what your use case is - how can you have events which don't have fields called PROD* and also don't have fields not called PROD* - please clarify what you are trying to do&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 17:26:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687647#M234524</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-15T17:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687685#M234542</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;sure, sorry if it wasn't clear&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some events that have `PROD*` in field names (e.g. `PROD error`, `Production warning`, etc.)&lt;/P&gt;&lt;P&gt;Other events don't have `PROD*` in field names, e.g. they have `DEV error`, `Development warning`, etc.&lt;/P&gt;&lt;P&gt;The end goal is to build dashboard that will compare statistics across different envs, that's why I need data from other fields like `ERROR_CODE`&lt;/P&gt;&lt;P&gt;Hope it makes sense and thanks a lot for your help and patience, it's much appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 06:41:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687685#M234542</guid>
      <dc:creator>kagarlickij</dc:creator>
      <dc:date>2024-05-16T06:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687687#M234544</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;I have some events that have `PROD*` in field names (e.g. `PROD error`, `Production warning`, etc.)&lt;P&gt;Other events don't have `PROD*` in field names, e.g. they have `DEV error`, `Development warning`, etc.&lt;/P&gt;&lt;P&gt;The end goal is to build dashboard that will compare statistics across different envs, that's why I need data from other fields like `ERROR_CODE`&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It really does not make sense because the above kind of contradicts what is asked in the OP.&lt;/P&gt;&lt;P&gt;A good way - in fact the very basic way to ask an answerable question is to illustrate your data with a table (you can give a few fields of relevance and value variants of importance), then illustrate desired output from the data with a table, then explain the logic to arrive at desired output from illustrated data as if you have no Splunk.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 06:59:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687687#M234544</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-05-16T06:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687690#M234546</link>
      <description>&lt;P&gt;Your wording might be a bit confusing. You apparently wanted to search for all events that do not have any fields matching the PROD* pattern in them whereas &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt; showed you how to show all events without showing the PROD* fields.&lt;/P&gt;&lt;P&gt;You can do the opposite to previous &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt; 's solution&lt;/P&gt;&lt;PRE&gt;&amp;lt;your initial search&amp;gt;&lt;BR /&gt;| eval keep=1&lt;BR /&gt;| foreach PROD* &lt;BR /&gt;&amp;nbsp; [ | eval keep=0 ]&lt;BR /&gt;| where keep=1&lt;BR /&gt;| fields - keep&lt;/PRE&gt;&lt;P&gt;This will filter out any event containing PROD* fields. But this is a very ineffective way of searching your data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 07:08:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687690#M234546</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-05-16T07:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687734#M234554</link>
      <description>&lt;P&gt;Sorry for the confusion - I'm new to this dataset and some topics became clear only after init search&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyways I'm running&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index="myIndex" sourcetype ="mySourceType" |  foreach "*PROD*" [| eval keep=if(isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), 1, keep)] | where keep==1&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;to get events with `*PROD*` in field names&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;..and&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index="myIndex" sourcetype ="mySourceType" |  foreach "*DEV*" [| eval keep=if(isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), 1, keep)] | where keep==1&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;to get events with `*DEV*`&amp;nbsp;in field names&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;..so no need to find events without&amp;nbsp;&lt;SPAN&gt;`*PROD*` in filed name&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. how can I make foreach condition case-insensitive, so events with both `Production` and `PRODUCTION`&amp;nbsp; fields found?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. how can I make foreach to search with OR condition, e.g. `foreach "*DEV*" OR "*UAT*"` ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Many thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 14:09:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687734#M234554</guid>
      <dc:creator>kagarlickij</dc:creator>
      <dc:date>2024-05-16T14:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687740#M234560</link>
      <description>&lt;P&gt;Honestly, you're digging deeper and deeper into something that seems that should be much better solved just by preparing the data correctly.&lt;/P&gt;&lt;P&gt;You either should make your developers log the same fields consistently and distinguish the source of the events by... source field? Or maybe some additional field if all events are aggregated into a single point of origin.&lt;/P&gt;&lt;P&gt;Alternatively as they apparently have different structure, they should have different sourcetypes so that each is parsed differently (and all can be normalized to a common set of fields).&lt;/P&gt;&lt;P&gt;IMHO you're unnecessarily trying to make the life harder than it has to be for yourself.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 13:11:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687740#M234560</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-05-16T13:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687756#M234563</link>
      <description>&lt;P&gt;unfortunately dataset is old and can't be changed&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd be happy if fields have decent naming pattern..&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 15:16:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687756#M234563</guid>
      <dc:creator>kagarlickij</dc:creator>
      <dc:date>2024-05-16T15:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687827#M234589</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;&lt;SPAN&gt;1. how can I make foreach condition case-insensitive, so events with both `Production` and `PRODUCTION`&amp;nbsp; fields found?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. how can I make foreach to search with OR condition, e.g. `foreach "*DEV*" OR "*UAT*"` ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Back to my previous comment. &amp;nbsp;My exact words are "&lt;SPAN&gt;depending on what you want to do with the keys and values." &amp;nbsp;If you don't tell us what your end goal is, it is not really an answerable question. &amp;nbsp;Like I exemplified, you can do a lot without having to resort to cumbersome foreach subsearches if you have some simple goals. &amp;nbsp;For example,&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats values(PROD*) as PROD* values(Prod*) as Prod*&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;| timechart dc(PROD*) as PROD* dc(Prod*) as Prod* by somekey&lt;/LI-CODE&gt;&lt;P&gt;and so on. &amp;nbsp;Like&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;points out, you could be giving yourself a harder time than it should have been.&lt;/P&gt;&lt;P&gt;Because Splunk is optimized for time series, there are more row-oriented, or value-oriented manipulations than column names or keys. &amp;nbsp;Instead of doing foreach for simple filter function - which is quite wasteful and offers no performance improvement like a simple filter in index search. &amp;nbsp;If there are only a handful variants of these field names, it is perhaps more profitable to simply enumerate them in command line.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myindex sourcetype=mysourcetype
  ("PROD deploy"=* OR "PROD update"=* OR "PROD error"=* OR "Production warning"=*)&lt;/LI-CODE&gt;&lt;P&gt;This is important for performance because it reduces the number of events.&lt;/P&gt;&lt;P&gt;Additionally, is this separation between Prod and Dev going somewhere or are they really just used in two different outputs?&lt;/P&gt;&lt;P&gt;The answer to the question about OR in foreach is you don't need any. &amp;nbsp;Simply do, for example,&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;foreach DEV* Dev* UAT*&lt;/FONT&gt;. &amp;nbsp;Again, is there a need to put wildcard in front of Prod and Dev?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 06:50:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687827#M234589</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-05-17T06:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687834#M234591</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;1. My task is to calculate number of events with "&lt;SPAN&gt;FAILED&lt;/SPAN&gt;" value in "RESULT" key, it looks like this and it works (thanks to you guys!) - `&lt;SPAN&gt;index&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"myIndex"&lt;/SPAN&gt; &lt;SPAN&gt;sourcetype&lt;/SPAN&gt; &lt;SPAN&gt;="mySourceType"&lt;/SPAN&gt; &lt;SPAN&gt;|&lt;/SPAN&gt;&lt;SPAN&gt; foreach &lt;/SPAN&gt;&lt;SPAN&gt;"*DEV*"&lt;/SPAN&gt; &lt;SPAN&gt;"UAT*"&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;SPAN&gt;|&lt;/SPAN&gt;&lt;SPAN&gt; eval keep&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;if(&lt;/SPAN&gt;&lt;SPAN&gt;isnotnull&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'&lt;/SPAN&gt;&lt;SPAN&gt;), 1, keep)] &lt;/SPAN&gt;&lt;SPAN&gt;|&lt;/SPAN&gt; &lt;SPAN&gt;where&lt;/SPAN&gt; &lt;SPAN&gt;keep==&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt; &lt;SPAN&gt;|&lt;/SPAN&gt; &lt;SPAN&gt;stats&lt;/SPAN&gt; &lt;SPAN&gt;count&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;eval&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'RESULT'&lt;/SPAN&gt;&lt;SPAN&gt;==&lt;/SPAN&gt;&lt;SPAN&gt;"FAILED"&lt;/SPAN&gt;&lt;SPAN&gt;)) as FAILS &lt;/SPAN&gt;&lt;SPAN&gt;|&lt;/SPAN&gt; &lt;SPAN&gt;stats&lt;/SPAN&gt; &lt;SPAN&gt;values&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;FAILS&lt;/SPAN&gt;&lt;SPAN&gt;)`&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It would be superb to add case-insensitivity, so both `DEV` and `Develop` are included to the result&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Many thanks, `&lt;SPAN&gt;foreach &lt;/SPAN&gt;&lt;SPAN&gt;"*DEV*"&lt;/SPAN&gt; &lt;SPAN&gt;"UAT*"&lt;/SPAN&gt;` works as a charm!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 07:53:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687834#M234591</guid>
      <dc:creator>kagarlickij</dc:creator>
      <dc:date>2024-05-17T07:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687837#M234592</link>
      <description>&lt;P&gt;You can't "add case-insensitivity". Field names are case-sensitive in Splunk by design (so Dev and DEV are two different fields and you can have both of them in your event).&lt;/P&gt;&lt;P&gt;You can try some ugly hacks to "normalize" field case like&lt;/P&gt;&lt;PRE&gt;| foreach * &lt;BR /&gt;   [ | eval field=lower("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;") &lt;BR /&gt;     | eval {field}=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; &lt;BR /&gt;     | eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=null() &lt;BR /&gt;     | eval field=null() ]&lt;/PRE&gt;&lt;P&gt;But this is really, really ugly. And if you have two similar but differently-cased field names, only one of them will be retained, other one(s) will be overwritten.&lt;/P&gt;&lt;P&gt;Of course you can "limit" this to just some pattern by doing conditional evals (but it gets even uglier than this because you have to add an &lt;EM&gt;if&lt;/EM&gt; matching the field name to most of those evals so it's getting really spaghetti).&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 08:15:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687837#M234592</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-05-17T08:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with wildcard in field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687957#M234611</link>
      <description>&lt;BLOCKQUOTE&gt;&amp;nbsp;1. My task is to calculate number of events with "&lt;SPAN&gt;FAILED&lt;/SPAN&gt;" value in "RESULT" key, it looks like this and it works (thanks to you guys!) - `&lt;SPAN&gt;index&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"myIndex"&lt;/SPAN&gt; &lt;SPAN&gt;sourcetype&lt;/SPAN&gt; &lt;SPAN&gt;="mySourceType"&lt;/SPAN&gt; &lt;SPAN&gt;|&lt;/SPAN&gt;&lt;SPAN&gt; foreach &lt;/SPAN&gt;&lt;SPAN&gt;"*DEV*"&lt;/SPAN&gt; &lt;SPAN&gt;"UAT*"&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;SPAN&gt;|&lt;/SPAN&gt;&lt;SPAN&gt; eval keep&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;if(&lt;/SPAN&gt;&lt;SPAN&gt;isnotnull&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'&lt;/SPAN&gt;&lt;SPAN&gt;), 1, keep)] &lt;/SPAN&gt;&lt;SPAN&gt;|&lt;/SPAN&gt; &lt;SPAN&gt;where&lt;/SPAN&gt; &lt;SPAN&gt;keep==&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt; &lt;SPAN&gt;|&lt;/SPAN&gt; &lt;SPAN&gt;stats&lt;/SPAN&gt; &lt;SPAN&gt;count&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;eval&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'RESULT'&lt;/SPAN&gt;&lt;SPAN&gt;==&lt;/SPAN&gt;&lt;SPAN&gt;"FAILED"&lt;/SPAN&gt;&lt;SPAN&gt;)) as FAILS &lt;/SPAN&gt;&lt;SPAN&gt;|&lt;/SPAN&gt; &lt;SPAN&gt;stats&lt;/SPAN&gt; &lt;SPAN&gt;values&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;FAILS&lt;/SPAN&gt;&lt;SPAN&gt;)`&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This gets even more confusing.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;'number of events with "&lt;SPAN&gt;FAILED&lt;/SPAN&gt;" value in "RESULT" key' implies that you already have a field (key) named "RESULT" that may have a value of "FAILED". &amp;nbsp;If this is correct, shouldn't your search begins with&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;SPAN&gt;index&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"myIndex"&lt;/SPAN&gt; &lt;SPAN&gt;sourcetype&lt;/SPAN&gt; &lt;SPAN&gt;="mySourceType"&lt;/SPAN&gt;&amp;nbsp;RESULT=FAILED&lt;/FONT&gt;?&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;|&lt;/SPAN&gt; &lt;SPAN&gt;stats&lt;/SPAN&gt; &lt;SPAN&gt;count&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;eval&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'RESULT'&lt;/SPAN&gt;&lt;SPAN&gt;==&lt;/SPAN&gt;&lt;SPAN&gt;"FAILED"&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;)) as FAILS&lt;/FONT&gt; gives one single numeric value. &amp;nbsp;What is the purpose of cascading&amp;nbsp;&lt;FONT face="courier new,courier"&gt;|statsvalues(FAILS)&lt;/FONT&gt; after this? &lt;FONT face="courier new,courier"&gt;| stats count(eval('RESULT'=="FAILED")) as FAILS | stats values(FAILS)&lt;/FONT&gt;&lt;/SPAN&gt; gives the exact same single value.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Most importantly still, as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;and I repeatedly point out, Splunk (and most programming languages) do not perform sophisticated calculations in name space, mostly because there is rarely need to do so. &amp;nbsp;When there is a serious need for manipulating variable name space, it is usually because the upstream programmer made poor design. &amp;nbsp;In Splunk's case, it is super flexible in handling data without preconceived field names. &amp;nbsp;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;suggested, if you can demonstrate your raw data containing those special keys, it is probably much easier (and more performant) to simply use TERM() filter to limit raw events rather than trying to apply semantics in extracted field names. (TERM is case insensitive by default.) &amp;nbsp;If you find TERM() too limiting, you can also use Splunk's super flexible field extraction to extract environment groups "Prod" and "Dev" using regex. &amp;nbsp;This way, all you need to do is&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="myIndex" sourcetype ="mySourceType" RESULT=FAILED environment=Dev
| stats count&lt;/LI-CODE&gt;&lt;P&gt;You can even do something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="myIndex" sourcetype ="mySourceType" RESULT=FAILED
| stats count by environment&lt;/LI-CODE&gt;&lt;P&gt;Any of these alternatives is better in clarity and efficiency.&lt;/P&gt;</description>
      <pubDate>Sun, 19 May 2024 07:25:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-wildcard-in-field-name/m-p/687957#M234611</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-05-19T07:25:30Z</dc:date>
    </item>
  </channel>
</rss>

