<?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: User agent Extraction - Lookup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569625#M198533</link>
    <description>&lt;P&gt;Sorry, I assumed you were using the my suggested case statement - rather than your original nested if statement. Are you saying that if statement is what gives you the results in your screenshot?&lt;/P&gt;&lt;P&gt;As for your question on examples of the lookup command, my earlier post showed you how to use the lookup command to get what you want, you will just need to create your lookup as I suggeted. You will not need the case statement if you use a lookup.&lt;/P&gt;&lt;P&gt;See the lookup description here&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.2/SearchTutorial/Usefieldlookups" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.2/SearchTutorial/Usefieldlookups&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and how to set up wildcard lookups here&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.2/Knowledge/Addfieldmatchingrulestoyourlookupconfiguration" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.2/Knowledge/Addfieldmatchingrulestoyourlookupconfiguration&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Oct 2021 22:54:49 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2021-10-04T22:54:49Z</dc:date>
    <item>
      <title>User agent Extraction - Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569028#M198331</link>
      <description>&lt;P&gt;Hi Team&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to extract few report from user agent. like below&amp;nbsp;&lt;/P&gt;&lt;TABLE width="725"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="72"&gt;OS details&amp;nbsp;&lt;/TD&gt;&lt;TD width="73"&gt;OS version&lt;/TD&gt;&lt;TD width="58"&gt;Browser&lt;/TD&gt;&lt;TD width="110"&gt;Browser Version&lt;/TD&gt;&lt;TD width="118"&gt;Operating System&lt;/TD&gt;&lt;TD width="171"&gt;Operating System Version&lt;/TD&gt;&lt;TD width="123"&gt;Mobile device&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently i am using eval&amp;nbsp; ( IF &amp;amp; Case ) to generate report however its very manual process and more time consuming. Please find below command for example&amp;nbsp;&lt;/P&gt;&lt;P&gt;If -&amp;nbsp;val Device =if(match(cs_user_agent, "iPhone"),"iPhone",if(match(cs_user_agent, "Macintosh"),"iPhone",if(match(cs_user_agent, "iPad"),"iPhone",if(match(cs_user_agent, "Android"),"Android",if(match(cs_user_agent, "Win64"),"Windows",if(match(cs_user_agent, "14092"),"Windows",if(match(cs_user_agent, "Windows"),"Windows",if(match(cs_user_agent,"SM-"),"Android",if(match(cs_user_agent,"CPH"),"Android",if(match(cs_user_agent,"Nokia"),"Android",if(match(cs_user_agent,"Pixel"),"Android",if(match(cs_user_agent,"TB-"),"Android",if(match(cs_user_agent,"VFD"),"Android",if(match(cs_user_agent,"HP%20Pro%20Slate"),"Android",if(match(cs_user_agent,"VOG-L09"),"Android",if(match(cs_user_agent,"YAL-L21"),"Android",if(match(cs_user_agent,"ATU-L22"),"Android",if(match(cs_user_agent,"MAR-LX1A"),"Android",if(match(cs_user_agent,"RNE-L22"),"Android",if(match(cs_user_agent,"INE-LX2"),"Android",if(match(cs_user_agent,"AMN-LX2"),"Android",if(match(cs_user_agent,"LYO-LO2"),"Android",if(match(cs_user_agent,"DRA-LX9"),"Android",if(match(cs_user_agent,"LYA-L29"),"Android",if(match(cs_user_agent,"ANE-LX2J"),"Android",if(match(cs_user_agent,"STK-L22"),"Android",if(match(cs_user_agent,"EML-AL00"),"Android",if(match(cs_user_agent,"BLA-L29"),"Android",if(match(cs_user_agent,"X11"),"Linux",if(match(cs_user_agent,"LDN-LX2"),"Android",if(match(cs_user_agent,"TB3-"),"Android",if(match(cs_user_agent,"5033T"),"Android",if(match(cs_user_agent,"5028D"),"Android",if(match(cs_user_agent,"5002X"),"Android",if(match(cs_user_agent,"COR-"),"Android",if(match(cs_user_agent,"MI%20MAX"),"Android",if(match(cs_user_agent,"WAS-LX2"),"Android",if(match(cs_user_agent,"vivo"),"Android",if(match(cs_user_agent,"EML-L29"),"Android",if(match(cs_user_agent,"Moto"),"Android",if(match(cs_user_agent,"MMB"),"Android",if(match(cs_user_agent,"Redmi%20Note%208"),"Android",if(match(cs_user_agent,"M2003J15SC"),"Android",if(match(cs_user_agent,"MI%20MAX"),"Android",if(match(cs_user_agent,"Nexus"),"Android",if(match(cs_user_agent,"ELE-L29"),"Android",if(match(cs_user_agent,"Redmi%20Note%204"),"Android",if(match(cs_user_agent,"rv:89.0"),"Android",if(match(cs_user_agent,"VKY-L09"),"Android",if(match(cs_user_agent,"SmartN11"),"Android",if(match(cs_user_agent,"A330"),"Android",if(match(cs_user_agent,"LM-"),"Android",if(match(cs_user_agent,"G8341"),"Android",if(match(cs_user_agent,"INE-AL00"),"Android",if(match(cs_user_agent,"Mi"),"Android",if(match(cs_user_agent,"CLT"),"Android",if(match(cs_user_agent,"Android"),"Android",if(match(cs_user_agent,"BV9700Pro"),"Android",if(match(cs_user_agent,"5024I"),"Android",if(match(cs_user_agent,"MEIZU"),"Android",if(match(cs_user_agent,"Linux%20X86_64"),"Linux","OTHER")))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))&lt;/P&gt;&lt;P&gt;Case -&amp;nbsp;val Brand= case(match(cs_user_agent, "CPH"),"Oppo",match(cs_user_agent, "SM-"),"Samsung",match(cs_user_agent, "VFD"),"Vodafone",match(cs_user_agent, "VFD"),"Vodafone",match(cs_user_agent, "VOG"),"Huawei",match(cs_user_agent, "ELE"),"Huawei",match(cs_user_agent, "CLT"),"Huawei",match(cs_user_agent, "EML"),"Huawei",match(cs_user_agent, "LYA"),"Huawei",match(cs_user_agent, "EVR"),"Huawei",match(cs_user_agent, "BLA"),"Huawei",match(cs_user_agent, "DRA"),"Huawei",match(cs_user_agent, "LDN"),"Huawei",match(cs_user_agent, "YAL-L21"),"Huawei",match(cs_user_agent, "ATU-L22"),"Huawei",match(cs_user_agent, "MAR-LX1A"),"Huawei",match(cs_user_agent, "X11"),"Linux",match(cs_user_agent, "INE-LX2"),"Huawei",match(cs_user_agent, "AMN-"),"Huawei",match(cs_user_agent, "RNE-L22"),"Honor",match(cs_user_agent, "LYO"),"Huawei",match(cs_user_agent, "ANE"),"Huawei",match(cs_user_agent, "STK"),"Huawei",match(cs_user_agent, "BLA"),"Huawei",match(cs_user_agent, "TB3-"),"Lenovo",match(cs_user_agent, "5033T"),"Alcatel",match(cs_user_agent, "5028D"),"Alcatel",match(cs_user_agent, "5002X"),"Alcatel",match(cs_user_agent, "iPhone"),"iPhone",match(cs_user_agent, "20Win64"),"Desktop",1=1,"other")&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Can any one help me on how do i use&amp;nbsp;&amp;nbsp;lookup? or automatic lookup so it fills a "human-readable" type into a separate field.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 00:14:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569028#M198331</guid>
      <dc:creator>jaibalaraman</dc:creator>
      <dc:date>2021-09-30T00:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: User agent Extraction - Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569031#M198332</link>
      <description>&lt;P&gt;You are using match/if in the wrong way - for this type of match you should be using case statement, not if and you should use the features of match so that you use regular expressions rather than a match statement for a single string. Instead you could use this syntax - try this complete search - but the case statement is what you can use in yours...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval cs_user_agent=split("iPhone,Nokia,VOG-LO8,VOG-L09,Android,X11,Redmi%20Note%204", ",")
| mvexpand cs_user_agent
| eval Device = case(
  match(cs_user_agent, "iPhone|Macintosh|iPad"),"iPhone",
  match(cs_user_agent, "(?i)win64|14092|windows"),"Windows", 
  match(cs_user_agent, "Android|SM-|CPH|Nokia|Pixel|TB-|VFD|HP%20Pro%20Slate|VOG-L09|YAL-L21|ATU-L22|MAR-LX1A|RNE-L22|INE-LX2|AMN-LX2|LYO-LO2|DRA-LX9|LYA-L29|ANE-LX2J|STK-L22|EML-AL00|BLA-L29|LDN-LX2|TB3-|5033T|5028D|5002X|COR-|MI%20MAX|WAS-LX2|vivo|EML-L29|Moto|MMB|Redmi%20Note%208|M2003J15SC|MI%20MAX|Nexus|ELE-L29|Redmi%20Note%204|rv:89.0|VKY-L09|SmartN11|A330|LM-|G8341|INE-AL00|Mi|CLT|BV9700Pro|5024I|MEIZU"), "Android",
  match(cs_user_agent, "X11|Linux%20X86_64"),"Linux", 
  1==1, "OTHER")&lt;/LI-CODE&gt;&lt;P&gt;You could technically use a lookup, where each row of the lookup contains&lt;/P&gt;&lt;P&gt;*XXX*,YYY&lt;/P&gt;&lt;P&gt;where XXX is the expression you want and YYY is the device. Then make a lookup definition that uses that field as a wildcard, e.g. WILDCARD(cs_user_agent)&lt;/P&gt;&lt;P&gt;and then do&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| lookup lookup_definition cs_user_agent OUTPUT Device&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 01:16:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569031#M198332</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-09-30T01:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: User agent Extraction - Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569403#M198451</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not really, the output is coming with some errors like counts are similar for iphone &amp;amp; Desktop. please find below screen shot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jaibalaraman_0-1633122663078.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/16253iA7885539B1D440F4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jaibalaraman_0-1633122663078.png" alt="jaibalaraman_0-1633122663078.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Also could you please help me with some sample lookup command based on the case statement which you suggested&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 21:12:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569403#M198451</guid>
      <dc:creator>jaibalaraman</dc:creator>
      <dc:date>2021-10-01T21:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: User agent Extraction - Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569618#M198530</link>
      <description>&lt;P&gt;Can you share the current search?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 22:36:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569618#M198530</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-10-04T22:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: User agent Extraction - Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569619#M198531</link>
      <description>&lt;P&gt;Hi , yes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval Device = if(match(cs_user_agent,"SM-"),"Android", if(match(cs_user_agent,"CPH"),"Android",if(match(cs_user_agent,"Nokia"),"Android",if(match(cs_user_agent,"Pixel"),"Android",if(match(cs_user_agent,"TB-"),"Android",if(match(cs_user_agent,"VFD"),"Android",if(match(cs_user_agent,"HP%20Pro%20Slate"),"Android",if(match(cs_user_agent,"VOG-L09"),"Android",if(match(cs_user_agent,"YAL-L21"),"Android",if(match(cs_user_agent,"ATU-L22"),"Android",if(match(cs_user_agent,"MAR-LX1A"),"Android",if(match(cs_user_agent,"RNE-L22"),"Android",if(match(cs_user_agent,"INE-LX2"),"Android",if(match(cs_user_agent,"AMN-LX2"),"Android",if(match(cs_user_agent,"LYO-LO2"),"Android",if(match(cs_user_agent,"DRA-LX9"),"Android",if(match(cs_user_agent,"LYA-L29"),"Android",if(match(cs_user_agent,"ANE-LX2J"),"Android",if(match(cs_user_agent,"STK-L22"),"Android",if(match(cs_user_agent,"EML-AL00"),"Android",if(match(cs_user_agent,"BLA-L29"),"Android",if(match(cs_user_agent,"X11"),"Linux",if(match(cs_user_agent,"LDN-LX2"),"Android",if(match(cs_user_agent,"TB3-"),"Android",if(match(cs_user_agent,"5033T"),"Android",if(match(cs_user_agent,"5028D"),"Android",if(match(cs_user_agent,"5002X"),"Android",if(match(cs_user_agent,"COR-"),"Android",if(match(cs_user_agent,"MI%20MAX"),"Android",if(match(cs_user_agent,"WAS-LX2"),"Android",if(match(cs_user_agent,"vivo"),"Android",if(match(cs_user_agent,"EML-L29"),"Android",if(match(cs_user_agent,"Moto"),"Android",if(match(cs_user_agent,"MMB"),"Android",if(match(cs_user_agent,"Redmi%20Note%208"),"Android",if(match(cs_user_agent,"M2003J15SC"),"Android",if(match(cs_user_agent,"MI%20MAX"),"Android",if(match(cs_user_agent,"Nexus"),"Android",if(match(cs_user_agent,"ELE-L29"),"Android",if(match(cs_user_agent,"Redmi%20Note%204"),"Android",if(match(cs_user_agent,"rv:89.0"),"Android",if(match(cs_user_agent,"VKY-L09"),"Android",if(match(cs_user_agent,"SmartN11"),"Android",if(match(cs_user_agent,"A330"),"Android",if(match(cs_user_agent,"LM-"),"Android",if(match(cs_user_agent,"G8341"),"Android",if(match(cs_user_agent,"INE-AL00"),"Android",if(match(cs_user_agent,"Mi"),"Android",if(match(cs_user_agent,"CLT"),"Android",if(match(cs_user_agent,"Android"),"Android",if(match(cs_user_agent,"BV9700Pro"),"Android",if(match(cs_user_agent,"5024I"),"Android",if(match(cs_user_agent,"MEIZU"),"Android","OTHER"))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))&lt;BR /&gt;| stats count by Device | sort -count&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 22:40:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569619#M198531</guid>
      <dc:creator>jaibalaraman</dc:creator>
      <dc:date>2021-10-04T22:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: User agent Extraction - Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569625#M198533</link>
      <description>&lt;P&gt;Sorry, I assumed you were using the my suggested case statement - rather than your original nested if statement. Are you saying that if statement is what gives you the results in your screenshot?&lt;/P&gt;&lt;P&gt;As for your question on examples of the lookup command, my earlier post showed you how to use the lookup command to get what you want, you will just need to create your lookup as I suggeted. You will not need the case statement if you use a lookup.&lt;/P&gt;&lt;P&gt;See the lookup description here&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.2/SearchTutorial/Usefieldlookups" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.2/SearchTutorial/Usefieldlookups&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and how to set up wildcard lookups here&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.2/Knowledge/Addfieldmatchingrulestoyourlookupconfiguration" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.2/Knowledge/Addfieldmatchingrulestoyourlookupconfiguration&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 22:54:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/User-agent-Extraction-Lookup/m-p/569625#M198533</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-10-04T22:54:49Z</dc:date>
    </item>
  </channel>
</rss>

