<?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: how to rex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635574#M220810</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232766"&gt;@mikeyty07&lt;/a&gt;&amp;nbsp;... its pretty simple actually.. check this out..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="two-logs.txt" host="laptop" sourcetype="twologs" 
| rex field=_raw "requestUri\=(?P&amp;lt;status&amp;gt;\w+)\:\/\/(?P&amp;lt;URL&amp;gt;\w+\.\w+\.\w+\:\d+)(?P&amp;lt;service&amp;gt;\/\w+)(?P&amp;lt;api&amp;gt;\/\w+\/\w+)[\,|\?](?P&amp;lt;params&amp;gt;\S+)\,"  
| table status URL service api params&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;check the sample run:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rex-two-logs.jpg" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24447iE7917E0E9F6A24DC/image-size/large?v=v2&amp;amp;px=999" role="button" title="rex-two-logs.jpg" alt="rex-two-logs.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Mar 2023 00:07:25 GMT</pubDate>
    <dc:creator>inventsekar</dc:creator>
    <dc:date>2023-03-23T00:07:25Z</dc:date>
    <item>
      <title>How to rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635566#M220808</link>
      <description>&lt;P&gt;I have 2 kind of logs where there are two types of uri which i want to rex into different fields&lt;/P&gt;
&lt;P&gt;{logType=DOWNSTREAM_RESPONSE, requestUri=&lt;A href="https://google.come.com:443/google/api/updateapi?&amp;amp;lo=en_US&amp;amp;sc=RT" target="_blank" rel="noopener"&gt;https://google.come.com:8000/google/api/updateapi?&amp;amp;lo=en_US&amp;amp;sc=RT&lt;/A&gt;, duration=22, requestId=znXdSxbJQw6iVTtEeykZVA, globalTrackingId=null, requestTrackingId=null, request={body={"a":{"b":{"country":"US", }}}, method=POST, requestUri=&lt;A href="https://google.come.com:443/google/api/updateapi?&amp;amp;lo=en_US&amp;amp;sc=RT" target="_blank" rel="noopener"&gt;https://google.come.com:443/google/api/updateapi?&amp;amp;lo=en_US&amp;amp;sc=RT&lt;/A&gt;}, response=(200 OK, { "body="{} }, "headers="{}, "statusCode=OK", statusCodeValue=200}")"}&lt;BR /&gt;&lt;BR /&gt;{logType=DOWNSTREAM_RESPONSE, requestUri=&lt;A href="https://google.come.com:443/google/api/deleteapi" target="_blank" rel="noopener"&gt;https://google.come.com:8000/google/api/deleteapi&lt;/A&gt;, duration=33, requestId=asdasd, globalTrackingId=null, requestTrackingId=null, request={body={"a":{"b":{"country":"US", }}}, method=POST, requestUri=&lt;A href="https://google.come.com:443/google/api/updateapi?&amp;amp;lo=en_US&amp;amp;sc=RT" target="_blank" rel="noopener"&gt;https://google.come.com:443/google/api/updateapi?&amp;amp;lo=en_US&amp;amp;sc=RT&lt;/A&gt;}, response=(200 OK, { "body="{} }, "headers="{}, "statusCode=OK", statusCodeValue=200}")"}&lt;/P&gt;
&lt;P&gt;http= https&lt;/P&gt;
&lt;P&gt;URL= google.come.com:8000&lt;/P&gt;
&lt;P&gt;service = /google&lt;/P&gt;
&lt;P&gt;api= /api/updateapi&lt;BR /&gt;api= /api/deleteapi&lt;/P&gt;
&lt;P&gt;params=&amp;nbsp;?&amp;amp;lo=en_US&amp;amp;sc=RT&lt;/P&gt;
&lt;P&gt;is there a way to regex this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 14:35:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635566#M220808</guid>
      <dc:creator>mikeyty07</dc:creator>
      <dc:date>2023-03-23T14:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635569#M220809</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Yes you can extract those fields using&amp;nbsp;| rex.&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 "(?&amp;lt;http&amp;gt;https?)\:\/\/(?&amp;lt;URL&amp;gt;[^\/]*)(?&amp;lt;service&amp;gt;/[^\/]*)(?&amp;lt;api&amp;gt;[^\?\,\}]*)(?:\?(?&amp;lt;params&amp;gt;[^\,\}]*))?"&lt;/LI-CODE&gt;&lt;P&gt;This will extract all URLs in the _raw event into those fields that you suggested. If you want to run this on a specific field then you could add the field=&amp;lt;&amp;lt;field&amp;gt;&amp;gt; argument to the | rex command.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 23:26:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635569#M220809</guid>
      <dc:creator>Tom_Lundie</dc:creator>
      <dc:date>2023-03-22T23:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635574#M220810</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232766"&gt;@mikeyty07&lt;/a&gt;&amp;nbsp;... its pretty simple actually.. check this out..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="two-logs.txt" host="laptop" sourcetype="twologs" 
| rex field=_raw "requestUri\=(?P&amp;lt;status&amp;gt;\w+)\:\/\/(?P&amp;lt;URL&amp;gt;\w+\.\w+\.\w+\:\d+)(?P&amp;lt;service&amp;gt;\/\w+)(?P&amp;lt;api&amp;gt;\/\w+\/\w+)[\,|\?](?P&amp;lt;params&amp;gt;\S+)\,"  
| table status URL service api params&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;check the sample run:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rex-two-logs.jpg" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24447iE7917E0E9F6A24DC/image-size/large?v=v2&amp;amp;px=999" role="button" title="rex-two-logs.jpg" alt="rex-two-logs.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 00:07:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635574#M220810</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2023-03-23T00:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635742#M220877</link>
      <description>&lt;P&gt;if i have to add the duration in same query of rex what would it be?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:24:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635742#M220877</guid>
      <dc:creator>mikeyty07</dc:creator>
      <dc:date>2023-03-23T15:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635749#M220881</link>
      <description>&lt;P&gt;Looking at your sample logs, duration is a separate field and it only seems to be applied in context of one of your URLs so I wouldn't extract it within the same | rex query.&lt;/P&gt;&lt;P&gt;Best-practise here is to set-up search-time field extractions for these fields. Read more &lt;A href="https://docs.splunk.com/Documentation/Splunk/9.0.4/Knowledge/Managesearch-timefieldextractions" target="_self"&gt;here&lt;/A&gt;. The general idea is to make your fields extract automatically so that you don't have to run these rex commands for every single-use case that pertains to these logs.&lt;/P&gt;&lt;P&gt;That being said, if you're sure that you want to get this extracted via rex, use a separate command, the following regex will work:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "duration=(?&amp;lt;duration&amp;gt;\d+)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 16:14:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rex/m-p/635749#M220881</guid>
      <dc:creator>Tom_Lundie</dc:creator>
      <dc:date>2023-03-23T16:14:22Z</dc:date>
    </item>
  </channel>
</rss>

