<?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: populating input dropdown with regex search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366254#M108028</link>
    <description>&lt;P&gt;hi kamlesh, this did not work&lt;/P&gt;

&lt;P&gt;additionally the &amp;lt;&amp;gt; is part of the text that i'm looking for and it's not a regex char, so, i do not believe that's where the break is&lt;/P&gt;</description>
    <pubDate>Fri, 10 Nov 2017 18:20:29 GMT</pubDate>
    <dc:creator>eddychuah</dc:creator>
    <dc:date>2017-11-10T18:20:29Z</dc:date>
    <item>
      <title>populating input dropdown with regex search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366252#M108026</link>
      <description>&lt;P&gt;Hi splunk community, am trying to populating input dropdown with results from regex search and i'm fairly sure it's my usage syntax&lt;/P&gt;

&lt;P&gt;any help is appreciated;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;input type="dropdown" token="field1"&amp;gt;
    &amp;lt;label&amp;gt;field1&amp;lt;/label&amp;gt;

                          &amp;lt;populatingSearch fieldForLabel="name" fieldForValue="name"&amp;gt;sourcetype="error log" | rex field=_raw "(&amp;lt;StatusCode&amp;gt;)(?&amp;lt;code&amp;gt;\d+)(&amp;lt;/ns0:StatusCode&amp;gt;)"|top code&amp;lt;/populatingSearch&amp;gt;

      &amp;lt;earliest&amp;gt;$test.earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$test.latest$&amp;lt;/latest&amp;gt;
  &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i keep receiving error on my regex line: Unexpected close tag&lt;/P&gt;

&lt;P&gt;and there's nothing wrong with the regex statement, i've tested it in the main search and it correctly extrapolates the data that i want into new afore stated &lt;CODE&gt; variable&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;thanks in advance&lt;BR /&gt;
&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:21:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366252#M108026</guid>
      <dc:creator>eddychuah</dc:creator>
      <dc:date>2017-11-10T16:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: populating input dropdown with regex search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366253#M108027</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;Can you please update your XML code?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;populatingSearch fieldForLabel="name" fieldForValue="name"&amp;gt;sourcetype="error log" | rex field=_raw "(&amp;gt;StatusCode&amp;lt;)(?&amp;gt;code&amp;lt;\d+)(&amp;gt;/ns0:StatusCode&amp;lt;)"|top code&amp;lt;/populatingSearch&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:34:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366253#M108027</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-10T16:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: populating input dropdown with regex search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366254#M108028</link>
      <description>&lt;P&gt;hi kamlesh, this did not work&lt;/P&gt;

&lt;P&gt;additionally the &amp;lt;&amp;gt; is part of the text that i'm looking for and it's not a regex char, so, i do not believe that's where the break is&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 18:20:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366254#M108028</guid>
      <dc:creator>eddychuah</dc:creator>
      <dc:date>2017-11-10T18:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: populating input dropdown with regex search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366255#M108029</link>
      <description>&lt;P&gt;Seems like you are trying to parse XML data for field extraction. You should consider the following for extraction data from XML&lt;BR /&gt;
1) Use of KV_MODE=xml for automatic Search Time Field Discovery from XML data, provided events are always XML. (&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf#Field_extraction_configuration" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf#Field_extraction_configuration&lt;/A&gt;)&lt;BR /&gt;
2) &lt;CODE&gt;spath&lt;/CODE&gt; command for parsing and extraction XML data. (&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;)&lt;/P&gt;

&lt;P&gt;Does your XML node StatusCode look like the following?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;StatusCode&amp;gt;12345&amp;lt;/ns0:StatusCode&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If yes you should try the following &lt;CODE&gt;rex&lt;/CODE&gt; command instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="error log" 
| rex "&amp;lt;StatusCode&amp;gt;(?&amp;lt;code&amp;gt;\d+)&amp;lt;\/ns0:StatusCode&amp;gt;"
| top code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: while saving to dashboard it &amp;lt; and &amp;gt; should be escaped&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "&amp;lt;StatusCode&amp;gt;(?&amp;lt;code&amp;gt;\d+)&amp;amp;quot;\/ns0:StatusCode&amp;amp;quot;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was also curious on the version of Splunk you are using, since populatingSearch is legacy command, you should be using &lt;CODE&gt;&amp;lt;search&amp;gt;&lt;/CODE&gt; with &lt;CODE&gt;&amp;lt;query&amp;gt;&lt;/CODE&gt; &lt;CODE&gt;&amp;lt;earliest&amp;gt;&lt;/CODE&gt; and &lt;CODE&gt;&amp;lt;latest&amp;gt;&lt;/CODE&gt; and tokens should be set using &lt;CODE&gt;&amp;lt;fieldforvalue&amp;gt;&lt;/CODE&gt; and &lt;CODE&gt;&amp;lt;fieldforlabel&amp;gt;&lt;/CODE&gt; respectively.&lt;/P&gt;

&lt;P&gt;So you final dropdown input code should look like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;input type="dropdown" token="field1"&amp;gt;
      &amp;lt;label&amp;gt;field1&amp;lt;/label&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;code&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;code&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;sourcetype="error log" earliest=$test.earliest$ latest=$test.latest$
| rex "&amp;amp;lt;StatusCode&amp;amp;gt;(?&amp;amp;lt;code&amp;amp;gt;\d+)&amp;amp;lt;\/ns0:StatusCode&amp;amp;gt;"
|top code
        &amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
    &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Viz/Buildandeditforms" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Viz/Buildandeditforms&lt;/A&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;&lt;STRONG&gt;[UPDATE]&lt;/STRONG&gt;, just noticed that &lt;CODE&gt;&amp;amp; lt ;&lt;/CODE&gt; got escaped as &lt;CODE&gt;&amp;amp;lt;&lt;/CODE&gt; while trying to post answer. Trying an update to fix the same. Can you try the query from the final example? Ideally with this &lt;CODE&gt;CDATA&lt;/CODE&gt; would not be required since special characters are already escaped. No need to stress though as you already have a working solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
PS: In your question you had used time tokens for earliest and latest, so I had included &lt;CODE&gt;earliest=$test.earliest$ latest=$test.latest$&lt;/CODE&gt; in the base search. Please include the same as your current search runs for 24 hours static time.&lt;BR /&gt;
Also if you are trying to apply &lt;CODE&gt;rex&lt;/CODE&gt; on &lt;CODE&gt;_raw&lt;/CODE&gt; data, then &lt;CODE&gt;field=_raw&lt;/CODE&gt; is optional.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:42:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366255#M108029</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T16:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: populating input dropdown with regex search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366256#M108030</link>
      <description>&lt;P&gt;hi again @niketnilay!  yes you are absolutely correctly;&lt;BR /&gt;
- i should have informed the version i'm using, rookie mistake coming from a old prod support guy lol (am using 6.6.3&lt;BR /&gt;
- this is indeed legacy command, however try as i might with the example syntax provided from splunk examples it didnt work because.......&lt;/P&gt;

&lt;P&gt;yes i'm digging through SOAP tags so since we are already working in XML form in Splunk, have to further "string-ify" the query string so i did this instead&lt;/P&gt;

&lt;P&gt;field1&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
        &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
        &amp;lt;fieldForLabel&amp;gt;code&amp;lt;/fieldForLabel&amp;gt;
        &amp;lt;fieldForValue&amp;gt;code&amp;lt;/fieldForValue&amp;gt;
        &amp;lt;search&amp;gt;
            &amp;lt;query&amp;gt;
              &amp;lt;![CDATA[index=main sourcetype="error log"  | rex "(&amp;lt;ns0:StatusCode&amp;gt;)(?&amp;lt;code&amp;gt;\d+)(&amp;lt;/ns0:StatusCode&amp;gt;)"|top code]]&amp;gt; 

             &amp;lt;!-- &amp;lt;![CDATA[index=main | stats count by code]]&amp;gt;--&amp;gt;
            &amp;lt;/query&amp;gt;
            &amp;lt;earliest&amp;gt;-24h&amp;lt;/earliest&amp;gt;
            &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Nov 2017 19:18:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/populating-input-dropdown-with-regex-search/m-p/366256#M108030</guid>
      <dc:creator>eddychuah</dc:creator>
      <dc:date>2017-11-10T19:18:36Z</dc:date>
    </item>
  </channel>
</rss>

