<?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 How to write a search with the regex to extract strings of URL IDs and create a pie chart with this field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145603#M40612</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have data in Splunk Cloud which has a &lt;CODE&gt;path=/api/versions/:version_id&lt;/CODE&gt; where &lt;CODE&gt;version_id&lt;/CODE&gt; can be anything acceptable in a URL.&lt;/P&gt;

&lt;P&gt;I'm trying to write a search that finds and creates a pie chart of the &lt;CODE&gt;:version_id&lt;/CODE&gt;s over the past 24 hours and past 7 days.&lt;/P&gt;

&lt;P&gt;I've tried this search, but it's not returning the right results: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=/var/log/mylog.log | rex field=path "/api/versions/(?.*)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get results that don't actually match the regex above. &lt;/P&gt;

&lt;P&gt;Can anyone point me to some docs so I can get the right usage of the regex and create my dashboard?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 16 Apr 2015 14:57:10 GMT</pubDate>
    <dc:creator>lanceblais</dc:creator>
    <dc:date>2015-04-16T14:57:10Z</dc:date>
    <item>
      <title>How to write a search with the regex to extract strings of URL IDs and create a pie chart with this field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145603#M40612</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have data in Splunk Cloud which has a &lt;CODE&gt;path=/api/versions/:version_id&lt;/CODE&gt; where &lt;CODE&gt;version_id&lt;/CODE&gt; can be anything acceptable in a URL.&lt;/P&gt;

&lt;P&gt;I'm trying to write a search that finds and creates a pie chart of the &lt;CODE&gt;:version_id&lt;/CODE&gt;s over the past 24 hours and past 7 days.&lt;/P&gt;

&lt;P&gt;I've tried this search, but it's not returning the right results: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=/var/log/mylog.log | rex field=path "/api/versions/(?.*)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get results that don't actually match the regex above. &lt;/P&gt;

&lt;P&gt;Can anyone point me to some docs so I can get the right usage of the regex and create my dashboard?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2015 14:57:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145603#M40612</guid>
      <dc:creator>lanceblais</dc:creator>
      <dc:date>2015-04-16T14:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with the regex to extract strings of URL IDs and create a pie chart with this field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145604#M40613</link>
      <description>&lt;P&gt;Slashes must be escaped and your group is mal-formed.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=path "\/api\/versions\/:(?&amp;lt;version_id&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Apr 2015 15:19:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145604#M40613</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-04-16T15:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with the regex to extract strings of URL IDs and create a pie chart with this field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145605#M40614</link>
      <description>&lt;P&gt;Thanks for the info. I've adapted my string:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=/var/log/my.log | rex field=path "\/api\/versions\/:(?.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it's still matching things like &lt;CODE&gt;/api/sections/123/items/123&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;

&lt;P&gt;Note: This box keeps striping out the &amp;lt; version_id &amp;gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2015 17:33:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145605#M40614</guid>
      <dc:creator>lanceblais</dc:creator>
      <dc:date>2015-04-16T17:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with the regex to extract strings of URL IDs and create a pie chart with this field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145606#M40615</link>
      <description>&lt;P&gt;There's no way "/api/versions/:" can match "/api/sections/".  Perhaps it would help if you shared (anonymized) sample data.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;($.*)&lt;/CODE&gt; is not a valid regex construct.  Use &lt;BR /&gt;
    (?&amp;lt;version_id&amp;gt;.*).&lt;BR /&gt;&lt;BR /&gt;
You can change 'version_id' to any string you want to be the field name to hold matching version IDs.&lt;/P&gt;

&lt;P&gt;Indent your code by 4 spaces to preserve backslashes and other formatting characters.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:34:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145606#M40615</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-09-28T19:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with the regex to extract strings of URL IDs and create a pie chart with this field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145607#M40616</link>
      <description>&lt;P&gt;Above does works for me and its not matching. See this runanywhere sample search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval path="/api/versions/:version_id /api/versions/api/sections/123/items/123 /api/versions/123/items/123 /api/versions/:version_id /api/sections/123/items/123" | table path | makemv path | mvexpand path | rex field=path "\/api\/versions\/:(?&amp;lt;version_id&amp;gt;.*)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you post some sample values of field path, including the ones that are not working?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2015 17:45:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-the-regex-to-extract-strings-of-URL/m-p/145607#M40616</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-04-16T17:45:32Z</dc:date>
    </item>
  </channel>
</rss>

