<?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 Wildcard support in tag definitions? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Wildcard-support-in-tag-definitions/m-p/14247#M1422</link>
    <description>&lt;P&gt;Is there a way to set tags based off a wild card value?&lt;/P&gt;

&lt;P&gt;IE I have the following hosts and I want to apply the 'test' tag to all of them&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;foo1 foo2 foo3 foo4&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Right now I think I have to apply a tag to each host individually&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;host=foo1  host=foo2 host=foo3 host=foo4&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But what I'd really like is to do something like:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;host=foo*&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Is this possible, or is there another way that I can do this (such as with a saved search?)
As we provision new hosts, sometimes tagging gets missed, which then causes omissions on searches that use these tags.  Just trying to find a good work around.&lt;/P&gt;</description>
    <pubDate>Wed, 26 May 2010 03:36:11 GMT</pubDate>
    <dc:creator>Yancy</dc:creator>
    <dc:date>2010-05-26T03:36:11Z</dc:date>
    <item>
      <title>Wildcard support in tag definitions?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Wildcard-support-in-tag-definitions/m-p/14247#M1422</link>
      <description>&lt;P&gt;Is there a way to set tags based off a wild card value?&lt;/P&gt;

&lt;P&gt;IE I have the following hosts and I want to apply the 'test' tag to all of them&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;foo1 foo2 foo3 foo4&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Right now I think I have to apply a tag to each host individually&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;host=foo1  host=foo2 host=foo3 host=foo4&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But what I'd really like is to do something like:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;host=foo*&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Is this possible, or is there another way that I can do this (such as with a saved search?)
As we provision new hosts, sometimes tagging gets missed, which then causes omissions on searches that use these tags.  Just trying to find a good work around.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2010 03:36:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Wildcard-support-in-tag-definitions/m-p/14247#M1422</guid>
      <dc:creator>Yancy</dc:creator>
      <dc:date>2010-05-26T03:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard support in tag definitions?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Wildcard-support-in-tag-definitions/m-p/14248#M1423</link>
      <description>&lt;P&gt;&lt;B&gt;Update:&lt;/B&gt;  As of Splunk 6, this IS supported. (Possibly it worked in 5.0, I'm not sure.)&lt;/P&gt;

&lt;P&gt;No.  Tags cannot use wildcards.&lt;/P&gt;

&lt;P&gt;There used to be a &lt;CODE&gt;tagcreate&lt;/CODE&gt; search command.  But it was removed in Splunk 4.0.  That could have been used, but for whatever reason it has been removed.   (I'm not sure what the official replacement is, but I do know thats it's often better to build a lookup table than to use automatically generated tags, because lookups scale better, so perhaps thats part of the reason.   But it does seem that using tags is the right approach here, so that really doesn't help you.)&lt;/P&gt;

&lt;H3&gt;A different approach&lt;/H3&gt;

&lt;P&gt;Here is one possible approach to finding hosts that have not been tagged yet:  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| metadata type=hosts index=main | tags | search NOT tag::host=*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can use the metadata information from one of your indexes to very quickly get a list of active hosts (any host that has events in your index).  Then the &lt;CODE&gt;tags&lt;/CODE&gt; command is used to get the tags associated with each hosts (thus creating the &lt;CODE&gt;tag::host&lt;/CODE&gt; field).&lt;/P&gt;

&lt;P&gt;You could schedule a search like this to run every day and email you about any new (untagged) hosts. And, of course, you have all the normal splunk post-search power at your disposal here.&lt;BR /&gt;
You could also take an approach where you are looking for certain hosts names and checking for certain tags (like in your example):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| metadata type=hosts | tags | search host=foo* NOT host::tag=test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Of course, you will still have to deal with missing tags manually.  But, at least you'll know which hosts are missing tags.&lt;/P&gt;

&lt;H3&gt;A more complex example&lt;/H3&gt;

&lt;P&gt;The more I'm thinking about this, the more helpful I'm thinking this would be for me to setup as well.   I'm setting up a weekly search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| metadata type=hosts | tags | search NOT tag::host=* totalCount&amp;gt;100 | regex host!="^\d+.\d+\.\d+\.\d+$" | where lastTime&amp;gt;relative_time(now(),"-1mon")`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm using a &lt;CODE&gt;where&lt;/CODE&gt; command to filter out hosts with no event within the past month (decommissioned hosts) or hosts that have less that 100 events (which I also don't care about).  We also have a number of hosts that are just IP addresses (small network devices with minimal activity), so they normally don't get tagged and therefore are being filtered out.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2010 20:51:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Wildcard-support-in-tag-definitions/m-p/14248#M1423</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-05-26T20:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard support in tag definitions?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Wildcard-support-in-tag-definitions/m-p/14249#M1424</link>
      <description>&lt;P&gt;Thanks Lowell!  I remember someone referencing the tagcreate command before.  I'm going to run a scheduled search as well.&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2010 08:28:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Wildcard-support-in-tag-definitions/m-p/14249#M1424</guid>
      <dc:creator>Yancy</dc:creator>
      <dc:date>2010-05-27T08:28:25Z</dc:date>
    </item>
  </channel>
</rss>

