<?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: transaction startswith from a lookup file in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685552#M233919</link>
    <description>&lt;P&gt;The following may look like voodoo but give it a try:-)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="test1" source="test2" run="test3"
| transaction source run startswith IN 
    [inputlookup messages.csv
    | fields Messages
    | rename Messages as search
    | format "(" "\"" "" "\"" "," ")"
    | rex field=search mode=sed "s/ *\" */\"/g"]
    endswith="status: PASS"&lt;/LI-CODE&gt;&lt;P&gt;#&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Format" target="_blank" rel="noopener"&gt;foremat&lt;/A&gt;magic&lt;span class="lia-unicode-emoji" title=":alien:"&gt;👽&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Apr 2024 04:49:03 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2024-04-26T04:49:03Z</dc:date>
    <item>
      <title>transaction startswith from a lookup file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685544#M233915</link>
      <description>&lt;P&gt;Hello I have the following sample log lines from a splunk search query&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;line1
line2
line3: field1 : some msg
line4
line5
status: PASS
line6
line7
line3: field2: some msg
line8
line9:
status: PASS
line1
line2
line3: field3: some msg
line4
line5:
status: PASS
line1
line2
line3: field4: some msg
line4
line5:
status: PASS&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to write a transaction to return lines between&lt;/P&gt;&lt;P&gt;field1, status: PASS&amp;nbsp;&lt;/P&gt;&lt;P&gt;field2, status: PASS&lt;/P&gt;&lt;P&gt;field3: status:PASS&lt;/P&gt;&lt;P&gt;and so-on&lt;/P&gt;&lt;P&gt;I have tried the following search query with multiple startswith values&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="test1" source="test2" run="test3"
| transaction source run startswith IN ("field1", "field2", "field3") endswith="status: PASS"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Instead of using IN keyword for startswith, I want to use a csv lookup table&amp;nbsp;&lt;STRONG&gt;messages.csv&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Sample&lt;STRONG&gt;&amp;nbsp;messages.csv&lt;/STRONG&gt; content&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;id,Message
1,field1
2,field2
3,field3
4,field4&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to write splunk transaction command with startswith parameter containing each&amp;nbsp;&lt;STRONG&gt;Message &lt;/STRONG&gt;field from&amp;nbsp;&lt;STRONG&gt;messages.csv&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My inputlookup CSV file may have 100 different rows with different messages&lt;/P&gt;&lt;P&gt;There is also a chance that my splunk search results may not have any entries with lines containing field1, field2, field3, field4&lt;/P&gt;&lt;P&gt;Can someone please help on how to write splunk transaction where &lt;STRONG&gt;startswith&lt;/STRONG&gt; needs to be run for each &lt;STRONG&gt;Message&lt;/STRONG&gt; in &lt;STRONG&gt;messages.csv&lt;/STRONG&gt;?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 02:45:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685544#M233915</guid>
      <dc:creator>MVK1</dc:creator>
      <dc:date>2024-04-26T02:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: transaction startswith from a lookup file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685552#M233919</link>
      <description>&lt;P&gt;The following may look like voodoo but give it a try:-)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="test1" source="test2" run="test3"
| transaction source run startswith IN 
    [inputlookup messages.csv
    | fields Messages
    | rename Messages as search
    | format "(" "\"" "" "\"" "," ")"
    | rex field=search mode=sed "s/ *\" */\"/g"]
    endswith="status: PASS"&lt;/LI-CODE&gt;&lt;P&gt;#&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Format" target="_blank" rel="noopener"&gt;foremat&lt;/A&gt;magic&lt;span class="lia-unicode-emoji" title=":alien:"&gt;👽&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 04:49:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685552#M233919</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-04-26T04:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: transaction startswith from a lookup file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685580#M233928</link>
      <description>&lt;P&gt;Thanks for the response&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I know what this block is doing?&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| format "(" "\"" "" "\"" "," ")"
| rex field=search mode=sed "s/ *\" */\"/g"&lt;/LI-CODE&gt;
&lt;P&gt;I don't see lines starting with startswith but see correct lines ending with endswith&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when I run this command separately&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;|inputlookup messages.csv
| fields Messages
| rename Messages as search
| format "(" "\"" "" "\"" "," ")"
| rex field=search mode=sed "s/ *\" */\"/g"&lt;/LI-CODE&gt;
&lt;P&gt;I see a column with name search and value (""field1"")&lt;/P&gt;
&lt;P&gt;Do we need to have field1 inside parentheses and two double quotes?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 09:10:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685580#M233928</guid>
      <dc:creator>MVK1</dc:creator>
      <dc:date>2024-04-26T09:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: transaction startswith from a lookup file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685662#M233951</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;I see a column with name search and value (""field1"")&lt;P&gt;Do we need to have field1 inside parentheses and two double quotes?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Field label "search" in a subsearch is a pseudo keyword for "use as is literal" in a search command. &amp;nbsp;No, they should NOT have two quotation marks on each side. &amp;nbsp;Maybe your lookup values insert one additional set of double quotes? &amp;nbsp;If so, we can get rid of one set.&lt;/P&gt;&lt;P&gt;Here is my emulation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="id,Messages
,a
,b
,c
,d"
``` the above emulates
| inputlookup messages.csv
```
| fields Messages
| rename Messages as search
| format "(" "\"" "" "\"" "," ")"
| rex field=search mode=sed "s/ *\" */\"/g"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output only contains one set of double quotes&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;search&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;("a","b","c","d")&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 26 Apr 2024 17:15:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685662#M233951</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-04-26T17:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: transaction startswith from a lookup file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685663#M233952</link>
      <description>&lt;P&gt;My guess of incorrect search results could be because of having spaces in my Message field in CSV&lt;/P&gt;&lt;P&gt;my input lookup CSV Message filed has a string &lt;STRONG&gt;"My input search message"&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to match all lines that start with entire line between "&lt;STRONG&gt;My input search message&lt;/STRONG&gt;"&amp;nbsp; and a given endswith&lt;/P&gt;&lt;P&gt;Currently I guess it is individually looking for events "&lt;STRONG&gt;My&lt;/STRONG&gt;"&amp;nbsp; "&lt;STRONG&gt;input" "search" "message" separately&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Can you please help how to match entire message in startswitb ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 17:07:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685663#M233952</guid>
      <dc:creator>MVK1</dc:creator>
      <dc:date>2024-04-26T17:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: transaction startswith from a lookup file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685667#M233954</link>
      <description>&lt;P&gt;Assuming my messages.csv has a single row with Messages field "&lt;STRONG&gt;My input search message&lt;/STRONG&gt;"&lt;/P&gt;
&lt;P&gt;I dont see any double quotes added until these 3 lines&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| inputlookup messages.csv
| fields Messages
| rename Messages as search &lt;/LI-CODE&gt;
&lt;P&gt;I see&amp;nbsp;&lt;STRONG&gt;My input search message&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After adding 4th line&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| inputlookup messages.csv
| fields Messages
| rename Messages as search 

| format "(" "\"" "" "\"" "," ")"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;I see the following&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;( " "My input search message" " )&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;After adding 5th line&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| inputlookup messages.csv
| fields Messages
| rename Messages as search 

| format "(" "\"" "" "\"" "," ")"

| rex field=search mode=sed "s/ *\" */\"/g"&lt;/LI-CODE&gt;
&lt;P&gt;I see the following result with two doublequotes&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;(""My input search message"")&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 20:19:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685667#M233954</guid>
      <dc:creator>MVK1</dc:creator>
      <dc:date>2024-04-26T20:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: transaction startswith from a lookup file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685719#M233967</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, breaker characters such as white spaces force Splunk to add quotation marks.&amp;nbsp; If you have mixed values with and without breaker characters, the rex needs to handle both.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup messages.csv
| fields Messages
| rename Messages AS search
| format "(" "\"" "" "\"" "," ")"
| rex field=search mode=sed "s/ *\" */\"/g s/\"\"/\"/g"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my emulation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="Messages
a
b c
d
e f g"
``` the above emulates
| inputlookup messages.csv
```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My result is now&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;search&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;("a","b c","d","e f g")&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Sun, 28 Apr 2024 00:17:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685719#M233967</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-04-28T00:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: transaction startswith from a lookup file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685895#M234021</link>
      <description>&lt;P&gt;Thank you for your time and response. I now don't see double quotes in the search query. This is helpful.&lt;/P&gt;&lt;P&gt;startswith="my start msg" endswith="my end msg" --&amp;gt; works&lt;/P&gt;&lt;P&gt;startswith IN ("my start msg1", "my start msg2", "my start msg3") endswith="my end msg"&amp;nbsp; &lt;STRONG&gt;---&amp;gt;&lt;/STRONG&gt; This is honoring only endswith flag and not returning events starting with my start msg lines "&lt;STRONG&gt;my start msg1"&lt;/STRONG&gt;&amp;nbsp;or "&lt;STRONG&gt;my start msg2"&amp;nbsp;&lt;/STRONG&gt;or "&lt;STRONG&gt;my start msg3"&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I notice that splunk search returns events before these matching &lt;STRONG&gt;startswith&lt;/STRONG&gt; fields&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will open a different question for that.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 22:06:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-startswith-from-a-lookup-file/m-p/685895#M234021</guid>
      <dc:creator>MVK1</dc:creator>
      <dc:date>2024-04-29T22:06:48Z</dc:date>
    </item>
  </channel>
</rss>

