<?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: How to left join ext data to event and perform rowwise eval? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639504#M221583</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;. I am clear from what&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp;mentioned in terms of use of avoiding use of joins.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's is what I am looking for.&lt;/P&gt;&lt;P&gt;I have external data in lookup with a list of eventName, min_threshold, max_threshold&lt;/P&gt;&lt;P&gt;From splunk source events, I am doing inline rex to extract the eventName field&lt;/P&gt;&lt;P&gt;Then I would like to do a count on the eventName and check if it is outside the min/max threshold for that particular eventName from the lookup file&lt;/P&gt;&lt;P&gt;Additionally, I would like my count table to display eventCount as "0" and not meeting threshold for eventNames in the look up data that is not available in source events.&lt;/P&gt;&lt;P&gt;This is why I was looking at left Join, but even beyond that - I am struggling on how to perform the rowwise comparison on the count stats&lt;/P&gt;</description>
    <pubDate>Tue, 11 Apr 2023 13:12:56 GMT</pubDate>
    <dc:creator>krbalaji77</dc:creator>
    <dc:date>2023-04-11T13:12:56Z</dc:date>
    <item>
      <title>How to left join ext data to event and perform rowwise eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/638872#M221364</link>
      <description>&lt;P&gt;I have a lookup table with an event name with min max thresholds&lt;/P&gt;
&lt;P&gt;I need to join this (left on the lookup) with the event count by with null fill on events not present in search&lt;/P&gt;
&lt;P&gt;lastly - I need rowwise comparison of event count against min / max and conditional format&amp;nbsp; coloring rows with counts out of band.&lt;/P&gt;
&lt;P&gt;I am able to left join the data but I am unable to proceed beyond that as I am not able to reference the attributes for any additional evals&lt;/P&gt;
&lt;P&gt;Any help or direction would be greatly appreciate:&lt;/P&gt;
&lt;P&gt;| inputlookup bk_lookup.csv&lt;BR /&gt;| join type=left left=L right=R where L.alertCode = R.alertCode [search index=my_index log_group="/my/log/group" "*cache*"&lt;BR /&gt;| rex field=event.message "alertCode: (?&amp;lt;alertCode&amp;gt;.*), version: (?&amp;lt;version&amp;gt;.*)"&lt;BR /&gt;| stats count as invokes by alertCode]&lt;BR /&gt;| table L.alertCode, R.invokes, L.min, L.max&lt;BR /&gt;| fillnull value=0 R.invokes&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 18:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/638872#M221364</guid>
      <dc:creator>krbalaji77</dc:creator>
      <dc:date>2023-04-05T18:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to left join ext data to event and perform rowwise eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/638921#M221390</link>
      <description>&lt;P&gt;You are thinking about it wrong (like SQL).&amp;nbsp; See this post for the full nitty-gritty (don't forget the karma):&lt;BR /&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/What-is-the-relation-between-the-Splunk-inner-left-join-and-the/m-p/391288" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Search/What-is-the-relation-between-the-Splunk-inner-left-join-and-the/m-p/391288&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;So in your case, you would start EITHER like this:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;index=my_index log_group="/my/log/group" "*cache*"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| rex field=event.message "alertCode: (?&amp;lt;alertCode&amp;gt;.*), version: (?&amp;lt;version&amp;gt;.*)"&lt;BR /&gt;&lt;/SPAN&gt;| lookup&amp;nbsp;&lt;SPAN&gt;bk_lookup.csv alertCode&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;OR like this:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;index=my_index log_group="/my/log/group" "*cache*"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| rex field=event.message "alertCode: (?&amp;lt;alertCode&amp;gt;.*), version: (?&amp;lt;version&amp;gt;.*)"&lt;BR /&gt;&lt;/SPAN&gt;| inputlookup append=true&amp;nbsp;&lt;SPAN&gt;bk_lookup.csv&lt;BR /&gt;&lt;/SPAN&gt;| eval sourcetype=coalesce(sourcetype, "&lt;SPAN&gt;bk_lookup")&lt;BR /&gt;&lt;BR /&gt;Then complete like shown in the other post.&lt;BR /&gt;DO NOT EVER USE JOIN.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 23:10:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/638921#M221390</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2023-04-05T23:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to left join ext data to event and perform rowwise eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639371#M221528</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;A class="" href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406" target="_self"&gt;&lt;SPAN class=""&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;for your response. I am still unable to reference other fields(like min and max threshold for each alertcode) from the excel in the context of evaluation against count by alertcode. This is where I have been struggling quite a bit.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 14:27:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639371#M221528</guid>
      <dc:creator>krbalaji77</dc:creator>
      <dc:date>2023-04-10T14:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to left join ext data to event and perform rowwise eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639460#M221562</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp;is right. &amp;nbsp;Do not think in terms of join, or any SQL operation. &amp;nbsp;Maybe you can describe the actual use case/application with illustrative data and desired output. &amp;nbsp;Splunk usually has a better way than emulating SQL.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 07:36:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639460#M221562</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-04-11T07:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to left join ext data to event and perform rowwise eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639504#M221583</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;. I am clear from what&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp;mentioned in terms of use of avoiding use of joins.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's is what I am looking for.&lt;/P&gt;&lt;P&gt;I have external data in lookup with a list of eventName, min_threshold, max_threshold&lt;/P&gt;&lt;P&gt;From splunk source events, I am doing inline rex to extract the eventName field&lt;/P&gt;&lt;P&gt;Then I would like to do a count on the eventName and check if it is outside the min/max threshold for that particular eventName from the lookup file&lt;/P&gt;&lt;P&gt;Additionally, I would like my count table to display eventCount as "0" and not meeting threshold for eventNames in the look up data that is not available in source events.&lt;/P&gt;&lt;P&gt;This is why I was looking at left Join, but even beyond that - I am struggling on how to perform the rowwise comparison on the count stats&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 13:12:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639504#M221583</guid>
      <dc:creator>krbalaji77</dc:creator>
      <dc:date>2023-04-11T13:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to left join ext data to event and perform rowwise eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639546#M221599</link>
      <description>&lt;P&gt;Read my answer.&amp;nbsp; Run the searches.&amp;nbsp; It is ALL there.&amp;nbsp; If you need `min()` or `max()` then just add those to the `stats` command.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 20:03:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639546#M221599</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2023-04-11T20:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to left join ext data to event and perform rowwise eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639601#M221633</link>
      <description>&lt;P&gt;So, let's start with&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;'s code and build in SPL.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index log_group="/my/log/group" "*cache*"
| rex field=event.message "alertCode: (?&amp;lt;alertCode&amp;gt;.*), version: (?&amp;lt;version&amp;gt;.*)"
| lookup bk_lookup.csv alertCode ``` output min_threshold max_threshold ```
| stats count as invokes by alertCode min_threshold max_threshold
| eval in_threshold = if(min_threshold &amp;gt; invokes OR invokes &amp;gt; max_threshold, "no", "yes")&lt;/LI-CODE&gt;&lt;P&gt;This accomplishes the first half of your requirement, namely&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Then I would like to do a count on the eventName and check if it is outside the min/max threshold for that particular eventName from the lookup file&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;(I think eventName is the same as alertCode in your code illustration.) The second half is&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Additionally, I would like my count table to display eventCount as "0" and not meeting threshold for eventNames in the look up data that is not available in source events.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You are correct that some sort of join is necessary here. &amp;nbsp;But a simple left join is insufficient. &amp;nbsp;A common trick is to &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Append" target="_blank" rel="noopener"&gt;append&lt;/A&gt;, then do another stats.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index log_group="/my/log/group" "*cache*"
| rex field=event.message "alertCode: (?&amp;lt;alertCode&amp;gt;.*), version: (?&amp;lt;version&amp;gt;.*)"
| stats count by alertCode
| append
    [| inputlookup bk_lookup.csv]
| stats values(count) as invokes values(*_threshold) as *_threshold by alertCode
| eval in_threshold = case(isnull(invokes), "n/a", min_threshold &amp;gt; invokes OR invokes &amp;gt; max_threshold, "no", true(), "yes")
| fillnull invokes value=0 ``` any alertCode not in events are given value 0 ```&lt;/LI-CODE&gt;&lt;P&gt;When using append + stats with inputlookup, lookup command is often unnecessary because stats groupby takes care of the matching.&lt;/P&gt;&lt;P&gt;Note: The in_threshold calculation is valid only if every alertCode has only one entry in bk_lookup.csv.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 08:25:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639601#M221633</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-04-12T08:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to left join ext data to event and perform rowwise eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639662#M221660</link>
      <description>&lt;P&gt;Thanks a bunch &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;. This is perfect. I was not aware of the values function.&amp;nbsp; Also I had the threshold named min and max that kind a of added to the confusion as well.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp; - Thank you for the clear direction as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate both your help.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 15:55:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-left-join-ext-data-to-event-and-perform-rowwise-eval/m-p/639662#M221660</guid>
      <dc:creator>krbalaji77</dc:creator>
      <dc:date>2023-04-12T15:55:37Z</dc:date>
    </item>
  </channel>
</rss>

