<?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: Reformat a field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82663#M20985</link>
    <description>&lt;P&gt;&lt;YOUR base="" search=""&gt; | eval testMac = replace($X$,":",".{0,1}") | &lt;BR /&gt;
where match(macAddr,testMac)&lt;/YOUR&gt;&lt;/P&gt;

&lt;P&gt;should work then&lt;/P&gt;</description>
    <pubDate>Fri, 02 Mar 2012 23:09:41 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2012-03-02T23:09:41Z</dc:date>
    <item>
      <title>Reformat a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82660#M20982</link>
      <description>&lt;P&gt;My logs contain mac addresses.  Sometimes they have colons and sometimes dots.&lt;BR /&gt;
I want to build a view where the user inputs a mac and is able to search for both formats.&lt;/P&gt;

&lt;P&gt;I looked at rewriting the mac with out colons in props.conf/transforms.conf, but could not figure out a method.&lt;/P&gt;

&lt;P&gt;It looks like I am going to have to do it in the view, create a new field a mac with colons, and search for both.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2012 20:57:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82660#M20982</guid>
      <dc:creator>fk319</dc:creator>
      <dc:date>2012-03-01T20:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reformat a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82661#M20983</link>
      <description>&lt;P&gt;Try using something like the following, assuming that the user input in is $X$ and that the MAC address in the event has been extracted into a field named macAddr:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your base search&amp;gt; | eval testMac = replace($X$,":",".") | where match(macAddr,testMac)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The eval command takes the user input, which is assumed to be in the form 00:B0:D0:86:BB:F7, and replaces the colons with dot (.)&lt;BR /&gt;&lt;BR /&gt;
The dot is the "match anything" character in regular expressions, so now the testMac field looks like 00.B0.D0.86.BB.F7 - as a regular expression, this will match &lt;EM&gt;anything&lt;/EM&gt; as a separator.&lt;BR /&gt;&lt;BR /&gt;
The where command uses the match function to see if the macAddr field in the event matches the pattern. If yes, the event  is returned, otherwise it is excluded from the search results.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2012 21:42:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82661#M20983</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-03-01T21:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reformat a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82662#M20984</link>
      <description>&lt;P&gt;the problem is in the mac is both ways in the logs, so my search is:&lt;BR /&gt;
mac="00:B0:D0:86:BB:F7" OR mac="00B0D086BBF7"&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2012 22:09:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82662#M20984</guid>
      <dc:creator>fk319</dc:creator>
      <dc:date>2012-03-01T22:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reformat a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82663#M20985</link>
      <description>&lt;P&gt;&lt;YOUR base="" search=""&gt; | eval testMac = replace($X$,":",".{0,1}") | &lt;BR /&gt;
where match(macAddr,testMac)&lt;/YOUR&gt;&lt;/P&gt;

&lt;P&gt;should work then&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2012 23:09:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82663#M20985</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-03-02T23:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reformat a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82664#M20986</link>
      <description>&lt;P&gt;What I ended up doing was creating two macros, one to strip out the colons and one that put them in.  I was then able to include it in my search:&lt;BR /&gt;
&lt;SEARCH&gt; (macStrip($mac$) OR macColons($mac$)) |&lt;BR /&gt;
I have to many macs in my logs to do a search and match.  Thank you for your help.&lt;/SEARCH&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2012 13:15:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82664#M20986</guid>
      <dc:creator>fk319</dc:creator>
      <dc:date>2012-03-07T13:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reformat a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82665#M20987</link>
      <description>&lt;P&gt;Nice solution with the macros&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2012 20:52:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Reformat-a-field/m-p/82665#M20987</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-03-07T20:52:18Z</dc:date>
    </item>
  </channel>
</rss>

