<?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: Rex on Value from Dashboard Textfield in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221247#M13709</link>
    <description>&lt;P&gt;The rex error is because your regex string does not do any field extractions.  It should look something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=str "cookies\-(?&amp;lt;field1&amp;gt;\d+\.\d+)\-(?&amp;lt;field2&amp;gt;[0-9a-z\._]+[0-9])" | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Naming the groups also resolves your I-might-want-to-further-break-down-the-6.22.yum1_3.5-field-in-the-future problem as you can easily pass field2 into another rex command for dissection.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2016 21:44:19 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2016-06-16T21:44:19Z</dc:date>
    <item>
      <title>Rex on Value from Dashboard Textfield</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221246#M13708</link>
      <description>&lt;P&gt;Hi There!&lt;/P&gt;

&lt;P&gt;Splunk newbie here! I'm using Splunk 6.4.1.&lt;/P&gt;

&lt;P&gt;Issue: I have a dashboard with a text field. I want to use certain components of the text field value in creating a dashboard panel.&lt;/P&gt;

&lt;P&gt;For example:&lt;BR /&gt;
Input (say the text field token is "text"): cookies-5.2-6.22.yum1_3.5.coconut.&lt;BR /&gt;
I want to use 5.2 and 6.22.yum1_3.5 in my query that creates a dashboard panel.&lt;/P&gt;

&lt;P&gt;I know rex is normally used for extracting values from raw data or the source or something related to the events returned in a search, but I feel like there must be a way to do it on the textfield value. I've looked into the split function...but I don't have a good delimiter and I might want to further break down the 6.22.yum1_3.5 field in the future. &lt;/P&gt;

&lt;P&gt;I haven't had any success with the rex command. Here's what I've tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval str="$text$" | rex field=str "regex...."
| rex field="$text$" "regex..."
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the same error back for both: Error in 'rex' command: The regex does not extract anything. It should specify at least one named group. &lt;BR /&gt;
I don't think the issue is with the regex, but here it is in case it is helpful at all: &lt;CODE&gt;cookies\-(?\d+\.\d+)\-(?[0-9a-z\._]+[0-9])&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Thanks so much!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:00:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221246#M13708</guid>
      <dc:creator>penguin1725</dc:creator>
      <dc:date>2020-09-29T10:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Rex on Value from Dashboard Textfield</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221247#M13709</link>
      <description>&lt;P&gt;The rex error is because your regex string does not do any field extractions.  It should look something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=str "cookies\-(?&amp;lt;field1&amp;gt;\d+\.\d+)\-(?&amp;lt;field2&amp;gt;[0-9a-z\._]+[0-9])" | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Naming the groups also resolves your I-might-want-to-further-break-down-the-6.22.yum1_3.5-field-in-the-future problem as you can easily pass field2 into another rex command for dissection.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 21:44:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221247#M13709</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-16T21:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Rex on Value from Dashboard Textfield</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221248#M13710</link>
      <description>&lt;P&gt;Thanks for the response. Oops, not sure why my regex came out like that. In actuality, my regex looks exactly like the one you have above. &lt;/P&gt;

&lt;P&gt;So for some reason, the "str" is not recognized as regex-able. &lt;/P&gt;

&lt;P&gt;Also, something I just tried:&lt;BR /&gt;
When I run the dashboard panel query I get the error I mentioned above.&lt;BR /&gt;
However, when I run the same query in the regular Splunk search window (with a hard coded value in place of the text field value), I don't get the error but the fields don't show up in the side bar.&lt;BR /&gt;
Do you have any ideas why that is the case? Thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 22:13:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221248#M13710</guid>
      <dc:creator>penguin1725</dc:creator>
      <dc:date>2016-06-16T22:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rex on Value from Dashboard Textfield</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221249#M13711</link>
      <description>&lt;P&gt;Oops...not sure why my regex came out like that. The regex I'm using in actuality looks pretty much exactly like richgalloway's: &lt;BR /&gt;
"cookies-(?\d+.\d+)-(?[0-9a-z._]+[0-9])"&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 22:18:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221249#M13711</guid>
      <dc:creator>penguin1725</dc:creator>
      <dc:date>2016-06-16T22:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rex on Value from Dashboard Textfield</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221250#M13712</link>
      <description>&lt;P&gt;Sorry, I'm very new to all of this. Not sure why my regex in the previous comment also came out with some characters missing (the greater-thans/less-thans/some of the slashes)--I'm guessing it is something to do with the fact that I'm not properly escaping the special characters...&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 23:12:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221250#M13712</guid>
      <dc:creator>penguin1725</dc:creator>
      <dc:date>2016-06-16T23:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Rex on Value from Dashboard Textfield</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221251#M13713</link>
      <description>&lt;P&gt;So we've established the problem is not with the regex string.  That leaves either the quotes around &lt;CODE&gt;$text$&lt;/CODE&gt; or something in the unseen parts of the query that results in no results returned.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 02:43:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221251#M13713</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-17T02:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Rex on Value from Dashboard Textfield</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221252#M13714</link>
      <description>&lt;P&gt;Put backticks around the regex to keep the forum from messing with the special characters.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 02:45:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221252#M13714</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-17T02:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Rex on Value from Dashboard Textfield</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221253#M13715</link>
      <description>&lt;P&gt;Great, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 16:05:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221253#M13715</guid>
      <dc:creator>penguin1725</dc:creator>
      <dc:date>2016-06-17T16:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rex on Value from Dashboard Textfield</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221254#M13716</link>
      <description>&lt;P&gt;Thanks for following up--I really appreciate it. &lt;/P&gt;

&lt;P&gt;Yup, I finally figured out that the issue was with how I put the regex search together. As I was experimenting around with the dashboard panel, I had somehow gotten my rex part to look something like: &lt;BR /&gt;
| eval str="$text$" &lt;BR /&gt;
| &lt;STRONG&gt;rex field= str"regex...."&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;That extra space after the equal sign and the deleted space after "str" completely did me in! I totally didn't notice it as I thought the issue was with the value of str coming from the dashboard textfield and str not being a field. &lt;/P&gt;

&lt;P&gt;Then I read that the eval command actually creates a new field. One thing led to another, and I realized that all my regexes that were working looked different from the one I was currently working on...got to love syntax errors! Now I know!&lt;/P&gt;

&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 16:33:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Rex-on-Value-from-Dashboard-Textfield/m-p/221254#M13716</guid>
      <dc:creator>penguin1725</dc:creator>
      <dc:date>2016-06-17T16:33:24Z</dc:date>
    </item>
  </channel>
</rss>

