<?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 Missing extra backslash in a &amp;quot;source&amp;quot; token to work properly in search query, any ideas? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421826#M27791</link>
    <description>&lt;P&gt;Hello all, &lt;/P&gt;

&lt;P&gt;I am relatively new to Splunk and creating dashboard with XML, so any recommendations and tips are greatly appreciated.&lt;/P&gt;

&lt;P&gt;So I have a dashboard with a drop-down menu with a list of sources - I did this because we a have a weekly CSV report so the user can pick a file based on its date within the file name. When the panel relying on the "source" token to do the search, it's missing a backslash to work properly. The source code and explanation below.&lt;/P&gt;

&lt;P&gt;Drop-down menu:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="dropdown" token="source_csv" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Select a report week:&amp;lt;/label&amp;gt;
      &amp;lt;prefix&amp;gt;source=&amp;lt;/prefix&amp;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;source&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;source&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;
          index="example_reports" | chart count by source 
        &amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
    &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So when a panel with the search below is done, nothing shows up because it's missing a backslash. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;host="example_host" index="example_index" $source_csv$ | stats distinct_count(ip)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The search query comes out as:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;host="example_host" index="example_index" source=D:\example\report-2018-12-25.csv | stats distinct_count(ip)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The issue is that the source value needs two backslashes for it to work:&lt;BR /&gt;
&lt;STRONG&gt;source=D:\example\report-2018-12-25.csv&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Is there anyway to get the token to have two backslashes to the directory with the token or search query? Thank you in advance.&lt;/P&gt;

&lt;P&gt;I did search for solutions on this by adding |s$ and search string, but couldn't get it to work right...&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 00:54:22 GMT</pubDate>
    <dc:creator>mpham07</dc:creator>
    <dc:date>2020-09-30T00:54:22Z</dc:date>
    <item>
      <title>Missing extra backslash in a "source" token to work properly in search query, any ideas?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421826#M27791</link>
      <description>&lt;P&gt;Hello all, &lt;/P&gt;

&lt;P&gt;I am relatively new to Splunk and creating dashboard with XML, so any recommendations and tips are greatly appreciated.&lt;/P&gt;

&lt;P&gt;So I have a dashboard with a drop-down menu with a list of sources - I did this because we a have a weekly CSV report so the user can pick a file based on its date within the file name. When the panel relying on the "source" token to do the search, it's missing a backslash to work properly. The source code and explanation below.&lt;/P&gt;

&lt;P&gt;Drop-down menu:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="dropdown" token="source_csv" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Select a report week:&amp;lt;/label&amp;gt;
      &amp;lt;prefix&amp;gt;source=&amp;lt;/prefix&amp;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;source&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;source&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;
          index="example_reports" | chart count by source 
        &amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
    &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So when a panel with the search below is done, nothing shows up because it's missing a backslash. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;host="example_host" index="example_index" $source_csv$ | stats distinct_count(ip)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The search query comes out as:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;host="example_host" index="example_index" source=D:\example\report-2018-12-25.csv | stats distinct_count(ip)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The issue is that the source value needs two backslashes for it to work:&lt;BR /&gt;
&lt;STRONG&gt;source=D:\example\report-2018-12-25.csv&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Is there anyway to get the token to have two backslashes to the directory with the token or search query? Thank you in advance.&lt;/P&gt;

&lt;P&gt;I did search for solutions on this by adding |s$ and search string, but couldn't get it to work right...&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:54:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421826#M27791</guid>
      <dc:creator>mpham07</dc:creator>
      <dc:date>2020-09-30T00:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Missing extra backslash in a "source" token to work properly in search query, any ideas?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421827#M27792</link>
      <description>&lt;P&gt;Yes, try this in your dynamic search that populates the drop down or prior to using the token in sub panels.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex mode=sed field=source "s/\\/\\/"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval field=$source$
  | rex mode=sed field=source "s/\\\/\\\\\\\/"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jun 2019 13:52:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421827#M27792</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-06-13T13:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Missing extra backslash in a "source" token to work properly in search query, any ideas?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421828#M27793</link>
      <description>&lt;P&gt;Hello jkat54,&lt;/P&gt;

&lt;P&gt;I tried both and they didn't work, I get a "Could not create search. Error in 'rex' command: Failed to initialize sed. Failed to parse the regex to replace."&lt;/P&gt;

&lt;P&gt;Is this the correct way to input the search in the drop-down panel? Thanks again. &lt;/P&gt;

&lt;P&gt;host="example_host" index="example_index" | rex mode=sed field=source "s/\/\/"| chart count by source&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:54:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421828#M27793</guid>
      <dc:creator>mpham07</dc:creator>
      <dc:date>2020-09-30T00:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Missing extra backslash in a "source" token to work properly in search query, any ideas?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421829#M27794</link>
      <description>&lt;P&gt;To troubleshoot, do the following (this works but just to explain the process);&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1
| eval source="D:\example\report-2015-05-05.csv"
| rex field=source mode=sed "s/\\\/\\\\\\\/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll see the result you desired, hopefully, I do.. But once your regex is confirmed then put it in your search and carry on.&lt;/P&gt;

&lt;P&gt;I tried using the regex provided above and didn't see the result you wanted so it most likely wouldn't work even with your search provided. &lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 14:46:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421829#M27794</guid>
      <dc:creator>jazzypai</dc:creator>
      <dc:date>2019-06-13T14:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Missing extra backslash in a "source" token to work properly in search query, any ideas?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421830#M27795</link>
      <description>&lt;P&gt;Thank you so much jazzypai! I got it to work with your rex line. Here is what I put in for the drop down search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="example_host" index="example_index"  | rex field=source mode=sed "s/\\\/\\\\\\\/g" | chart count by source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then it came out right for the search queries that used "source_csv" tokens! Thank you so much for the help and troubleshooting guys/gals! :'D&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 15:09:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421830#M27795</guid>
      <dc:creator>mpham07</dc:creator>
      <dc:date>2019-06-13T15:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Missing extra backslash in a "source" token to work properly in search query, any ideas?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421831#M27796</link>
      <description>&lt;P&gt;With the help of jazzypai and jkat54, the answer is below:&lt;/P&gt;

&lt;P&gt;Thank you so much jazzypai! I got it to work with your rex line. Here is what I put in for the drop down search:&lt;/P&gt;

&lt;P&gt;host="example_host" index="example_index"  | rex field=source mode=sed "s/\\/\\\\/g" | chart count by source&lt;/P&gt;

&lt;P&gt;Then it came out right for the search queries that used "source_csv" tokens! Thank you so much for the help and troubleshooting guys/gals! :'D&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:54:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421831#M27796</guid>
      <dc:creator>mpham07</dc:creator>
      <dc:date>2020-09-30T00:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Missing extra backslash in a "source" token to work properly in search query, any ideas?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421832#M27797</link>
      <description>&lt;P&gt;Glad it worked out! Good job!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 15:27:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Missing-extra-backslash-in-a-quot-source-quot-token-to-work/m-p/421832#M27797</guid>
      <dc:creator>jazzypai</dc:creator>
      <dc:date>2019-06-13T15:27:58Z</dc:date>
    </item>
  </channel>
</rss>

