<?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 regex multiple events, store it in one variable and display based on User click? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495323#M138099</link>
    <description>&lt;P&gt;Something may have been lost from your regular expressions.  Please edit your question to restore them so we can better understand what you are doing.  It seems you only have 2 fields (variables) - api and message.  How do you want to combine them?&lt;/P&gt;</description>
    <pubDate>Fri, 13 Mar 2020 00:10:49 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-03-13T00:10:49Z</dc:date>
    <item>
      <title>How to regex multiple events, store it in one variable and display based on User click?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495322#M138098</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am looking for some help on the below query. I have list of APIs which has different parameters in the URL. I have extracted the Values from the URL and stored it in a variable using replace command. &lt;/P&gt;

&lt;P&gt;Question:&lt;BR /&gt;
1) How would I be able to combine them and store it in one Regex variable? &lt;BR /&gt;
2) If I had it stored in one variable, will it be possible to display the count based on the selected api? &lt;/P&gt;

&lt;P&gt;Splunk Query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abcd appname=xyz
| rex field=message "(GET|POST).(?[^\?\s]+)"
| rex field=message "HTTP\/\S+.(?[^\ ]+)"
| search RespCode=50*
| eval api=replace(api, "(/api/abc/v2/user/Id/.*)","/api/abc/v2/user/Id/Unique_Value")
| eval api=replace(api, "(/api/abc/v2/Name/.*)","/api/abc/v2/user/Name/Unique_Value")
| eval api=replace(api, "(/api/abc/v2/user/.*)","/api/abc/v2/user/Unique_Value")
| eval api=replace(api, "(/api/abc/v2/name/.*/info)","/api/abc/v2/name/unique_value/info")
| eval api=replace(api, "(/api/abc/v2/info/.*/name)","/api/abc/v2/info/unique_value/name")
| rex field=message "user.Id.(?[^\ ]+)"
| stats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can someone help if there is a scope within splunk queries to solve this? I am still trying to learn. Appreciate any assistance. Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 23:09:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495322#M138098</guid>
      <dc:creator>rkrish71</dc:creator>
      <dc:date>2020-03-12T23:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to regex multiple events, store it in one variable and display based on User click?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495323#M138099</link>
      <description>&lt;P&gt;Something may have been lost from your regular expressions.  Please edit your question to restore them so we can better understand what you are doing.  It seems you only have 2 fields (variables) - api and message.  How do you want to combine them?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 00:10:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495323#M138099</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-03-13T00:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to regex multiple events, store it in one variable and display based on User click?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495324#M138100</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Thanks for your response and pointing out about the regex. Yes it got missed out the variable names. I tried to update it in the original question, but I couldn't so reposting the question with the regex query update below.&lt;/P&gt;

&lt;P&gt;Question with update:&lt;BR /&gt;
Hi,&lt;/P&gt;

&lt;P&gt;I am looking for some help on the below query. I have list of APIs which has different parameters in the URL. I have extracted the Values from the URL and stored it in a variable using replace command. &lt;/P&gt;

&lt;P&gt;Question:&lt;BR /&gt;
1) How would I be able to combine them and store it in one Regex variable? &lt;BR /&gt;
2) If I had it stored in one variable, will it be possible to display the count based on the API? like lets say I display the count in a table and have another panel in drilldown that displays when the table is clicked the count.&lt;/P&gt;

&lt;P&gt;Splunk Query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abcd appname=xyz
| rex field=message "(GET|POST).(?&amp;lt;api&amp;gt;[^\ ]+)"
| rex field=message "HTTP\/\S+.(?&amp;lt;RespCode&amp;gt;[^\ ]+)"
| search RespCode=50*
| eval api=replace(api, "(/api/abc/v2/user/Id/.*)","/api/abc/v2/user/Id/Unique_Value")
| eval api=replace(api, "(/api/abc/v2/Name/.*)","/api/abc/v2/user/Name/Unique_Value")
| eval api=replace(api, "(/api/abc/v2/user/.*)","/api/abc/v2/user/Unique_Value")
| eval api=replace(api, "(/api/abc/v2/name/.*/info)","/api/abc/v2/name/unique_value/info")
| eval api=replace(api, "(/api/abc/v2/info/.*/name)","/api/abc/v2/info/unique_value/name")
| rex field=message "user.Id.(&amp;lt;ID&amp;gt;?[^\ ]+)"
| stats dc(ID)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can someone help if there is a scope within splunk queries to solve this? I am still trying to learn. Appreciate any assistance. Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 00:19:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495324#M138100</guid>
      <dc:creator>rkrish71</dc:creator>
      <dc:date>2020-03-13T00:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to regex multiple events, store it in one variable and display based on User click?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495325#M138101</link>
      <description>&lt;P&gt;So you already have the api value in a single field called 'api'.  What do you want to do with it?&lt;BR /&gt;
Be aware that the &lt;CODE&gt;stats&lt;/CODE&gt; command discards all fields except for "dc(ID)" so any attempt to access 'api' will return no results.&lt;BR /&gt;
Please tell us more about what you want your results to look like.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 12:49:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495325#M138101</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-03-13T12:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to regex multiple events, store it in one variable and display based on User click?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495326#M138102</link>
      <description>&lt;P&gt;Unique value is the variable i am storing record/entry of any info that's not static but generated different each time. &lt;/P&gt;

&lt;P&gt;the regular expression that has the value variable "ID" stores only one pattern. (i.e) the first one (/api/abc/v2/user/Id/Unique_Value). So,  i want to do the same for all the other different apis and store it in the same "ID" variable instead of creating different regular expressions for each api and store it in different variables.&lt;/P&gt;

&lt;P&gt;Once I store this in one variable "ID". I am looking to have this in a drilldown and depending upon which api someone clicks, it should give the unique value count of that.  &lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 23:32:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495326#M138102</guid>
      <dc:creator>rkrish71</dc:creator>
      <dc:date>2020-03-13T23:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to regex multiple events, store it in one variable and display based on User click?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495327#M138103</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;|makeresults
| eval _raw="/api/abc/v2/user/Id/abcdefg
/api/abc/v2/user/Id/abcdefs
/api/abc/v2/Name/test
/api/abc/v2/Name/tests
/api/abc/v2/user/okiefshi
/api/abc/v2/user/okie3shi
/api/abc/v2/name/gift/info
/api/abc/v2/name/giftw/info
/api/abc/v2/info/nennde/name
/api/abc/v2/info/nennae/name"
|makemv delim="
" _raw
| stats count by _raw
| rename COMMENT as "this is sample, from here , the logic"
| rex  mode=sed "s/(?i)(\/api\/abc\/v2\/(user\/Id|user|name|info)\/)(?&amp;lt;replace_field&amp;gt;.*?)($|\/(info|name))/\1Unique_value\4/"
| stats count by _raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Mar 2020 05:53:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495327#M138103</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-14T05:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to regex multiple events, store it in one variable and display based on User click?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495328#M138104</link>
      <description>&lt;P&gt;I would put your stuff in a &lt;CODE&gt;Lookup File&lt;/CODE&gt; named &lt;CODE&gt;URL2API.csv&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;URL,API
/api/abc/v2/user/Id/.*,/api/abc/v2/user/Id/Unique_Value
/api/abc/v2/Name/.*,/api/abc/v2/user/Name/Unique_Value
/api/abc/v2/user/.*,/api/abc/v2/user/Unique_Value
/api/abc/v2/name/.*/info,/api/abc/v2/name/unique_value/info
/api/abc/v2/info/.*/name,/api/abc/v2/info/unique_value/name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then create a &lt;CODE&gt;Lookup Definition&lt;/CODE&gt; called &lt;CODE&gt;URL2API&lt;/CODE&gt; with &lt;CODE&gt;WILDCARD(URL)&lt;/CODE&gt;&lt;BR /&gt;
Then you can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | lookup URL2API URL AS api OUTPUT API
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you create automatic &lt;CODE&gt;Field Extractions&lt;/CODE&gt; for &lt;CODE&gt;api&lt;/CODE&gt; then you can create an &lt;CODE&gt;Automatic Lookup&lt;/CODE&gt; so that you will always have &lt;CODE&gt;api&lt;/CODE&gt; &lt;EM&gt;and&lt;/EM&gt; &lt;CODE&gt;API&lt;/CODE&gt; whenever you search this &lt;CODE&gt;sourcetype&lt;/CODE&gt;.  Whenever you need to update the mapping, just adjust the &lt;CODE&gt;Lookup File&lt;/CODE&gt; and everything else will instantly adjust.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 17:34:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495328#M138104</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-14T17:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to regex multiple events, store it in one variable and display based on User click?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495329#M138105</link>
      <description>&lt;P&gt;Thanks. I tried the above but the issue is, the unique values differ and there are 100s of unique values. I cannot list all of them  in raw as each time it varies. Can you suggest how to tackle that?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 05:57:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495329#M138105</guid>
      <dc:creator>rkrish71</dc:creator>
      <dc:date>2020-03-26T05:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to regex multiple events, store it in one variable and display based on User click?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495330#M138106</link>
      <description>&lt;P&gt;&lt;CODE&gt;100s of unique values&lt;/CODE&gt;&lt;BR /&gt;
where?&lt;BR /&gt;
If these are at same position, you can make&lt;BR /&gt;
 Regex&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 09:37:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-multiple-events-store-it-in-one-variable-and/m-p/495330#M138106</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-26T09:37:25Z</dc:date>
    </item>
  </channel>
</rss>

