<?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: How to pass a field as a parameter to the rex command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165571#M47055</link>
    <description>&lt;P&gt;The reason that I did not give a more clear answer was because your question was unclear.  Do you mean that you mean that for this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;Search query&amp;gt; | rex field={FieldWithValue} "SomeRegEx"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You would like the &lt;CODE&gt;rex&lt;/CODE&gt; performed on the field name that is represented by the &lt;EM&gt;&lt;CODE&gt;value&lt;/CODE&gt;&lt;/EM&gt; of the &lt;CODE&gt;FieldWithValue&lt;/CODE&gt; field?&lt;/P&gt;</description>
    <pubDate>Wed, 12 Aug 2015 14:09:43 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-08-12T14:09:43Z</dc:date>
    <item>
      <title>How to pass a field as a parameter to the rex command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165568#M47052</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I would like to how we can pass a field as a parameter to the rex expression in Splunk.&lt;BR /&gt;
I am using the below which is not working for some reason.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Search query&amp;gt; | rex &amp;lt;Field1&amp;gt; | rex "&amp;lt;tag1&amp;gt;?(P=Field1)&amp;lt;/tag1&amp;gt;&amp;lt;tag2&amp;gt;(?P&amp;lt;Field2&amp;gt;)" | table Field1,Field2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there any other way we can pass parameters to a rex expression?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2015 07:11:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165568#M47052</guid>
      <dc:creator>Murali2888</dc:creator>
      <dc:date>2015-08-11T07:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a field as a parameter to the rex command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165569#M47053</link>
      <description>&lt;P&gt;I am not exactly sure what you mean but perhaps you can make use of a &lt;CODE&gt;macro&lt;/CODE&gt; to paramaterize your use of &lt;CODE&gt;rex&lt;/CODE&gt;:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/Search/Usesearchmacros"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.4/Search/Usesearchmacros&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2015 15:49:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165569#M47053</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-11T15:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a field as a parameter to the rex command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165570#M47054</link>
      <description>&lt;P&gt;Thanks for your comments woodcock.&lt;/P&gt;

&lt;P&gt;I tried creating a parameterised macro, but the macro is not handling the "Field Name" as a parameter.&lt;BR /&gt;
Instead of populating the value of the field, the macro populates the Field Name itself. &lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2015 05:56:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165570#M47054</guid>
      <dc:creator>Murali2888</dc:creator>
      <dc:date>2015-08-12T05:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a field as a parameter to the rex command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165571#M47055</link>
      <description>&lt;P&gt;The reason that I did not give a more clear answer was because your question was unclear.  Do you mean that you mean that for this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;Search query&amp;gt; | rex field={FieldWithValue} "SomeRegEx"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You would like the &lt;CODE&gt;rex&lt;/CODE&gt; performed on the field name that is represented by the &lt;EM&gt;&lt;CODE&gt;value&lt;/CODE&gt;&lt;/EM&gt; of the &lt;CODE&gt;FieldWithValue&lt;/CODE&gt; field?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2015 14:09:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165571#M47055</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-12T14:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a field as a parameter to the rex command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165572#M47056</link>
      <description>&lt;P&gt;I'm not sure exactly what you're asking either.  I've used this below to use the value of a capture group later on in the rex, where "\1" is the value from the first capture group - in this case the malware_domain field.  And I have to believe there is a way to escape field values as well is needed (would need to read up on rex), but maybe not.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "CEF.+rewrite (?&amp;lt;malware_domain&amp;gt;\S+).+(\1|nsdname)\.(?&amp;lt;apt_policy&amp;gt;[^\"]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Aug 2015 15:07:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-a-field-as-a-parameter-to-the-rex-command/m-p/165572#M47056</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2015-08-12T15:07:06Z</dc:date>
    </item>
  </channel>
</rss>

