<?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 Wildcards on the left side of a comparison in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197595#M57093</link>
    <description>&lt;P&gt;Is there any way to use a wildcard on the left side of a comparison in a Splunk search?  We have a scripted input that returns physical drive status across many systems, and the results look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;hostname=some_hostname physDrv1=ok physDrv2=ok physDrv3=ok physDrv4=failed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there any way to search for events that have any non-OK lines like below?  This apparently doesn't work and I haven't found anything in the Splunk documentation.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=drive_status | where physDrv*!="ok"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For now, we just hardcode every possible drive property in the search like below and it works fine, but it would be cool to write a more elegant search if possible.  Let me know what you think.  Thanks for the help!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=drive_status | where physDrv1!="ok" OR physDrv2!="ok" OR physDrv3!="ok" OR physDrv4!="ok"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Jan 2014 15:49:18 GMT</pubDate>
    <dc:creator>jerdmann</dc:creator>
    <dc:date>2014-01-07T15:49:18Z</dc:date>
    <item>
      <title>Wildcards on the left side of a comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197595#M57093</link>
      <description>&lt;P&gt;Is there any way to use a wildcard on the left side of a comparison in a Splunk search?  We have a scripted input that returns physical drive status across many systems, and the results look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;hostname=some_hostname physDrv1=ok physDrv2=ok physDrv3=ok physDrv4=failed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there any way to search for events that have any non-OK lines like below?  This apparently doesn't work and I haven't found anything in the Splunk documentation.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=drive_status | where physDrv*!="ok"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For now, we just hardcode every possible drive property in the search like below and it works fine, but it would be cool to write a more elegant search if possible.  Let me know what you think.  Thanks for the help!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=drive_status | where physDrv1!="ok" OR physDrv2!="ok" OR physDrv3!="ok" OR physDrv4!="ok"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jan 2014 15:49:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197595#M57093</guid>
      <dc:creator>jerdmann</dc:creator>
      <dc:date>2014-01-07T15:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards on the left side of a comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197596#M57094</link>
      <description>&lt;P&gt;You could try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=drive_status NOT "ok" | your stats or table
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But you have to be careful how you use it because it will ignore "ok" regardless of the field.  In your example, it looks like ignoring "ok" will not be a problem.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2014 15:59:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197596#M57094</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2014-01-07T15:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards on the left side of a comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197597#M57095</link>
      <description>&lt;P&gt;Cool, thanks for the feedback.  I'm not sure if this will work though, as it looks like this filters out all events that have the text "ok" anywhere in them.  &lt;/P&gt;

&lt;P&gt;I gave it a shot and it filters out all results which obviously isn't what we want.  Thanks for the suggestion though!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2014 16:02:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197597#M57095</guid>
      <dc:creator>jerdmann</dc:creator>
      <dc:date>2014-01-07T16:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards on the left side of a comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197598#M57096</link>
      <description>&lt;P&gt;Try following&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blah sourcetype=blah NOT "physDrv*=ok" | &amp;lt;do more&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;H2&gt;UPDATED Search&lt;/H2&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blah sourcetype=blah | rex max_match=0 "(?m)physDrv[0-9]*=(?&amp;lt;drive_status&amp;gt;[^ ]+)" | nomv drive_status | eval drive_status=replace(drive_status,"ok","") | where drive_status!=""
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jan 2014 16:06:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197598#M57096</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-01-07T16:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards on the left side of a comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197599#M57097</link>
      <description>&lt;P&gt;Hmmm, no dice here either.  This filters out all events that an OK in any of the drives/properties, similar to the above suggestion.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2014 16:32:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197599#M57097</guid>
      <dc:creator>jerdmann</dc:creator>
      <dc:date>2014-01-07T16:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards on the left side of a comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197600#M57098</link>
      <description>&lt;P&gt;Please see if the updated answer works.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2014 16:58:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197600#M57098</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-01-07T16:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards on the left side of a comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197601#M57099</link>
      <description>&lt;P&gt;Perfect, works like a treat!  I had to modify the above slightly (see below), but this is otherwise exactly what I needed.  Thanks a ton!&lt;/P&gt;

&lt;P&gt;rex max_match=0 "(?m)physDrv[0-9]+=(?&lt;DRIVE_STATUS&gt;[\w]+)" | nomv drive_status | eval drive_status=replace(drive_status,"ok\s*","") | where drive_status!=""&lt;/DRIVE_STATUS&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:36:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Wildcards-on-the-left-side-of-a-comparison/m-p/197601#M57099</guid>
      <dc:creator>jerdmann</dc:creator>
      <dc:date>2020-09-28T15:36:07Z</dc:date>
    </item>
  </channel>
</rss>

