<?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: use information from a lookup to extract values ​​from a field with a rex in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511494#M2863</link>
    <description>&lt;P&gt;hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/64317"&gt;@rnowitzki&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx for your answer and it works for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It taught me a lot and concerning your concern about similar code, I checked and it should not be a problem&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;amir&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jul 2020 11:27:41 GMT</pubDate>
    <dc:creator>amir_bnp</dc:creator>
    <dc:date>2020-07-29T11:27:41Z</dc:date>
    <item>
      <title>use information from a lookup to extract values ​​from a field with a rex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511314#M2831</link>
      <description>&lt;P&gt;hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i need some help for a request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a lookup which contains area country code (phone) associated to country and i want to use these area code( +33, +32,..) to extract from the "calling" field the code which is at the beginning of the number.&lt;/P&gt;&lt;P&gt;EX:&lt;/P&gt;&lt;P&gt;lookup.csv&lt;/P&gt;&lt;P&gt;num country&lt;/P&gt;&lt;P&gt;+33 France&lt;/P&gt;&lt;P&gt;+32 Belgium&lt;/P&gt;&lt;P&gt;+44 England&lt;/P&gt;&lt;P&gt;+351 Portugal&lt;/P&gt;&lt;P&gt;+216 Tunisia&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Field "calling":&lt;/P&gt;&lt;P&gt;calling&lt;/P&gt;&lt;P&gt;+33xxxxxxxxx&lt;/P&gt;&lt;P&gt;+351xxxxxxxxx&lt;/P&gt;&lt;P&gt;+216xxxxxxxx&lt;/P&gt;&lt;P&gt;+32xxxxxxxx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use a rex which points to the "num" field in the lookup file and which will automatically extract the area code in the "calling" field thanks to the lookup.&lt;/P&gt;&lt;P&gt;can we use the "num" field of the lookup file as a variable and put this variable in a rex?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that making a rex that identifies the first 2 or 3 is difficult because you will have to do it one by one&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 12:05:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511314#M2831</guid>
      <dc:creator>amir_bnp</dc:creator>
      <dc:date>2020-07-28T12:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: use information from a lookup to extract values ​​from a field with a rex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511471#M2859</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/218370"&gt;@amir_bnp&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;I came up with a solution. Maybe not the smartest/shortest way, but it works with some sample data.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval calling="+491345256 +32245245134 +35162456235 +216456724356 +444562345 +339324561"
| makemv calling 
| mvexpand calling
| eval sub_calling_3=substr(calling,1,4)
| eval sub_calling_2=substr(calling,1,3)
| lookup countrycode.csv num as sub_calling_3 OUTPUT country as country_3
| lookup countrycode.csv num as sub_calling_2 OUTPUT country as country_2
| eval country=if(country_2!="",country_2, country_3)
| fields - sub_calling_2, sub_calling_3, country_2, country_3&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You only need the SPL starting from the first eval. The lines above it are just to create some sample data.&lt;BR /&gt;&lt;BR /&gt;It tries to match the country with either 2 or 3 digit country code (the 2 lookup lines) and then creates the final country field from either one of them with the &lt;EM&gt;eval if(....).&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;It would fail (or produce random output) if there are countries that share the same first 2 digits.&lt;BR /&gt;So, if country A has +12 and Country B has +123, not sure if this combination exists.&lt;BR /&gt;&lt;BR /&gt;Hope it helps.&amp;nbsp;&lt;BR /&gt;BR&amp;nbsp;&lt;BR /&gt;Ralph&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Karma and/or Solution Tagging appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 08:47:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511471#M2859</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-07-29T08:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: use information from a lookup to extract values ​​from a field with a rex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511478#M2862</link>
      <description>&lt;P&gt;sample:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval calling="+491345256 +32245245134 +35162456235 +216456724356 +444562345 +339324561"
| makemv calling 
| mvexpand calling
| append [ | makeresults
| eval _raw="num,country
+33,France
+32,Belgium
+44,England
+351,Portugal
+216,Tunisia"
| multikv forceheader=1 
| table num country
| eval nums=num."%:".country
| stats list(nums) as nums]
| eventstats list(nums) as nums
| mvexpand nums
| eval num=mvindex(split(nums,":"),0), country=mvindex(split(nums,":"),1)
| where like(calling,num)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;recommend:&lt;BR /&gt;&lt;BR /&gt;index=yours&lt;BR /&gt;| inputlookup append=t&amp;nbsp;&lt;SPAN&gt;lookup.csv&lt;BR /&gt;&lt;/SPAN&gt;| eval nums=num."%:".country&lt;BR /&gt;| evenstats list(nums) as nums&lt;BR /&gt;| mvexpand nums&amp;nbsp;&lt;BR /&gt;| eval num=mvindex(split(nums,":"),0), country=mvindex(split(nums,":"),1)&lt;BR /&gt;| where like(calling,num)&lt;BR /&gt;&lt;BR /&gt;OR&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.5/Knowledge/Usefieldlookupstoaddinformationtoyourevents" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.5/Knowledge/Usefieldlookupstoaddinformationtoyourevents&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;modify CSV and try match type&amp;nbsp;&lt;STRONG&gt;WILDCARD&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 10:21:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511478#M2862</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-07-29T10:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: use information from a lookup to extract values ​​from a field with a rex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511494#M2863</link>
      <description>&lt;P&gt;hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/64317"&gt;@rnowitzki&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx for your answer and it works for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It taught me a lot and concerning your concern about similar code, I checked and it should not be a problem&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;amir&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 11:27:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511494#M2863</guid>
      <dc:creator>amir_bnp</dc:creator>
      <dc:date>2020-07-29T11:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: use information from a lookup to extract values ​​from a field with a rex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511497#M2864</link>
      <description>&lt;P&gt;hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/184221"&gt;@to4kawa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx for your answer but when i run your request, i have a pb due to excessive memory usage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i run step by step your request there are 1 million event at a time and splunk truncate event so at the end i dont have all my event.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="amir_bnp_0-1596022281031.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9926iB63B6C07C83079BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="amir_bnp_0-1596022281031.png" alt="amir_bnp_0-1596022281031.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;amir&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 11:31:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/use-information-from-a-lookup-to-extract-values-from-a-field/m-p/511497#M2864</guid>
      <dc:creator>amir_bnp</dc:creator>
      <dc:date>2020-07-29T11:31:43Z</dc:date>
    </item>
  </channel>
</rss>

