<?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 How to create a list of literal values of strings with Splunk query language? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-list-of-literal-values-of-strings-with-Splunk/m-p/536047#M151547</link>
    <description>&lt;P&gt;The requirements is to find the event_A and event_B such that&lt;/P&gt;&lt;OL class="org-ol"&gt;&lt;LI&gt;There is some event A's before the event_B, and the event_A’s TEXT field and the event_B’s TEXT field have the first character identical, and the second characters satisfy the condition:&lt;UL class="org-ul"&gt;&lt;LI&gt;the event_B’s TEXT’s 2nd character in numerical value is equal to the event_A’s corresponding field’s 2nd character, or event_B’s is 1 plus, or 1 minus of the event_A’s.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;OL class="org-ol"&gt;&lt;LI&gt;It is after some event_A satisfying condition 1, with CATEGORY value “ALARM” and not after such event_A with CATEGORY value “CLEARED”, or&lt;/LI&gt;&lt;LI&gt;It is after some event_A satisfying condition 1, with CATEGORY value “CLEARED”, but the event_B’s _time is within 60 minutes of the _time of event_A (CATEGORY=CLEARED)&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here are some sample data:&lt;/P&gt;&lt;PRE&gt;_time	                        CATEGORY	TYPE	TEXT
2020-12-29T05:20:32.710-0800	ADVISORY	event_B	K35JB
2020-12-29T05:37:54.462-0800	ADVISORY	event_B	A05KM
2020-12-29T05:57:50.164-0800	ADVISORY	event_B	K25CD
2020-12-29T05:59:06.004-0800	ALARM	    event_A	R20-A
2020-12-29T05:59:24.635-0800	ALARM	    event_A	K35-E
2020-12-29T05:59:37.200-0800	ALARM	    event_A	C15
2020-12-29T06:00:24.470-0800	CLEARED	    event_A	R20-A
2020-12-29T06:00:40.415-0800	CLEARED	    event_A	K35-E
2020-12-29T06:08:09.945-0800	ADVISORY	event_B	R65AG
2020-12-29T06:14:24.740-0800	ADVISORY	event_B	K35JB
2020-12-29T06:14:43.988-0800	ADVISORY	event_B	K45JB
2020-12-29T06:56:44.642-0800	ADVISORY	event_B	A77MD
2020-12-29T06:59:42.745-0800	ADVISORY	event_B	C87AB
2020-12-29T07:30:39.080-0800	ADVISORY	event_B	M97AF
2020-12-29T08:39:26.008-0800	ADVISORY	event_B	K25BA
2020-12-29T09:46:48.175-0800	ADVISORY	event_B	C25EG&lt;/PRE&gt;&lt;P&gt;Here is the illustration with the above sample data (with comment after # )&lt;/P&gt;&lt;PRE&gt;_time	                        CATEGORY	TYPE	TEXT
                                                                # all the event_B without event_A before are eliminated
2020-12-29T05:59:06.004-0800	ALARM	    event_A	R20-A   # expecting event_B with TEXT with prefix Ri where i = 1, 2, 3
2020-12-29T05:59:24.635-0800	ALARM	    event_A	K35-E   # expecting event_B with TEXT with prefix Ki where i = 2, 3, 4
2020-12-29T05:59:37.200-0800	ALARM	    event_A	C15     # expecting event_B with TEXT with prefix Ci where i = 0, 1, 2
2020-12-29T06:00:24.470-0800	CLEARED	    event_A	R20-A   # only expecting event_B with TEXT with prefix Ri where i = 1, 2, 3 with _time &amp;lt; 2020-12-29T06:00:24.470-0800 + 60 minutes
2020-12-29T06:00:40.415-0800	CLEARED	    event_A	K35-E   # only expecting event_B with TEXT with prefix Ki where i = 2, 3, 4 with _time &amp;lt; 2020-12-29T06:00:40.415-0800 + 60 minutes
2020-12-29T06:08:09.945-0800	ADVISORY	event_B	R65AG   # to be eliminated, not expected, as R6 does not match Ri, i=1, 2, 3
2020-12-29T06:14:24.740-0800	ADVISORY	event_B	K35JB   # kept, as K3 matched the expected prefix, and within the time windows
2020-12-29T06:14:43.988-0800	ADVISORY	event_B	K45JB   # kept, as K4 matched the expected prefix, and within the time windows
2020-12-29T06:56:44.642-0800	ADVISORY	event_B	A77MD   # to be eliminated, not expected, as A7 does not match any of the expected prefix
2020-12-29T06:59:42.745-0800	ADVISORY	event_B	C87AB   # to be eliminated, not expected, as C8 does not match Ci, i=0, 1, 2
2020-12-29T07:30:39.080-0800	ADVISORY	event_B	M97AF   # to be eliminated, not expected, as M9 does not match any of the expected prefix
2020-12-29T08:39:26.008-0800	ADVISORY	event_B	K25BA   # to be eliminated, not expected, as its _time is beyond the expected window
2020-12-29T09:46:48.175-0800	ADVISORY	event_B	C25EG   # kept, as C2 matched the expected prefix, and there is no time window limit for the prefx C2&lt;/PRE&gt;&lt;P&gt;I cannot wrap my head to figure a solution with Splunk query.&lt;/P&gt;&lt;P&gt;I could only find a solution when there is only one event_A expecting the corresponding event_B, using streamstats to keep of track the only one expecting event_A’s TEXT prefix, and _time to scan for the satisfying event_B, but once there are multiple event_A’s expecting with different TEXT prefixes and _time’s, then I cannot find a way to remember and perform the scan for the multiple event_A’s expectations.&lt;/P&gt;&lt;P&gt;With a conventional programming language, say Python, I’ll keep track of the union of expectant prefixes, and time windows, and scan the events against such history state.&lt;/P&gt;&lt;P&gt;Could you kindly help me! Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jan 2021 20:06:45 GMT</pubDate>
    <dc:creator>yshen</dc:creator>
    <dc:date>2021-01-15T20:06:45Z</dc:date>
    <item>
      <title>How to create a list of literal values of strings with Splunk query language?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-list-of-literal-values-of-strings-with-Splunk/m-p/536047#M151547</link>
      <description>&lt;P&gt;The requirements is to find the event_A and event_B such that&lt;/P&gt;&lt;OL class="org-ol"&gt;&lt;LI&gt;There is some event A's before the event_B, and the event_A’s TEXT field and the event_B’s TEXT field have the first character identical, and the second characters satisfy the condition:&lt;UL class="org-ul"&gt;&lt;LI&gt;the event_B’s TEXT’s 2nd character in numerical value is equal to the event_A’s corresponding field’s 2nd character, or event_B’s is 1 plus, or 1 minus of the event_A’s.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;OL class="org-ol"&gt;&lt;LI&gt;It is after some event_A satisfying condition 1, with CATEGORY value “ALARM” and not after such event_A with CATEGORY value “CLEARED”, or&lt;/LI&gt;&lt;LI&gt;It is after some event_A satisfying condition 1, with CATEGORY value “CLEARED”, but the event_B’s _time is within 60 minutes of the _time of event_A (CATEGORY=CLEARED)&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here are some sample data:&lt;/P&gt;&lt;PRE&gt;_time	                        CATEGORY	TYPE	TEXT
2020-12-29T05:20:32.710-0800	ADVISORY	event_B	K35JB
2020-12-29T05:37:54.462-0800	ADVISORY	event_B	A05KM
2020-12-29T05:57:50.164-0800	ADVISORY	event_B	K25CD
2020-12-29T05:59:06.004-0800	ALARM	    event_A	R20-A
2020-12-29T05:59:24.635-0800	ALARM	    event_A	K35-E
2020-12-29T05:59:37.200-0800	ALARM	    event_A	C15
2020-12-29T06:00:24.470-0800	CLEARED	    event_A	R20-A
2020-12-29T06:00:40.415-0800	CLEARED	    event_A	K35-E
2020-12-29T06:08:09.945-0800	ADVISORY	event_B	R65AG
2020-12-29T06:14:24.740-0800	ADVISORY	event_B	K35JB
2020-12-29T06:14:43.988-0800	ADVISORY	event_B	K45JB
2020-12-29T06:56:44.642-0800	ADVISORY	event_B	A77MD
2020-12-29T06:59:42.745-0800	ADVISORY	event_B	C87AB
2020-12-29T07:30:39.080-0800	ADVISORY	event_B	M97AF
2020-12-29T08:39:26.008-0800	ADVISORY	event_B	K25BA
2020-12-29T09:46:48.175-0800	ADVISORY	event_B	C25EG&lt;/PRE&gt;&lt;P&gt;Here is the illustration with the above sample data (with comment after # )&lt;/P&gt;&lt;PRE&gt;_time	                        CATEGORY	TYPE	TEXT
                                                                # all the event_B without event_A before are eliminated
2020-12-29T05:59:06.004-0800	ALARM	    event_A	R20-A   # expecting event_B with TEXT with prefix Ri where i = 1, 2, 3
2020-12-29T05:59:24.635-0800	ALARM	    event_A	K35-E   # expecting event_B with TEXT with prefix Ki where i = 2, 3, 4
2020-12-29T05:59:37.200-0800	ALARM	    event_A	C15     # expecting event_B with TEXT with prefix Ci where i = 0, 1, 2
2020-12-29T06:00:24.470-0800	CLEARED	    event_A	R20-A   # only expecting event_B with TEXT with prefix Ri where i = 1, 2, 3 with _time &amp;lt; 2020-12-29T06:00:24.470-0800 + 60 minutes
2020-12-29T06:00:40.415-0800	CLEARED	    event_A	K35-E   # only expecting event_B with TEXT with prefix Ki where i = 2, 3, 4 with _time &amp;lt; 2020-12-29T06:00:40.415-0800 + 60 minutes
2020-12-29T06:08:09.945-0800	ADVISORY	event_B	R65AG   # to be eliminated, not expected, as R6 does not match Ri, i=1, 2, 3
2020-12-29T06:14:24.740-0800	ADVISORY	event_B	K35JB   # kept, as K3 matched the expected prefix, and within the time windows
2020-12-29T06:14:43.988-0800	ADVISORY	event_B	K45JB   # kept, as K4 matched the expected prefix, and within the time windows
2020-12-29T06:56:44.642-0800	ADVISORY	event_B	A77MD   # to be eliminated, not expected, as A7 does not match any of the expected prefix
2020-12-29T06:59:42.745-0800	ADVISORY	event_B	C87AB   # to be eliminated, not expected, as C8 does not match Ci, i=0, 1, 2
2020-12-29T07:30:39.080-0800	ADVISORY	event_B	M97AF   # to be eliminated, not expected, as M9 does not match any of the expected prefix
2020-12-29T08:39:26.008-0800	ADVISORY	event_B	K25BA   # to be eliminated, not expected, as its _time is beyond the expected window
2020-12-29T09:46:48.175-0800	ADVISORY	event_B	C25EG   # kept, as C2 matched the expected prefix, and there is no time window limit for the prefx C2&lt;/PRE&gt;&lt;P&gt;I cannot wrap my head to figure a solution with Splunk query.&lt;/P&gt;&lt;P&gt;I could only find a solution when there is only one event_A expecting the corresponding event_B, using streamstats to keep of track the only one expecting event_A’s TEXT prefix, and _time to scan for the satisfying event_B, but once there are multiple event_A’s expecting with different TEXT prefixes and _time’s, then I cannot find a way to remember and perform the scan for the multiple event_A’s expectations.&lt;/P&gt;&lt;P&gt;With a conventional programming language, say Python, I’ll keep track of the union of expectant prefixes, and time windows, and scan the events against such history state.&lt;/P&gt;&lt;P&gt;Could you kindly help me! Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2021 20:06:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-list-of-literal-values-of-strings-with-Splunk/m-p/536047#M151547</guid>
      <dc:creator>yshen</dc:creator>
      <dc:date>2021-01-15T20:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a list of literal values of strings with Splunk query language?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-list-of-literal-values-of-strings-with-Splunk/m-p/536059#M151556</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="_time	                        CATEGORY	TYPE	TEXT
2020-12-29T05:20:32.710-0800	ADVISORY	event_B	K35JB
2020-12-29T05:37:54.462-0800	ADVISORY	event_B	A05KM
2020-12-29T05:57:50.164-0800	ADVISORY	event_B	K25CD
2020-12-29T05:59:06.004-0800	ALARM	event_A	R20-A
2020-12-29T05:59:24.635-0800	ALARM	event_A	K35-E
2020-12-29T05:59:37.200-0800	ALARM	event_A	C15
2020-12-29T06:00:24.470-0800	CLEARED	event_A	R20-A
2020-12-29T06:00:40.415-0800	CLEARED	event_A	K35-E
2020-12-29T06:08:09.945-0800	ADVISORY	event_B	R65AG
2020-12-29T06:14:24.740-0800	ADVISORY	event_B	K35JB
2020-12-29T06:14:43.988-0800	ADVISORY	event_B	K45JB
2020-12-29T06:56:44.642-0800	ADVISORY	event_B	A77MD
2020-12-29T06:59:42.745-0800	ADVISORY	event_B	C87AB
2020-12-29T07:30:39.080-0800	ADVISORY	event_B	M97AF
2020-12-29T08:39:26.008-0800	ADVISORY	event_B	K25BA
2020-12-29T09:46:48.175-0800	ADVISORY	event_B	C25EG" 
| multikv forceheader=1 
| eval _time=strptime(time,"%FT%T.%3Q%:z") 
| table _time CATEGORY TYPE TEXT 
| rex field=TEXT "(?&amp;lt;cat1&amp;gt;\w)(?&amp;lt;cat2&amp;gt;\w)" 
| eval cat2_range=mvrange(cat2-1,cat2+2) 
| streamstats count(eval(TYPE="event_A")) as session 
| where session &amp;gt; 0 
| eventstats values(eval(if(CATEGORY="ALARM",cat2_range,NULL))) as limit
    values(eval(if(CATEGORY="CLEARED",relative_time(_time,"+60m"),NULL))) as limit_time by cat1 
| where CATEGORY IN ("ALARM","CLEARED")
    OR (CATEGORY="ADVISORY" AND if(limit_time!="",match(limit,cat2) AND _time &amp;lt;= limit_time,match(limit,cat2)))
```
| table _time CATEGORY TYPE TEXT
```&lt;/LI-CODE&gt;&lt;P&gt;I just filtered it as you asked.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2021 21:18:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-list-of-literal-values-of-strings-with-Splunk/m-p/536059#M151556</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2021-01-15T21:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a list of literal values of strings with Splunk query language?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-list-of-literal-values-of-strings-with-Splunk/m-p/536076#M151561</link>
      <description>&lt;P&gt;Amazing! Powerful, and sophisticated!&lt;/P&gt;&lt;P&gt;Thanks a million!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2021 22:51:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-list-of-literal-values-of-strings-with-Splunk/m-p/536076#M151561</guid>
      <dc:creator>yshen</dc:creator>
      <dc:date>2021-01-15T22:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a list of literal values of strings with Splunk query language?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-list-of-literal-values-of-strings-with-Splunk/m-p/536079#M151563</link>
      <description>&lt;P&gt;Your question was very clear, and I just had to make it that way.&lt;BR /&gt;I hope it is the same for others.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2021 23:10:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-list-of-literal-values-of-strings-with-Splunk/m-p/536079#M151563</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2021-01-15T23:10:36Z</dc:date>
    </item>
  </channel>
</rss>

