<?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 Extract query parameters from URL in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423277#M173431</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
 I have a tomcat access log which contains urls like &lt;/P&gt;

&lt;P&gt;url=/find.do?from-id=549499&amp;amp;q-out=2019-02-20&amp;amp;q-room-0-adults=2&amp;amp;q-rooms=1&amp;amp;q-check-in=2019-02-18&amp;amp;q-room-0-children=0&amp;amp;hid=116903&lt;/P&gt;

&lt;P&gt;I want to extract all the parameters from it, like from-id ,q-out etc.&lt;/P&gt;

&lt;P&gt;the query I am using is like &lt;/P&gt;

&lt;P&gt;index=my_site source=&lt;EM&gt;sa-*tomcat_access.log&lt;/EM&gt; url | rex field=url "[search.do]&lt;A href="https://community.splunk.com/?%5B%5E=%5D+" target="_blank"&gt;\?&amp;amp;&lt;/A&gt;=([^&amp;amp;]+)" | stats count by url_parameter&lt;/P&gt;

&lt;P&gt;its printing the first value, but not all the fields. Please help me with the query.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 22:55:31 GMT</pubDate>
    <dc:creator>vineethvnair0</dc:creator>
    <dc:date>2020-09-29T22:55:31Z</dc:date>
    <item>
      <title>Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423277#M173431</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
 I have a tomcat access log which contains urls like &lt;/P&gt;

&lt;P&gt;url=/find.do?from-id=549499&amp;amp;q-out=2019-02-20&amp;amp;q-room-0-adults=2&amp;amp;q-rooms=1&amp;amp;q-check-in=2019-02-18&amp;amp;q-room-0-children=0&amp;amp;hid=116903&lt;/P&gt;

&lt;P&gt;I want to extract all the parameters from it, like from-id ,q-out etc.&lt;/P&gt;

&lt;P&gt;the query I am using is like &lt;/P&gt;

&lt;P&gt;index=my_site source=&lt;EM&gt;sa-*tomcat_access.log&lt;/EM&gt; url | rex field=url "[search.do]&lt;A href="https://community.splunk.com/?%5B%5E=%5D+" target="_blank"&gt;\?&amp;amp;&lt;/A&gt;=([^&amp;amp;]+)" | stats count by url_parameter&lt;/P&gt;

&lt;P&gt;its printing the first value, but not all the fields. Please help me with the query.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:55:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423277#M173431</guid>
      <dc:creator>vineethvnair0</dc:creator>
      <dc:date>2020-09-29T22:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423278#M173432</link>
      <description>&lt;P&gt;@vineethvnair0 ,&lt;BR /&gt;
Try adding &lt;CODE&gt;max_match=0&lt;/CODE&gt; to repeat the match&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_site source=*sa-tomcat_access.log url | rex max_match=0 field=url "[search.do][\?\&amp;amp;](?[^=]+)=([^&amp;amp;]+)" | stats count by url_parameter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Test&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    |makeresults|eval url="url=/find.do?from-id=549499&amp;amp;q-out=2019-02-20&amp;amp;q-room-0-adults=2&amp;amp;q-rooms=1&amp;amp;q-check-in=2019-02-18&amp;amp;q-room-0-children=0&amp;amp;hid=116903"
    |rex field=url max_match=0 "[\?\&amp;amp;](?&amp;lt;params&amp;gt;[^=]+)=(?&amp;lt;values&amp;gt;[^&amp;amp;]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Jan 2019 06:24:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423278#M173432</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-01-24T06:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423279#M173433</link>
      <description>&lt;P&gt;@renjith.nair &lt;/P&gt;

&lt;P&gt;its working fine with the test you give, but not working when I query on the original log, I suspect the issue is because the url element is not correctly extracted. Please find a full sample event below&lt;/P&gt;

&lt;P&gt;domain=xxx.com [24/Jan/2019:07:04:45 +0000] remote_host=1.14.1.17 ajax=- http_method=GET url=/find/listings.json?q-locale=en_GB&amp;amp;mvariant=495.0%2C4212.1%2C790.1%2C4192.1%2C2313.3%2C5001.0%2C3309.0%2C7015.0%2C5167.0%2C4440.0&amp;amp;q-mvts=495.0%2C4212.1%2C790.1%2C4192.1%2C2313.3%2C5001.0%2C3309.0%2C7015.0%2C5167.0%2C4440.0&amp;amp;q-logged-in=false&amp;amp;q-posa=DOT_UK&amp;amp;q-secure=true&amp;amp;destination-id=726784&amp;amp;q-client-ip=10.187.77.115&amp;amp;q-channel=WEB_DESKTOP&amp;amp;q-hermes-user-guid=a6acceab-e2e1-43c7-9111-3840cb09bab4&amp;amp;q-brand-id=xxx.com&amp;amp;include-filters=true&amp;amp;q-native-app=iPhone&amp;amp;q-room-0-adults=2&amp;amp;q-rooms=1&amp;amp;so=STAR_RATING_HIGHEST_FIRST&amp;amp;q-client-id=SRLE&amp;amp;lids=1658484 redirect=&lt;A href="http://test.com/find/listings.json?q-locale=en_GB&amp;amp;q-mvts=495.0%2C4212.1%2C790.1%2C4192.1%2C2313.3%2C5001.0%2C3309.0%2C7015.0%2C5167.0%2C4440.0&amp;amp;q-logged-in=false&amp;amp;q-posa=DOT_&amp;amp;q-secure=true&amp;amp;destination-id=726784&amp;amp;q-client-ip=10.187.77.115&amp;amp;q-channel=WEB_DESKTOP&amp;amp;q-hermes-user-guid=a6acceab-e2e1-43c7-9111-3840cb09bab4&amp;amp;q-brand-id=xxx.com&amp;amp;include-filters=true&amp;amp;q-native-app=iPhone&amp;amp;q-room-0-adults=2&amp;amp;q-rooms=1&amp;amp;so=STAR_RATING_HIGHEST_FIRST&amp;amp;q-client-id=SRLE&amp;amp;lids=1658484" target="_blank"&gt;http://test.com/find/listings.json?q-locale=en_GB&amp;amp;q-mvts=495.0%2C4212.1%2C790.1%2C4192.1%2C2313.3%2C5001.0%2C3309.0%2C7015.0%2C5167.0%2C4440.0&amp;amp;q-logged-in=false&amp;amp;q-posa=DOT_&amp;amp;q-secure=true&amp;amp;destination-id=726784&amp;amp;q-client-ip=10.187.77.115&amp;amp;q-channel=WEB_DESKTOP&amp;amp;q-hermes-user-guid=a6acceab-e2e1-43c7-9111-3840cb09bab4&amp;amp;q-brand-id=xxx.com&amp;amp;include-filters=true&amp;amp;q-native-app=iPhone&amp;amp;q-room-0-adults=2&amp;amp;q-rooms=1&amp;amp;so=STAR_RATING_HIGHEST_FIRST&amp;amp;q-client-id=SRLE&amp;amp;lids=1658484&lt;/A&gt; statuscode=302 duration_ms=8 bytes_sent=- referer=- user_agent=comappdefault sessid=- edgescape=- guid=- req_guid=ShoppingApp-SA.2019.1.7379;a4c32120-e144-4c2e-a90b-cceec77e676a;10 nativeApp=- X-Forwarded-Host=- X-Forwarded-Server=- X-NS-Forwarded-Server=- SiteSpectEngine=- &lt;/P&gt;

&lt;P&gt;Can you please help to get the query parameters from this event?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:55:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423279#M173433</guid>
      <dc:creator>vineethvnair0</dc:creator>
      <dc:date>2020-09-29T22:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423280#M173434</link>
      <description>&lt;P&gt;@vineethvnair0 , since all these params are key=value pair, splunk should have extracted them automatically by default. Do you see these as fields in the events ? If not , is url is a field or do we need to extract that as well?&lt;BR /&gt;
I have tried loading your sample event and still it works with the above regex&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 08:31:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423280#M173434</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-01-24T08:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423281#M173435</link>
      <description>&lt;P&gt;@renjith.nair The query parameters  are not listed in splunk, the url is listed but showing only value till&lt;BR /&gt;
find/listings.json?q-locale=en_GB&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 09:26:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423281#M173435</guid>
      <dc:creator>vineethvnair0</dc:creator>
      <dc:date>2019-01-24T09:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423282#M173436</link>
      <description>&lt;P&gt;So it's extracting key value pair but not sure why it's showing up the other fields - there might be other configuration which override KM_MODE.&lt;/P&gt;

&lt;P&gt;Nevertheless, this should also work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=yourindex
|rex field=_raw "url=(?&amp;lt;URL&amp;gt;.+)"
|rex field=URL max_match=0 "[\?\&amp;amp;](?&amp;lt;params&amp;gt;[^=]+)=(?&amp;lt;values&amp;gt;[^&amp;amp;]+)"
|table params,values
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Jan 2019 05:07:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423282#M173436</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-01-25T05:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423283#M173437</link>
      <description>&lt;P&gt;@renjith.nair thanks its working&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 06:38:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423283#M173437</guid>
      <dc:creator>vineethvnair0</dc:creator>
      <dc:date>2019-01-25T06:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423284#M173438</link>
      <description>&lt;P&gt;A small correction for getting the url though &lt;BR /&gt;
rex field=_raw "url=(?[^ ]+)"&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 06:53:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423284#M173438</guid>
      <dc:creator>vineethvnair0</dc:creator>
      <dc:date>2019-01-25T06:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423285#M173439</link>
      <description>&lt;P&gt;@renjith.nair how can i avoid duplicates, I tried using dedup params before and after the&lt;BR /&gt;
 | table params &lt;/P&gt;

&lt;P&gt;But still the field are coming like &lt;/P&gt;

&lt;P&gt;q-locale&lt;BR /&gt;
q-logged-in&lt;BR /&gt;
q-posa&lt;BR /&gt;
q-secure&lt;BR /&gt;
destination-id&lt;BR /&gt;
q-client-ip&lt;BR /&gt;
q-channel&lt;/P&gt;

&lt;P&gt;q-locale&lt;BR /&gt;
q-logged-in&lt;BR /&gt;
q-posa&lt;BR /&gt;
q-secure&lt;BR /&gt;
destination-id&lt;BR /&gt;
q-client-ip&lt;BR /&gt;
q-channel&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 07:31:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423285#M173439</guid>
      <dc:creator>vineethvnair0</dc:creator>
      <dc:date>2019-01-25T07:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423286#M173440</link>
      <description>&lt;P&gt;It might be as multivalue, so either you could use &lt;CODE&gt;|stats count by params|fields - count&lt;/CODE&gt; or &lt;CODE&gt;eval params=mvdedup(params)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 09:50:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423286#M173440</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-01-25T09:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Extract query parameters from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423287#M173441</link>
      <description>&lt;P&gt;@renjith.nair  the stats count one some params are missing, even mvdedup is not working its coming as multiple lists, thats why the duplicates are not removed, is there any way to avoid that&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 10:33:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-query-parameters-from-URL/m-p/423287#M173441</guid>
      <dc:creator>vineethvnair0</dc:creator>
      <dc:date>2019-01-25T10:33:39Z</dc:date>
    </item>
  </channel>
</rss>

