<?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: String comparison in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/String-comparison/m-p/671202#M230033</link>
    <description>&lt;P&gt;From your SPL, it looks like you're trying to access the first line after At as the message type&lt;/P&gt;&lt;P&gt;Have you tried extracting Message type with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw "(?s)At \d+:\d+:\d+\s+-0800\s+-..\s+(?&amp;lt;message_type&amp;gt;\w+):"&lt;/LI-CODE&gt;&lt;P&gt;where the .. will match the line feed (you may only need a single dot, depends on the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Dec 2023 23:55:10 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2023-12-07T23:55:10Z</dc:date>
    <item>
      <title>String comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-comparison/m-p/671195#M230032</link>
      <description>&lt;P&gt;I've got this search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main sourcetype="bigfix"
| eval raw=_raw 
| rex mode=sed field=raw "s/\n/ /g" 
| rex field=raw "At \d+:\d+:\d+\s+-0800\s+-(?&amp;lt;message&amp;gt;.*)"
| rex field=message "^(?&amp;lt;message_type&amp;gt;[^:]+):\s"
| eval message_type_ns=replace(message_type, " ", "")
| eval x_message_type=if(message_type == message_type_ns, message_type, "No message type")
| stats count by message_type, message_type_ns, x_message_type&lt;/LI-CODE&gt;&lt;P&gt;That doesn't appear to be working correctly.&amp;nbsp; I'm always getting either all true or all false.&amp;nbsp; This is the output.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"message_type","message_type_ns","x_message_type",count
"     ActionLogMessage",ActionLogMessage,"No message type",240
"     ActiveDirectory",ActiveDirectory,"No message type",128
"     Client has an AuthenticationCertificate    Relay selected",ClienthasanAuthenticationCertificateRelayselected,"No message type",2
"     Client shutdown (Service manager shutdown request) ******************************************** Current Date","Clientshutdown(Servicemanagershutdownrequest)********************************************CurrentDate","No message type",3
"     Encryption",Encryption,"No message type",11
"     Initializing Site",InitializingSite,"No message type",43
"     PollForCommands",PollForCommands,"No message type",13
"     Processing fixlet site. ******************************************** Current Date","Processingfixletsite.********************************************CurrentDate","No message type",1
"     RegisterOnce",RegisterOnce,"No message type",149
"     Report posted successfully ******************************************** Current Date","Reportpostedsuccessfully********************************************CurrentDate","No message type",1
"     Restricted mode    Initializing Site",RestrictedmodeInitializingSite,"No message type",3
"     User interface process disabled for user 'user'    ActiveDirectory","Userinterfaceprocessdisabledforuser'user'ActiveDirectory","No message type",1
"     User interface process disabled for user 'user'    ActiveDirectory","Userinterfaceprocessdisabledforuser'user'ActiveDirectory","No message type",1
"     User interface session ended for user 'user'    User interface session ended for user 'user' ******************************************** Current Date","Userinterfacesessionendedforuser'user'Userinterfacesessionendedforuser'user'********************************************CurrentDate","No message type",1
"     User interface session ended for user 'user'    ActiveDirectory","Userinterfacesessionendedforuser'user'ActiveDirectory","No message type",1
"     User interface session ended for user 'user' ******************************************** Current Date","Userinterfacesessionendedforuser'user'********************************************CurrentDate","No message type",1&lt;/LI-CODE&gt;&lt;P&gt;When I try this simple case, it works.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval string_a="Client shutdown (Service manager shutdown request) ******************************************** Current Date"
| eval string_b="Client_shutdown_(Service_manager_shutdown_request)_********************************************_Current_Date"
| eval my_string=if(string_a == string_b, string_a, string_b)&lt;/LI-CODE&gt;&lt;P&gt;And the output&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_time	my_string	string_a	string_b
2023-12-07 10:14:17	Client_shutdown_(Service_manager_shutdown_request)_********************************************_Current_Date	Client shutdown (Service manager shutdown request) ******************************************** Current Date	Client_shutdown_(Service_manager_shutdown_request)_********************************************_Current_Date&lt;/LI-CODE&gt;&lt;P&gt;What I'm trying to do is find these&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;At 09:01:45 -0800 - 
   Encryption: optional encryption with no certificate; reports in cleartext&lt;/LI-CODE&gt;&lt;P&gt;The above would have message_type=Encryption.&amp;nbsp; This example&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;At 09:00:39 -0800 - 
   Starting client version xx.yy.zz.aa
   FIPS mode disabled by default.
   Cryptographic module initialized successfully.
   Using crypto library libBEScrypto - OpenSSL&lt;/LI-CODE&gt;&lt;P&gt;would have message_type="No message type".&amp;nbsp; I've tried using colon (:), but there are messages with embedded colons.&amp;nbsp; Any thoughts on how to solve this are appreciated.&lt;/P&gt;&lt;P&gt;TIA,&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 21:50:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-comparison/m-p/671195#M230032</guid>
      <dc:creator>jwhughes58</dc:creator>
      <dc:date>2023-12-07T21:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-comparison/m-p/671202#M230033</link>
      <description>&lt;P&gt;From your SPL, it looks like you're trying to access the first line after At as the message type&lt;/P&gt;&lt;P&gt;Have you tried extracting Message type with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw "(?s)At \d+:\d+:\d+\s+-0800\s+-..\s+(?&amp;lt;message_type&amp;gt;\w+):"&lt;/LI-CODE&gt;&lt;P&gt;where the .. will match the line feed (you may only need a single dot, depends on the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 23:55:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-comparison/m-p/671202#M230033</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-12-07T23:55:10Z</dc:date>
    </item>
  </channel>
</rss>

